mirror of
https://github.com/danog/psalm.git
synced 2024-12-02 17:52:45 +01:00
d8fea8aabb
* implement DTO for plugins * introduce EventHandler + reintroduce legacy API for plugins
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
namespace Psalm\Test\Config\Plugin\Hook;
|
|
|
|
use Psalm\Plugin\EventHandler\PropertyExistenceProviderInterface;
|
|
use Psalm\Plugin\EventHandler\PropertyTypeProviderInterface;
|
|
use Psalm\Plugin\EventHandler\PropertyVisibilityProviderInterface;
|
|
use Psalm\Plugin\EventHandler\Event\PropertyExistenceProviderEvent;
|
|
use Psalm\Plugin\EventHandler\Event\PropertyTypeProviderEvent;
|
|
use Psalm\Plugin\EventHandler\Event\PropertyVisibilityProviderEvent;
|
|
use Psalm\Type;
|
|
|
|
class FooPropertyProvider implements
|
|
PropertyExistenceProviderInterface,
|
|
PropertyVisibilityProviderInterface,
|
|
PropertyTypeProviderInterface
|
|
{
|
|
/**
|
|
* @return array<string>
|
|
*/
|
|
public static function getClassLikeNames() : array
|
|
{
|
|
return ['Ns\Foo'];
|
|
}
|
|
|
|
public static function doesPropertyExist(PropertyExistenceProviderEvent $event): ?bool
|
|
{
|
|
$property_name = $event->getPropertyName();
|
|
return $property_name === 'magic_property';
|
|
}
|
|
|
|
public static function isPropertyVisible(PropertyVisibilityProviderEvent $event): ?bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public static function getPropertyType(PropertyTypeProviderEvent $event): ?Type\Union
|
|
{
|
|
return Type::getString();
|
|
}
|
|
}
|