mirror of
https://github.com/danog/psalm.git
synced 2024-12-02 17:52:45 +01:00
47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Psalm\Test\Config\Plugin\Hook;
|
|
|
|
use Psalm\Plugin\EventHandler\Event\FunctionExistenceProviderEvent;
|
|
use Psalm\Plugin\EventHandler\Event\FunctionParamsProviderEvent;
|
|
use Psalm\Plugin\EventHandler\Event\FunctionReturnTypeProviderEvent;
|
|
use Psalm\Plugin\EventHandler\FunctionExistenceProviderInterface;
|
|
use Psalm\Plugin\EventHandler\FunctionParamsProviderInterface;
|
|
use Psalm\Plugin\EventHandler\FunctionReturnTypeProviderInterface;
|
|
use Psalm\Storage\FunctionLikeParameter;
|
|
use Psalm\Type;
|
|
use Psalm\Type\Union;
|
|
|
|
class MagicFunctionProvider implements
|
|
FunctionExistenceProviderInterface,
|
|
FunctionParamsProviderInterface,
|
|
FunctionReturnTypeProviderInterface
|
|
{
|
|
/**
|
|
* @return array<lowercase-string>
|
|
*/
|
|
public static function getFunctionIds(): array
|
|
{
|
|
return ['magicfunction'];
|
|
}
|
|
|
|
public static function doesFunctionExist(FunctionExistenceProviderEvent $event): ?bool
|
|
{
|
|
$function_id = $event->getFunctionId();
|
|
return $function_id === 'magicfunction';
|
|
}
|
|
|
|
/**
|
|
* @return ?array<int, FunctionLikeParameter>
|
|
*/
|
|
public static function getFunctionParams(FunctionParamsProviderEvent $event): ?array
|
|
{
|
|
return [new FunctionLikeParameter('first', false, Type::getString(), Type::getString())];
|
|
}
|
|
|
|
public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): ?Union
|
|
{
|
|
return Type::getString();
|
|
}
|
|
}
|