1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-04 18:48:03 +01:00
psalm/tests/Plugin/Hook/FooPropertyProvider.php
Matthew Brown 317f790bde
New plugin hooks (#1405)
* Add a bunch of new hooks

* Add more integrations

* Add some broken tests

* Add more things

* Fix remaining interfaces

* Suppress proper issue

* UndefinedMethod should not stop analysis

* Add handlers for two custom method return types
2019-03-01 08:57:10 -05:00

71 lines
1.6 KiB
PHP

<?php
namespace Psalm\Test\Plugin\Hook;
use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Type;
use Psalm\StatementsSource;
use Psalm\Plugin\Hook\{
PropertyExistenceProviderInterface,
PropertyVisibilityProviderInterface,
PropertyTypeProviderInterface
};
class FooPropertyProvider implements
PropertyExistenceProviderInterface,
PropertyVisibilityProviderInterface,
PropertyTypeProviderInterface
{
/**
* @return array<string>
*/
public static function getClassLikeNames() : array
{
return ['Ns\Foo'];
}
/**
* @return ?bool
*/
public static function doesPropertyExist(
string $fq_classlike_name,
string $property_name,
bool $read_mode,
StatementsSource $source = null,
Context $context = null,
CodeLocation $code_location = null
) {
return $property_name === 'magic_property';
}
/**
* @return ?bool
*/
public static function isPropertyVisible(
StatementsSource $source,
string $fq_classlike_name,
string $property_name,
bool $read_mode,
Context $context = null,
CodeLocation $code_location = null
) {
return true;
}
/**
* @param array<PhpParser\Node\Arg> $call_args
* @return ?Type\Union
*/
public static function getPropertyType(
string $fq_classlike_name,
string $property_name,
bool $read_mode,
StatementsSource $source = null,
Context $context = null
) {
return Type::getString();
}
}