mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 14:27:14 +01:00
c726969380
fc10fce13d
[Rectify] [Php81] Enable Rectify on Readonly Property only (#1384)
51 lines
2.2 KiB
PHP
51 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\VendorLocker;
|
|
|
|
use PhpParser\Node;
|
|
use PhpParser\Node\Stmt\ClassMethod;
|
|
use PhpParser\Node\Stmt\Property;
|
|
use Rector\VendorLocker\NodeVendorLocker\ClassMethodParamVendorLockResolver;
|
|
use Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnVendorLockResolver;
|
|
use Rector\VendorLocker\NodeVendorLocker\PropertyTypeVendorLockResolver;
|
|
final class VendorLockResolver
|
|
{
|
|
/**
|
|
* @readonly
|
|
* @var \Rector\VendorLocker\NodeVendorLocker\ClassMethodParamVendorLockResolver
|
|
*/
|
|
private $classMethodParamVendorLockResolver;
|
|
/**
|
|
* @readonly
|
|
* @var \Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnVendorLockResolver
|
|
*/
|
|
private $classMethodReturnVendorLockResolver;
|
|
/**
|
|
* @readonly
|
|
* @var \Rector\VendorLocker\NodeVendorLocker\PropertyTypeVendorLockResolver
|
|
*/
|
|
private $propertyTypeVendorLockResolver;
|
|
public function __construct(\Rector\VendorLocker\NodeVendorLocker\ClassMethodParamVendorLockResolver $classMethodParamVendorLockResolver, \Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnVendorLockResolver $classMethodReturnVendorLockResolver, \Rector\VendorLocker\NodeVendorLocker\PropertyTypeVendorLockResolver $propertyTypeVendorLockResolver)
|
|
{
|
|
$this->classMethodParamVendorLockResolver = $classMethodParamVendorLockResolver;
|
|
$this->classMethodReturnVendorLockResolver = $classMethodReturnVendorLockResolver;
|
|
$this->propertyTypeVendorLockResolver = $propertyTypeVendorLockResolver;
|
|
}
|
|
public function isClassMethodParamLockedIn(\PhpParser\Node $node) : bool
|
|
{
|
|
if (!$node instanceof \PhpParser\Node\Stmt\ClassMethod) {
|
|
return \false;
|
|
}
|
|
return $this->classMethodParamVendorLockResolver->isVendorLocked($node);
|
|
}
|
|
public function isReturnChangeVendorLockedIn(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool
|
|
{
|
|
return $this->classMethodReturnVendorLockResolver->isVendorLocked($classMethod);
|
|
}
|
|
public function isPropertyTypeChangeVendorLockedIn(\PhpParser\Node\Stmt\Property $property) : bool
|
|
{
|
|
return $this->propertyTypeVendorLockResolver->isVendorLocked($property);
|
|
}
|
|
}
|