1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-03 10:07:52 +01:00
psalm/tests/Config/Plugin/Hook/MagicFunctionProvider.php
Bruce Weirdan 105c6f3a1c
Remove (and prevent) unused uses (#5704)
* Updates `slevomat/coding-standard`
* Removes unused uses
* Prevents unused uses
* Fixes a number of symbol case mismatches
2021-05-03 17:22:15 -04:00

44 lines
1.4 KiB
PHP

<?php
namespace Psalm\Test\Config\Plugin\Hook;
use Psalm\Plugin\EventHandler\FunctionExistenceProviderInterface;
use Psalm\Plugin\EventHandler\FunctionParamsProviderInterface;
use Psalm\Plugin\EventHandler\FunctionReturnTypeProviderInterface;
use Psalm\Plugin\EventHandler\Event\FunctionExistenceProviderEvent;
use Psalm\Plugin\EventHandler\Event\FunctionParamsProviderEvent;
use Psalm\Plugin\EventHandler\Event\FunctionReturnTypeProviderEvent;
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';
}
/**
* @return ?array<int, \Psalm\Storage\FunctionLikeParameter>
*/
public static function getFunctionParams(FunctionParamsProviderEvent $event): ?array
{
return [new \Psalm\Storage\FunctionLikeParameter('first', false, Type::getString())];
}
public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): ?Type\Union
{
return Type::getString();
}
}