Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php declare (strict_types=1); namespace Rector\CodingStyle\ClassNameImport\ClassNameImp..
Decoded Output download
<?php
declare (strict_types=1);
namespace Rector\CodingStyle\ClassNameImport\ClassNameImportSkipVoter;
use PhpParser\Node;
use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface;
use Rector\PostRector\Collector\UseNodesToAddCollector;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Rector\ValueObject\Application\File;
/**
* This prevents importing:
* - App\Some\Product
*
* if there is already:
* - use App\Another\Product
*/
final class UsesClassNameImportSkipVoter implements ClassNameImportSkipVoterInterface
{
/**
* @readonly
* @var \Rector\PostRector\Collector\UseNodesToAddCollector
*/
private $useNodesToAddCollector;
public function __construct(UseNodesToAddCollector $useNodesToAddCollector)
{
$this->useNodesToAddCollector = $useNodesToAddCollector;
}
public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedObjectType, Node $node) : bool
{
$useImportTypes = $this->useNodesToAddCollector->getUseImportTypesByNode($file);
foreach ($useImportTypes as $useImportType) {
if (!$useImportType->equals($fullyQualifiedObjectType) && $useImportType->areShortNamesEqual($fullyQualifiedObjectType)) {
return \true;
}
if ($useImportType->equals($fullyQualifiedObjectType)) {
return \false;
}
}
return \false;
}
}
?>
Did this file decode correctly?
Original Code
<?php
declare (strict_types=1);
namespace Rector\CodingStyle\ClassNameImport\ClassNameImportSkipVoter;
use PhpParser\Node;
use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface;
use Rector\PostRector\Collector\UseNodesToAddCollector;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Rector\ValueObject\Application\File;
/**
* This prevents importing:
* - App\Some\Product
*
* if there is already:
* - use App\Another\Product
*/
final class UsesClassNameImportSkipVoter implements ClassNameImportSkipVoterInterface
{
/**
* @readonly
* @var \Rector\PostRector\Collector\UseNodesToAddCollector
*/
private $useNodesToAddCollector;
public function __construct(UseNodesToAddCollector $useNodesToAddCollector)
{
$this->useNodesToAddCollector = $useNodesToAddCollector;
}
public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedObjectType, Node $node) : bool
{
$useImportTypes = $this->useNodesToAddCollector->getUseImportTypesByNode($file);
foreach ($useImportTypes as $useImportType) {
if (!$useImportType->equals($fullyQualifiedObjectType) && $useImportType->areShortNamesEqual($fullyQualifiedObjectType)) {
return \true;
}
if ($useImportType->equals($fullyQualifiedObjectType)) {
return \false;
}
}
return \false;
}
}
Function Calls
None |
Stats
MD5 | cf5e427f9412ae15f7c6cf359ad37a50 |
Eval Count | 0 |
Decode Time | 98 ms |