mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 06:18:07 +01:00
0b3c5d9bcc
f22ddc8f18
Add not null compare to FlipTypeControlToUseExclusiveTypeRector (#3513)
28 lines
884 B
PHP
28 lines
884 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Php80\NodeResolver;
|
|
|
|
use PHPStan\Reflection\ParameterReflection;
|
|
use PHPStan\Reflection\ParametersAcceptor;
|
|
use PHPStan\Type\Type;
|
|
final class RequireOptionalParamResolver
|
|
{
|
|
/**
|
|
* @return ParameterReflection[]
|
|
*/
|
|
public function resolveFromParametersAcceptor(ParametersAcceptor $parametersAcceptor) : array
|
|
{
|
|
$optionalParams = [];
|
|
$requireParams = [];
|
|
foreach ($parametersAcceptor->getParameters() as $position => $parameterReflection) {
|
|
if (!$parameterReflection->getDefaultValue() instanceof Type && !$parameterReflection->isVariadic()) {
|
|
$requireParams[$position] = $parameterReflection;
|
|
} else {
|
|
$optionalParams[$position] = $parameterReflection;
|
|
}
|
|
}
|
|
return $requireParams + $optionalParams;
|
|
}
|
|
}
|