1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 16:59:45 +01:00
psalm/tests/Config/Plugin/Hook/MagicFunctionProvider.php

45 lines
1.4 KiB
PHP
Raw Normal View History

<?php
2019-05-10 00:58:30 +02:00
namespace Psalm\Test\Config\Plugin\Hook;
use Psalm\Plugin\EventHandler\Event\FunctionExistenceProviderEvent;
use Psalm\Plugin\EventHandler\Event\FunctionParamsProviderEvent;
use Psalm\Plugin\EventHandler\Event\FunctionReturnTypeProviderEvent;
2021-06-08 04:55:21 +02:00
use Psalm\Plugin\EventHandler\FunctionExistenceProviderInterface;
use Psalm\Plugin\EventHandler\FunctionParamsProviderInterface;
use Psalm\Plugin\EventHandler\FunctionReturnTypeProviderInterface;
2021-12-03 20:11:20 +01:00
use Psalm\Storage\FunctionLikeParameter;
2019-03-23 19:27:54 +01:00
use Psalm\Type;
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';
}
/**
2021-12-04 03:37:19 +01:00
* @return ?array<int, FunctionLikeParameter>
*/
public static function getFunctionParams(FunctionParamsProviderEvent $event): ?array
{
2021-12-03 20:11:20 +01:00
return [new FunctionLikeParameter('first', false, Type::getString())];
}
public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): ?Type\Union
{
return Type::getString();
}
}