-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#713Labels
Description
Bug report
While working on #5368, I realized that deprecated core functions were not being flagged, like create_function which was deprecated in 7.2 and removed 8.0.
However, NativeFunctionReflection hardcodes isDeprecated to always be "no".
public function getDeprecatedDescription(): ?string
{
return null;
}
public function isDeprecated(): TrinaryLogic
{
return TrinaryLogic::createNo();
}
These values can be parsed via the PhpStorm stubs, which are documented using PHP attributes, now
#[Deprecated(reason: "Use anonymous functions instead", since: "7.2")]
function create_function (string $args, string $code): false|string
{}
Stub examples
/**
* Create an anonymous (lambda-style) function
* @link https://php.net/manual/en/function.create-function.php
* @param string $args <p>
* The function arguments.
* </p>
* @param string $code <p>
* The function code.
* </p>
* @return string|false a unique function name as a string, or false on error.
* @removed 8.0
*/
#[Deprecated(reason: "Use anonymous functions instead", since: "7.2")]
function create_function(string $args, string $code): false|string {}
https://github.com/JetBrains/phpstorm-stubs/blob/v2019.3/Core/Core.php
/**
* Create an anonymous (lambda-style) function
* @link https://php.net/manual/en/function.create-function.php
* @param string $args <p>
* The function arguments.
* </p>
* @param string $code <p>
* The function code.
* </p>
* @return string a unique function name as a string, or false on error.
* @since 4.0.1
* @since 5.0
* @deprecated 7.2 Use anonymous functions instead.
*/
function create_function ($args, $code) {}
Code snippet that reproduces the problem
https://phpstan.org/r/7b7db20f-8b1d-411d-9d9e-41dbec9bae4d
Expected output
I would expected phpstan/phpstan-deprecation-rules to flag and identify this.
andypost
