rector/rules/CodingStyle/Reflection/VendorLocationDetector.php
Tomas Votruba 598bce3f9d Updated Rector to commit f686cbac1cfba1808e8ce9fa9cc0b9c39e3ee079
f686cbac1c [DowngradePhp72] Handle in assign on DowngradePregUnmatchedAsNullConstantRector (#1872)
2022-02-26 04:25:13 +00:00

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;
}
}