mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-15 23:52:23 +00:00
38 lines
957 B
PHP
38 lines
957 B
PHP
|
<?php
|
||
|
|
||
|
declare (strict_types=1);
|
||
|
namespace Rector\Core\NodeAnalyzer;
|
||
|
|
||
|
use PhpParser\Node\Arg;
|
||
|
use PhpParser\Node\VariadicPlaceholder;
|
||
|
final class ArgsAnalyzer
|
||
|
{
|
||
|
/**
|
||
|
* @param Arg[]|VariadicPlaceholder[] $args
|
||
|
*/
|
||
|
public function isArgInstanceInArgsPosition(array $args, int $position) : bool
|
||
|
{
|
||
|
if (!isset($args[$position])) {
|
||
|
return \false;
|
||
|
}
|
||
|
return $args[$position] instanceof \PhpParser\Node\Arg;
|
||
|
}
|
||
|
/**
|
||
|
* @param Arg[]|VariadicPlaceholder[] $args
|
||
|
* @param int[] $positions
|
||
|
*/
|
||
|
public function isArgsInstanceInArgsPositions(array $args, array $positions) : bool
|
||
|
{
|
||
|
foreach ($positions as $position) {
|
||
|
if (!isset($args[$position])) {
|
||
|
return \false;
|
||
|
}
|
||
|
if ($args[$position] instanceof \PhpParser\Node\Arg) {
|
||
|
continue;
|
||
|
}
|
||
|
return \false;
|
||
|
}
|
||
|
return \true;
|
||
|
}
|
||
|
}
|