-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the ability to register deprecated scope resolvers for controlling the deprecated scope.
- Loading branch information
1 parent
94d68d3
commit 6d416c7
Showing
37 changed files
with
337 additions
and
59 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
33 changes: 33 additions & 0 deletions
33
src/DependencyInjection/LazyDeprecatedScopeResolverProvider.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,33 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\DependencyInjection; | ||
|
||
use PHPStan\Rules\Deprecations\DeprecatedScopeHelper; | ||
|
||
final class LazyDeprecatedScopeResolverProvider | ||
{ | ||
|
||
public const EXTENSION_TAG = 'phpstan.deprecations.deprecatedScopeResolver'; | ||
|
||
/** @var Container */ | ||
private $container; | ||
|
||
/** @var DeprecatedScopeHelper */ | ||
private $scopeHelper; | ||
|
||
public function __construct(Container $container) | ||
{ | ||
$this->container = $container; | ||
} | ||
|
||
public function get(): DeprecatedScopeHelper | ||
{ | ||
if ($this->scopeHelper === null) { | ||
$this->scopeHelper = new DeprecatedScopeHelper( | ||
$this->container->getServicesByTag(self::EXTENSION_TAG) | ||
); | ||
} | ||
return $this->scopeHelper; | ||
} | ||
|
||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Rules\Deprecations; | ||
|
||
use PHPStan\Analyser\Scope; | ||
|
||
final class DefaultDeprecatedScopeResolver implements DeprecatedScopeResolver | ||
{ | ||
|
||
public function isScopeDeprecated(Scope $scope): bool | ||
{ | ||
$class = $scope->getClassReflection(); | ||
if ($class !== null && $class->isDeprecated()) { | ||
return true; | ||
} | ||
|
||
$trait = $scope->getTraitReflection(); | ||
if ($trait !== null && $trait->isDeprecated()) { | ||
return true; | ||
} | ||
|
||
$function = $scope->getFunction(); | ||
if ($function !== null && $function->isDeprecated()->yes()) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Rules\Deprecations; | ||
|
||
use PHPStan\Analyser\Scope; | ||
|
||
interface DeprecatedScopeResolver | ||
{ | ||
|
||
public function isScopeDeprecated(Scope $scope): bool; | ||
|
||
} |
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
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
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
Oops, something went wrong.