diff --git a/assets/config_levels/3.xml b/assets/config_levels/3.xml index c94bb67e7..444b1ab60 100644 --- a/assets/config_levels/3.xml +++ b/assets/config_levels/3.xml @@ -21,6 +21,7 @@ + diff --git a/assets/config_levels/4.xml b/assets/config_levels/4.xml index 9fc8360b3..ee31aa22a 100644 --- a/assets/config_levels/4.xml +++ b/assets/config_levels/4.xml @@ -21,6 +21,7 @@ + diff --git a/assets/config_levels/5.xml b/assets/config_levels/5.xml index f11763262..0425b03ce 100644 --- a/assets/config_levels/5.xml +++ b/assets/config_levels/5.xml @@ -21,6 +21,7 @@ + diff --git a/assets/config_levels/6.xml b/assets/config_levels/6.xml index 6d1555e5c..c4e6f294e 100644 --- a/assets/config_levels/6.xml +++ b/assets/config_levels/6.xml @@ -21,6 +21,7 @@ + diff --git a/assets/config_levels/7.xml b/assets/config_levels/7.xml index 497c8fa2e..20d5b52d0 100644 --- a/assets/config_levels/7.xml +++ b/assets/config_levels/7.xml @@ -21,6 +21,7 @@ + diff --git a/assets/config_levels/8.xml b/assets/config_levels/8.xml index 07db13295..99694973b 100644 --- a/assets/config_levels/8.xml +++ b/assets/config_levels/8.xml @@ -21,6 +21,7 @@ + diff --git a/config.xsd b/config.xsd index 105f4c5fd..0c108aa4b 100644 --- a/config.xsd +++ b/config.xsd @@ -147,6 +147,7 @@ + diff --git a/docs/running_psalm/issues.md b/docs/running_psalm/issues.md index a3258e240..ad034b4ae 100644 --- a/docs/running_psalm/issues.md +++ b/docs/running_psalm/issues.md @@ -107,6 +107,16 @@ class A { echo A::FOO; ``` +### DeprecatedFunction + +Emitted when calling a deprecated function: + +```php +/** @deprecated */ +function foo() : void {} +foo(); +``` + ### DeprecatedInterface Emitted when referring to a deprecated interface diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php index a4622afcf..dfeb08b82 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php @@ -11,6 +11,7 @@ use Psalm\Internal\Codebase\CallMap; use Psalm\CodeLocation; use Psalm\Context; use Psalm\Internal\FileManipulation\FileManipulationBuffer; +use Psalm\Issue\DeprecatedFunction; use Psalm\Issue\ForbiddenCode; use Psalm\Issue\MixedFunctionCall; use Psalm\Issue\InvalidFunctionCall; @@ -598,6 +599,19 @@ class FunctionCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expressio $function_storage->if_false_assertions ); } + + if ($function_storage->deprecated && $function_id) { + if (IssueBuffer::accepts( + new DeprecatedFunction( + 'The function ' . $function_id . ' has been marked as deprecated', + $code_location, + $function_id + ), + $statements_analyzer->getSuppressedIssues() + )) { + // continue + } + } } if ($function instanceof PhpParser\Node\Name) { diff --git a/src/Psalm/Issue/DeprecatedFunction.php b/src/Psalm/Issue/DeprecatedFunction.php new file mode 100644 index 000000000..546f1cc5a --- /dev/null +++ b/src/Psalm/Issue/DeprecatedFunction.php @@ -0,0 +1,6 @@ +