-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement getDeprecatedDescription()
- Loading branch information
Showing
4 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
tests/PHPStan/Reflection/Constant/RuntimeConstantReflectionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Reflection\Constant; | ||
|
||
use PhpParser\Node\Name; | ||
use PHPStan\Testing\PHPStanTestCase; | ||
use PHPStan\TrinaryLogic; | ||
|
||
class RuntimeConstantReflectionTest extends PHPStanTestCase | ||
{ | ||
|
||
public function dataDeprecatedConstants(): array | ||
{ | ||
return [ | ||
[ | ||
new Name('\DeprecatedConst\FINE'), | ||
TrinaryLogic::createNo(), | ||
null, | ||
], | ||
[ | ||
new Name('\DeprecatedConst\MY_CONST'), | ||
TrinaryLogic::createYes(), | ||
null, | ||
], | ||
[ | ||
new Name('\DeprecatedConst\MY_CONST2'), | ||
TrinaryLogic::createYes(), | ||
"don't use it!", | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider dataDeprecatedConstants | ||
*/ | ||
public function testDeprecatedConstants(Name $constName, TrinaryLogic $isDeprecated, ?string $deprecationMessage): void | ||
{ | ||
require_once __DIR__ . '/data/deprecated-constant.php'; | ||
|
||
$reflectionProvider = $this->createReflectionProvider(); | ||
|
||
$this->assertTrue($reflectionProvider->hasConstant($constName, null)); | ||
$this->assertSame($isDeprecated, $reflectionProvider->getConstant($constName, null)->isDeprecated()); | ||
$this->assertSame($deprecationMessage, $reflectionProvider->getConstant($constName, null)->getDeprecatedDescription()); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
tests/PHPStan/Reflection/Constant/data/deprecated-constant.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace DeprecatedConst; | ||
|
||
const FINE = '1'; | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
const MY_CONST = '1'; | ||
|
||
/** | ||
* @deprecated don't use it! | ||
*/ | ||
const MY_CONST2 = '1'; |