mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 19:53:14 +01:00
f686cbac1c
[DowngradePhp72] Handle in assign on DowngradePregUnmatchedAsNullConstantRector (#1872)
31 lines
1.0 KiB
PHP
31 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\CodingStyle\Reflection;
|
|
|
|
use PHPStan\Reflection\MethodReflection;
|
|
use RectorPrefix20220226\Symplify\SmartFileSystem\Normalizer\PathNormalizer;
|
|
final class VendorLocationDetector
|
|
{
|
|
/**
|
|
* @readonly
|
|
* @var \Symplify\SmartFileSystem\Normalizer\PathNormalizer
|
|
*/
|
|
private $pathNormalizer;
|
|
public function __construct(\RectorPrefix20220226\Symplify\SmartFileSystem\Normalizer\PathNormalizer $pathNormalizer)
|
|
{
|
|
$this->pathNormalizer = $pathNormalizer;
|
|
}
|
|
public function detectMethodReflection(\PHPStan\Reflection\MethodReflection $methodReflection) : bool
|
|
{
|
|
$declaringClassReflection = $methodReflection->getDeclaringClass();
|
|
$fileName = $declaringClassReflection->getFileName();
|
|
// probably internal
|
|
if ($fileName === null) {
|
|
return \false;
|
|
}
|
|
$normalizedFileName = $this->pathNormalizer->normalizePath($fileName);
|
|
return \strpos($normalizedFileName, '/vendor/') !== \false;
|
|
}
|
|
}
|