mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #1793 - warn on deprecated function
This commit is contained in:
parent
fbd8faadaf
commit
5a64e97f0f
@ -21,6 +21,7 @@
|
|||||||
<DeprecatedProperty errorLevel="info" />
|
<DeprecatedProperty errorLevel="info" />
|
||||||
<DeprecatedClass errorLevel="info" />
|
<DeprecatedClass errorLevel="info" />
|
||||||
<DeprecatedConstant errorLevel="info" />
|
<DeprecatedConstant errorLevel="info" />
|
||||||
|
<DeprecatedFunction errorLevel="info" />
|
||||||
<DeprecatedInterface errorLevel="info" />
|
<DeprecatedInterface errorLevel="info" />
|
||||||
<DeprecatedTrait errorLevel="info" />
|
<DeprecatedTrait errorLevel="info" />
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
<DeprecatedProperty errorLevel="info" />
|
<DeprecatedProperty errorLevel="info" />
|
||||||
<DeprecatedClass errorLevel="info" />
|
<DeprecatedClass errorLevel="info" />
|
||||||
<DeprecatedConstant errorLevel="info" />
|
<DeprecatedConstant errorLevel="info" />
|
||||||
|
<DeprecatedFunction errorLevel="info" />
|
||||||
<DeprecatedInterface errorLevel="info" />
|
<DeprecatedInterface errorLevel="info" />
|
||||||
<DeprecatedTrait errorLevel="info" />
|
<DeprecatedTrait errorLevel="info" />
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
<DeprecatedProperty errorLevel="info" />
|
<DeprecatedProperty errorLevel="info" />
|
||||||
<DeprecatedClass errorLevel="info" />
|
<DeprecatedClass errorLevel="info" />
|
||||||
<DeprecatedConstant errorLevel="info" />
|
<DeprecatedConstant errorLevel="info" />
|
||||||
|
<DeprecatedFunction errorLevel="info" />
|
||||||
<DeprecatedInterface errorLevel="info" />
|
<DeprecatedInterface errorLevel="info" />
|
||||||
<DeprecatedTrait errorLevel="info" />
|
<DeprecatedTrait errorLevel="info" />
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
<DeprecatedProperty errorLevel="info" />
|
<DeprecatedProperty errorLevel="info" />
|
||||||
<DeprecatedClass errorLevel="info" />
|
<DeprecatedClass errorLevel="info" />
|
||||||
<DeprecatedConstant errorLevel="info" />
|
<DeprecatedConstant errorLevel="info" />
|
||||||
|
<DeprecatedFunction errorLevel="info" />
|
||||||
<DeprecatedInterface errorLevel="info" />
|
<DeprecatedInterface errorLevel="info" />
|
||||||
<DeprecatedTrait errorLevel="info" />
|
<DeprecatedTrait errorLevel="info" />
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
<DeprecatedProperty errorLevel="info" />
|
<DeprecatedProperty errorLevel="info" />
|
||||||
<DeprecatedClass errorLevel="info" />
|
<DeprecatedClass errorLevel="info" />
|
||||||
<DeprecatedConstant errorLevel="info" />
|
<DeprecatedConstant errorLevel="info" />
|
||||||
|
<DeprecatedFunction errorLevel="info" />
|
||||||
<DeprecatedInterface errorLevel="info" />
|
<DeprecatedInterface errorLevel="info" />
|
||||||
<DeprecatedTrait errorLevel="info" />
|
<DeprecatedTrait errorLevel="info" />
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
<DeprecatedProperty errorLevel="info" />
|
<DeprecatedProperty errorLevel="info" />
|
||||||
<DeprecatedClass errorLevel="info" />
|
<DeprecatedClass errorLevel="info" />
|
||||||
<DeprecatedConstant errorLevel="info" />
|
<DeprecatedConstant errorLevel="info" />
|
||||||
|
<DeprecatedFunction errorLevel="info" />
|
||||||
<DeprecatedInterface errorLevel="info" />
|
<DeprecatedInterface errorLevel="info" />
|
||||||
<DeprecatedTrait errorLevel="info" />
|
<DeprecatedTrait errorLevel="info" />
|
||||||
|
|
||||||
|
@ -147,6 +147,7 @@
|
|||||||
<xs:element name="ConflictingReferenceConstraint" type="IssueHandlerType" minOccurs="0" />
|
<xs:element name="ConflictingReferenceConstraint" type="IssueHandlerType" minOccurs="0" />
|
||||||
<xs:element name="DeprecatedClass" type="ClassIssueHandlerType" minOccurs="0" />
|
<xs:element name="DeprecatedClass" type="ClassIssueHandlerType" minOccurs="0" />
|
||||||
<xs:element name="DeprecatedConstant" type="IssueHandlerType" minOccurs="0" />
|
<xs:element name="DeprecatedConstant" type="IssueHandlerType" minOccurs="0" />
|
||||||
|
<xs:element name="DeprecatedFunction" type="FunctionIssueHandlerType" minOccurs="0" />
|
||||||
<xs:element name="DeprecatedInterface" type="ClassIssueHandlerType" minOccurs="0" />
|
<xs:element name="DeprecatedInterface" type="ClassIssueHandlerType" minOccurs="0" />
|
||||||
<xs:element name="DeprecatedMethod" type="MethodIssueHandlerType" minOccurs="0" />
|
<xs:element name="DeprecatedMethod" type="MethodIssueHandlerType" minOccurs="0" />
|
||||||
<xs:element name="DeprecatedProperty" type="PropertyIssueHandlerType" minOccurs="0" />
|
<xs:element name="DeprecatedProperty" type="PropertyIssueHandlerType" minOccurs="0" />
|
||||||
|
@ -107,6 +107,16 @@ class A {
|
|||||||
echo A::FOO;
|
echo A::FOO;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### DeprecatedFunction
|
||||||
|
|
||||||
|
Emitted when calling a deprecated function:
|
||||||
|
|
||||||
|
```php
|
||||||
|
/** @deprecated */
|
||||||
|
function foo() : void {}
|
||||||
|
foo();
|
||||||
|
```
|
||||||
|
|
||||||
### DeprecatedInterface
|
### DeprecatedInterface
|
||||||
|
|
||||||
Emitted when referring to a deprecated interface
|
Emitted when referring to a deprecated interface
|
||||||
|
@ -11,6 +11,7 @@ use Psalm\Internal\Codebase\CallMap;
|
|||||||
use Psalm\CodeLocation;
|
use Psalm\CodeLocation;
|
||||||
use Psalm\Context;
|
use Psalm\Context;
|
||||||
use Psalm\Internal\FileManipulation\FileManipulationBuffer;
|
use Psalm\Internal\FileManipulation\FileManipulationBuffer;
|
||||||
|
use Psalm\Issue\DeprecatedFunction;
|
||||||
use Psalm\Issue\ForbiddenCode;
|
use Psalm\Issue\ForbiddenCode;
|
||||||
use Psalm\Issue\MixedFunctionCall;
|
use Psalm\Issue\MixedFunctionCall;
|
||||||
use Psalm\Issue\InvalidFunctionCall;
|
use Psalm\Issue\InvalidFunctionCall;
|
||||||
@ -598,6 +599,19 @@ class FunctionCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expressio
|
|||||||
$function_storage->if_false_assertions
|
$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) {
|
if ($function instanceof PhpParser\Node\Name) {
|
||||||
|
6
src/Psalm/Issue/DeprecatedFunction.php
Normal file
6
src/Psalm/Issue/DeprecatedFunction.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
namespace Psalm\Issue;
|
||||||
|
|
||||||
|
class DeprecatedFunction extends FunctionIssue
|
||||||
|
{
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user