mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-03 01:40:49 +00:00
fc10fce13d
* re-enable rectify and ecs * [Rectify] [Php81] Enable Rectify on Readonly Property only * comment * [ci-review] Rector Rectify * [ci-review] Rector Rectify * [ci-review] Rector Rectify * [ci-review] Rector Rectify * [ci-review] Rector Rectify Co-authored-by: GitHub Action <action@github.com>
33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Rector\NodeTypeResolver\PHPStan\Scope;
|
|
|
|
use PHPStan\Analyser\MutatingScope;
|
|
use PHPStan\Analyser\ScopeContext;
|
|
use PHPStan\Reflection\ReflectionProvider;
|
|
use Rector\Core\Stubs\DummyTraitClass;
|
|
use Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
|
|
|
final class TraitScopeFaker
|
|
{
|
|
public function __construct(
|
|
private readonly PrivatesAccessor $privatesAccessor,
|
|
private readonly ReflectionProvider $reflectionProvider
|
|
) {
|
|
}
|
|
|
|
public function createDummyClassScopeContext(MutatingScope $mutatingScope): ScopeContext
|
|
{
|
|
// this has to be faked, because trait PHPStan does not traverse trait without a class
|
|
/** @var ScopeContext $scopeContext */
|
|
$scopeContext = $this->privatesAccessor->getPrivateProperty($mutatingScope, 'context');
|
|
$dummyClassReflection = $this->reflectionProvider->getClass(DummyTraitClass::class);
|
|
|
|
// faking a class reflection
|
|
return ScopeContext::create($scopeContext->getFile())
|
|
->enterClass($dummyClassReflection);
|
|
}
|
|
}
|