2019-03-01 14:57:10 +01:00
|
|
|
<?php
|
2019-05-10 00:58:30 +02:00
|
|
|
namespace Psalm\Test\Config\Plugin\Hook;
|
2019-03-01 14:57:10 +01:00
|
|
|
|
|
|
|
use PhpParser;
|
|
|
|
use Psalm\CodeLocation;
|
|
|
|
use Psalm\Context;
|
2019-03-23 19:27:54 +01:00
|
|
|
use Psalm\Plugin\Hook\PropertyExistenceProviderInterface;
|
|
|
|
use Psalm\Plugin\Hook\PropertyTypeProviderInterface;
|
|
|
|
use Psalm\Plugin\Hook\PropertyVisibilityProviderInterface;
|
2019-03-01 14:57:10 +01:00
|
|
|
use Psalm\StatementsSource;
|
2019-03-23 19:27:54 +01:00
|
|
|
use Psalm\Type;
|
2019-03-01 14:57:10 +01:00
|
|
|
|
|
|
|
class FooPropertyProvider implements
|
|
|
|
PropertyExistenceProviderInterface,
|
|
|
|
PropertyVisibilityProviderInterface,
|
|
|
|
PropertyTypeProviderInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return array<string>
|
|
|
|
*/
|
|
|
|
public static function getClassLikeNames() : array
|
|
|
|
{
|
|
|
|
return ['Ns\Foo'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function doesPropertyExist(
|
|
|
|
string $fq_classlike_name,
|
|
|
|
string $property_name,
|
|
|
|
bool $read_mode,
|
2020-09-07 01:36:47 +02:00
|
|
|
?StatementsSource $source = null,
|
|
|
|
?Context $context = null,
|
|
|
|
?CodeLocation $code_location = null
|
2020-09-12 17:24:05 +02:00
|
|
|
): ?bool {
|
2019-03-01 14:57:10 +01:00
|
|
|
return $property_name === 'magic_property';
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function isPropertyVisible(
|
|
|
|
StatementsSource $source,
|
|
|
|
string $fq_classlike_name,
|
|
|
|
string $property_name,
|
|
|
|
bool $read_mode,
|
2020-09-07 01:36:47 +02:00
|
|
|
?Context $context = null,
|
|
|
|
?CodeLocation $code_location = null
|
2020-09-12 17:24:05 +02:00
|
|
|
): ?bool {
|
2019-03-01 14:57:10 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getPropertyType(
|
|
|
|
string $fq_classlike_name,
|
|
|
|
string $property_name,
|
|
|
|
bool $read_mode,
|
2020-09-07 01:36:47 +02:00
|
|
|
?StatementsSource $source = null,
|
|
|
|
?Context $context = null
|
2020-09-12 17:24:05 +02:00
|
|
|
): ?Type\Union {
|
2019-03-01 14:57:10 +01:00
|
|
|
return Type::getString();
|
|
|
|
}
|
|
|
|
}
|