mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 22:08:00 +01:00
fff9179119
f7e9986835
[PHP 8.0] Add downgrade for str_starts_with() (#126)
24 lines
730 B
PHP
24 lines
730 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Naming;
|
|
|
|
use Rector\Renaming\ValueObject\RenamedNamespace;
|
|
final class NamespaceMatcher
|
|
{
|
|
/**
|
|
* @param string[] $oldToNewNamespace
|
|
*/
|
|
public function matchRenamedNamespace(string $name, array $oldToNewNamespace) : ?\Rector\Renaming\ValueObject\RenamedNamespace
|
|
{
|
|
\krsort($oldToNewNamespace);
|
|
/** @var string $oldNamespace */
|
|
foreach ($oldToNewNamespace as $oldNamespace => $newNamespace) {
|
|
if (\strncmp($name, $oldNamespace, \strlen($oldNamespace)) === 0) {
|
|
return new \Rector\Renaming\ValueObject\RenamedNamespace($name, $oldNamespace, $newNamespace);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|