-
Notifications
You must be signed in to change notification settings - Fork 548
DeprecationExtensions: allow custom deprecation-marking logic #3932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
badbbd6
DeprecationProviders: allow custom deprecation-marking logic
janedbal 17aeaa0
No null coalesce
janedbal b4ac3a8
Try fix PHP 7.4 CI issues
janedbal 24acb10
,
janedbal 82fc4a8
DeprecationProvidersTest: skip on PHP 7.4
janedbal 4f825cb
DeprecationProvidersTest: skip on PHP 7.4
janedbal be1de74
Renames, mainly Provider -> Extension
janedbal 2526e5c
Support enum cases
janedbal c5ae947
Missed provider var renames
janedbal e1301ac
Adjust enum tests for PHP8.1+
janedbal 6935ac4
Fix naming inconsistency typo
janedbal 529f030
DeprecationProvider: lazy extensions
janedbal ea58997
Tags to be in const
janedbal 14a6864
Separate enum tests
janedbal 6cba377
ignore enum issue on old php
janedbal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
27 changes: 27 additions & 0 deletions
27
src/Reflection/Deprecation/ClassConstantDeprecationProvider.php
This file contains hidden or 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,27 @@ | ||
| <?php declare(strict_types = 1); | ||
|
|
||
| namespace PHPStan\Reflection\Deprecation; | ||
|
|
||
| use PHPStan\BetterReflection\Reflection\Adapter\ReflectionClassConstant; | ||
|
|
||
| /** | ||
| * This interface allows you to provide custom deprecation information | ||
| * | ||
| * To register it in the configuration file use the following tag: | ||
| * | ||
| * ``` | ||
| * services: | ||
| * - | ||
| * class: App\PHPStan\MyProvider | ||
| * tags: | ||
| * - phpstan.classConstantDeprecationProvider | ||
| * ``` | ||
| * | ||
| * @api | ||
| */ | ||
| interface ClassConstantDeprecationProvider | ||
janedbal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
|
|
||
| public function getClassConstantDeprecation(ReflectionClassConstant $reflection): ?Deprecation; | ||
|
|
||
| } | ||
This file contains hidden or 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,28 @@ | ||
| <?php declare(strict_types = 1); | ||
|
|
||
| namespace PHPStan\Reflection\Deprecation; | ||
|
|
||
| use PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass; | ||
| use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum; | ||
|
|
||
| /** | ||
| * This interface allows you to provide custom deprecation information | ||
| * | ||
| * To register it in the configuration file use the following tag: | ||
| * | ||
| * ``` | ||
| * services: | ||
| * - | ||
| * class: App\PHPStan\MyProvider | ||
| * tags: | ||
| * - phpstan.classDeprecationProvider | ||
| * ``` | ||
| * | ||
| * @api | ||
| */ | ||
| interface ClassDeprecationProvider | ||
| { | ||
|
|
||
| public function getClassDeprecation(ReflectionClass|ReflectionEnum $reflection): ?Deprecation; | ||
|
|
||
| } |
27 changes: 27 additions & 0 deletions
27
src/Reflection/Deprecation/ConstantDeprecationProvider.php
This file contains hidden or 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,27 @@ | ||
| <?php declare(strict_types = 1); | ||
|
|
||
| namespace PHPStan\Reflection\Deprecation; | ||
|
|
||
| use PHPStan\BetterReflection\Reflection\ReflectionConstant; | ||
|
|
||
| /** | ||
| * This interface allows you to provide custom deprecation information | ||
| * | ||
| * To register it in the configuration file use the following tag: | ||
| * | ||
| * ``` | ||
| * services: | ||
| * - | ||
| * class: App\PHPStan\MyProvider | ||
| * tags: | ||
| * - phpstan.constantDeprecationProvider | ||
| * ``` | ||
| * | ||
| * @api | ||
| */ | ||
| interface ConstantDeprecationProvider | ||
| { | ||
|
|
||
| public function getConstantDeprecation(ReflectionConstant $reflection): ?Deprecation; | ||
|
|
||
| } |
This file contains hidden or 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,35 @@ | ||
| <?php declare(strict_types = 1); | ||
|
|
||
| namespace PHPStan\Reflection\Deprecation; | ||
|
|
||
| /** | ||
| * @api | ||
| */ | ||
| final class Deprecation | ||
| { | ||
|
|
||
| private ?string $description = null; | ||
|
|
||
| private function __construct() | ||
| { | ||
| } | ||
|
|
||
| public static function create(): self | ||
| { | ||
| return new self(); | ||
| } | ||
|
|
||
| public function getDescription(): ?string | ||
| { | ||
| return $this->description; | ||
| } | ||
|
|
||
| public function withDescription(?string $description): self | ||
janedbal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| $clone = clone $this; | ||
| $clone->description = $description; | ||
|
|
||
| return $clone; | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.