Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ab854bb

Browse files
Fix Deprecated attribute
1 parent 0d410e6 commit ab854bb

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

‎src/Reflection/InitializerExprTypeResolver.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,9 @@ function (Type $type, callable $traverse): Type {
20082008

20092009
$constantClassReflection = $this->getReflectionProvider()->getClass($referencedClass);
20102010
if (!$constantClassReflection->hasConstant($constantName)) {
2011+
if ($constantClassReflection->getName() === 'Attribute' && $constantName === 'TARGET_CONSTANT') {
2012+
return new ConstantIntegerType(1 << 16);
2013+
}
20112014
continue;
20122015
}
20132016

‎tests/PHPStan/Rules/Methods/MethodAttributesRuleTest.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,9 @@ public function testBug5898(): void
6262
$this->analyse([__DIR__ . '/data/bug-5898.php'], []);
6363
}
6464

65+
public function testDeprecatedAttribute(): void
66+
{
67+
$this->analyse([__DIR__ . '/data/deprecated-attribute.php'], []);
68+
}
69+
6570
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace MethodDeprecatedAttribute;
4+
5+
use Deprecated;
6+
7+
class HelloWorld
8+
{
9+
#[Deprecated]
10+
public function sayHello(): void
11+
{
12+
}
13+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /