2019-03-01 08:57:10 -05:00
|
|
|
<?php
|
2021-12-15 04:58:32 +01:00
|
|
|
|
2019-05-09 18:58:30 -04:00
|
|
|
namespace Psalm\Test\Config\Plugin\Hook;
|
2019-03-01 08:57:10 -05:00
|
|
|
|
2021-01-06 15:05:53 +01:00
|
|
|
use Psalm\Plugin\EventHandler\Event\PropertyExistenceProviderEvent;
|
|
|
|
use Psalm\Plugin\EventHandler\Event\PropertyTypeProviderEvent;
|
|
|
|
use Psalm\Plugin\EventHandler\Event\PropertyVisibilityProviderEvent;
|
2021-06-08 05:55:21 +03:00
|
|
|
use Psalm\Plugin\EventHandler\PropertyExistenceProviderInterface;
|
|
|
|
use Psalm\Plugin\EventHandler\PropertyTypeProviderInterface;
|
|
|
|
use Psalm\Plugin\EventHandler\PropertyVisibilityProviderInterface;
|
2019-03-23 14:27:54 -04:00
|
|
|
use Psalm\Type;
|
2021-12-13 16:28:14 +01:00
|
|
|
use Psalm\Type\Union;
|
2019-03-01 08:57:10 -05:00
|
|
|
|
|
|
|
class FooPropertyProvider implements
|
|
|
|
PropertyExistenceProviderInterface,
|
|
|
|
PropertyVisibilityProviderInterface,
|
|
|
|
PropertyTypeProviderInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return array<string>
|
|
|
|
*/
|
2021-12-05 18:51:26 +01:00
|
|
|
public static function getClassLikeNames(): array
|
2019-03-01 08:57:10 -05:00
|
|
|
{
|
|
|
|
return ['Ns\Foo'];
|
|
|
|
}
|
|
|
|
|
2021-01-06 15:05:53 +01:00
|
|
|
public static function doesPropertyExist(PropertyExistenceProviderEvent $event): ?bool
|
|
|
|
{
|
|
|
|
$property_name = $event->getPropertyName();
|
2019-03-01 08:57:10 -05:00
|
|
|
return $property_name === 'magic_property';
|
|
|
|
}
|
|
|
|
|
2021-01-06 15:05:53 +01:00
|
|
|
public static function isPropertyVisible(PropertyVisibilityProviderEvent $event): ?bool
|
|
|
|
{
|
2019-03-01 08:57:10 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-12-13 16:28:14 +01:00
|
|
|
public static function getPropertyType(PropertyTypeProviderEvent $event): ?Union
|
2021-01-06 15:05:53 +01:00
|
|
|
{
|
2019-03-01 08:57:10 -05:00
|
|
|
return Type::getString();
|
|
|
|
}
|
|
|
|
}
|