mirror of
https://github.com/danog/psalm.git
synced 2024-12-02 17:52:45 +01:00
09fb141e49
* document lowercase-string * fix missing strtolower
63 lines
1.7 KiB
PHP
63 lines
1.7 KiB
PHP
<?php
|
|
namespace Psalm\Test\Config\Plugin\Hook;
|
|
|
|
use PhpParser;
|
|
use Psalm\CodeLocation;
|
|
use Psalm\Context;
|
|
use Psalm\Plugin\Hook\FunctionExistenceProviderInterface;
|
|
use Psalm\Plugin\Hook\FunctionParamsProviderInterface;
|
|
use Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface;
|
|
use Psalm\StatementsSource;
|
|
use Psalm\Type;
|
|
|
|
class MagicFunctionProvider implements
|
|
FunctionExistenceProviderInterface,
|
|
FunctionParamsProviderInterface,
|
|
FunctionReturnTypeProviderInterface
|
|
{
|
|
/**
|
|
* @return array<lowercase-string>
|
|
*/
|
|
public static function getFunctionIds() : array
|
|
{
|
|
return ['magicfunction'];
|
|
}
|
|
|
|
public static function doesFunctionExist(
|
|
StatementsSource $statements_source,
|
|
string $function_id,
|
|
?CodeLocation $code_location = null
|
|
): ?bool {
|
|
return $function_id === 'magicfunction';
|
|
}
|
|
|
|
/**
|
|
* @param array<PhpParser\Node\Arg> $call_args
|
|
*
|
|
* @return ?array<int, \Psalm\Storage\FunctionLikeParameter>
|
|
*/
|
|
public static function getFunctionParams(
|
|
StatementsSource $statements_source,
|
|
string $function_id,
|
|
array $call_args,
|
|
?Context $context = null,
|
|
?CodeLocation $code_location = null
|
|
): ?array {
|
|
return [new \Psalm\Storage\FunctionLikeParameter('first', false, Type::getString())];
|
|
}
|
|
|
|
/**
|
|
* @param array<PhpParser\Node\Arg> $call_args
|
|
*
|
|
*/
|
|
public static function getFunctionReturnType(
|
|
StatementsSource $statements_source,
|
|
string $function_id,
|
|
array $call_args,
|
|
Context $context,
|
|
CodeLocation $code_location
|
|
): ?Type\Union {
|
|
return Type::getString();
|
|
}
|
|
}
|