Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.3"
php-version: "8.5"

- uses: "ramsey/composer-install@v3"

Expand Down
2 changes: 2 additions & 0 deletions build/composer-dependency-analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
'symfony/polyfill-php80',
'symfony/polyfill-php81',
'symfony/polyfill-php83',
'symfony/polyfill-php84',
'symfony/polyfill-php85',
];

$pinnedToSupportPhp72 = [
Expand Down
5 changes: 5 additions & 0 deletions compiler/build/scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
'../../stubs',
'../../vendor/jetbrains/phpstorm-stubs',
'../../vendor/phpstan/php-8-stubs/stubs',
// when adding new polyfills, don't forget to also append them in 'exclude-namespaces' below
'../../vendor/symfony/polyfill-php80',
'../../vendor/symfony/polyfill-php81',
'../../vendor/symfony/polyfill-php83',
'../../vendor/symfony/polyfill-php84',
'../../vendor/symfony/polyfill-php85',
'../../vendor/symfony/polyfill-mbstring',
'../../vendor/symfony/polyfill-intl-normalizer',
'../../vendor/symfony/polyfill-intl-grapheme',
Expand Down Expand Up @@ -246,6 +249,8 @@ function (string $filePath, string $prefix, string $content): string {
'Symfony\Polyfill\Php80',
'Symfony\Polyfill\Php81',
'Symfony\Polyfill\Php83',
'Symfony\Polyfill\Php84',
'Symfony\Polyfill\Php85',
'Symfony\Polyfill\Mbstring',
'Symfony\Polyfill\Intl\Normalizer',
'Symfony\Polyfill\Intl\Grapheme',
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"symfony/polyfill-php80": "^1.23",
"symfony/polyfill-php81": "^1.27",
"symfony/polyfill-php83": "^1.33",
"symfony/polyfill-php84": "^1.33",
"symfony/polyfill-php85": "^1.33",
"symfony/process": "^5.4.3",
"symfony/service-contracts": "^2.5.0",
"symfony/string": "^5.4.3"
Expand Down
162 changes: 161 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -3779,7 +3779,7 @@ private function enterAnonymousFunctionWithoutReflection(
if (isset($callableParameters[$i])) {
$parameterType = self::intersectButNotNever($parameterType, $callableParameters[$i]->getType());
} elseif (count($callableParameters) > 0) {
$lastParameter = $callableParameters[count($callableParameters) - 1];
$lastParameter = array_last($callableParameters);
if ($lastParameter->isVariadic()) {
$parameterType = self::intersectButNotNever($parameterType, $lastParameter->getType());
} else {
Expand Down Expand Up @@ -3972,7 +3972,7 @@ private function enterArrowFunctionWithoutReflection(Expr\ArrowFunction $arrowFu
if (isset($callableParameters[$i])) {
$parameterType = self::intersectButNotNever($parameterType, $callableParameters[$i]->getType());
} elseif (count($callableParameters) > 0) {
$lastParameter = $callableParameters[count($callableParameters) - 1];
$lastParameter = array_last($callableParameters);
if ($lastParameter->isVariadic()) {
$parameterType = self::intersectButNotNever($parameterType, $lastParameter->getType());
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ private function processStmtNode(

$bodyScope = $initScope;
$isIterableAtLeastOnce = TrinaryLogic::createYes();
$lastCondExpr = $stmt->cond[count($stmt->cond) - 1] ?? null;
$lastCondExpr = array_last($stmt->cond) ?? null;
foreach ($stmt->cond as $condExpr) {
$condResult = $this->processExprNode($stmt, $condExpr, $bodyScope, static function (): void {
}, ExpressionContext::createDeep());
Expand Down Expand Up @@ -5239,7 +5239,7 @@ private function processArgs(
}
$parameter = $parameters[$i];
} elseif (count($parameters) > 0 && $parametersAcceptor->isVariadic()) {
$lastParameter = $parameters[count($parameters) - 1];
$lastParameter = array_last($parameters);
$assignByReference = $lastParameter->passedByReference()->createsNewVariable();
$parameterType = $lastParameter->getType();

Expand Down Expand Up @@ -5432,7 +5432,7 @@ private function processArgs(
if (isset($parameters[$i])) {
$currentParameter = $parameters[$i];
} elseif (count($parameters) > 0 && $parametersAcceptor->isVariadic()) {
$currentParameter = $parameters[count($parameters) - 1];
$currentParameter = array_last($parameters);
}

if ($currentParameter !== null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/TypeSpecifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ private function specifyTypesFromAsserts(TypeSpecifierContext $context, Expr\Cal
} elseif (isset($parameters[$i])) {
$paramName = $parameters[$i]->getName();
} elseif (count($parameters) > 0 && $parametersAcceptor->isVariadic()) {
$lastParameter = $parameters[count($parameters) - 1];
$lastParameter = array_last($parameters);
$paramName = $lastParameter->getName();
} else {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/Fixable/PhpPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function pCommaSeparated(array $nodes): string
if (count($nodes) === 0) {
return $result;
}
$last = $nodes[count($nodes) - 1];
$last = array_last($nodes);

$trailingComma = $last->getAttribute(self::FUNC_ARGS_TRAILING_COMMA_ATTRIBUTE);
if ($trailingComma === false) {
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/LastConditionVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function enterNode(Node $node): ?Node
}

$if = $statements[$statementCount - 2];
$cond = count($if->elseifs) > 0 ? $if->elseifs[count($if->elseifs) - 1]->cond : $if->cond;
$cond = count($if->elseifs) > 0 ? array_last($if->elseifs)->cond : $if->cond;
$cond->setAttribute(self::ATTRIBUTE_NAME, true);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Parser/TryCatchTypeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function enterNode(Node $node): ?Node
{
if ($node instanceof Node\Stmt || $node instanceof Node\Expr\Match_) {
if (count($this->typeStack) > 0) {
$node->setAttribute(self::ATTRIBUTE_NAME, $this->typeStack[count($this->typeStack) - 1]);
$node->setAttribute(self::ATTRIBUTE_NAME, array_last($this->typeStack));
}
}

Expand Down
9 changes: 4 additions & 5 deletions src/Parser/VariadicMethodsVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use PHPStan\Reflection\ParametersAcceptor;
use function array_key_exists;
use function array_pop;
use function count;
use function in_array;
use function sprintf;

Expand Down Expand Up @@ -74,15 +73,15 @@ public function enterNode(Node $node): ?Node
$this->inMethodStack[] = $node->name->name;
}

$lastMethod = $this->inMethodStack[count($this->inMethodStack) - 1] ?? null;
$lastMethod = array_last($this->inMethodStack) ?? null;

if (
$lastMethod !== null
&& $node instanceof Node\Expr\FuncCall
&& $node->name instanceof Name
&& in_array((string) $node->name, ParametersAcceptor::VARIADIC_FUNCTIONS, true)
) {
$lastClass = $this->classStack[count($this->classStack) - 1] ?? null;
$lastClass = array_last($this->classStack) ?? null;
if ($lastClass !== null) {
if (
!array_key_exists($lastClass, $this->variadicMethods)
Expand All @@ -101,8 +100,8 @@ public function enterNode(Node $node): ?Node
public function leaveNode(Node $node): ?Node
{
if ($node instanceof ClassMethod) {
$lastClass = $this->classStack[count($this->classStack) - 1] ?? null;
$lastMethod = $this->inMethodStack[count($this->inMethodStack) - 1] ?? null;
$lastClass = array_last($this->classStack) ?? null;
$lastMethod = array_last($this->inMethodStack) ?? null;
if ($lastClass !== null && $lastMethod !== null) {
$this->variadicMethods[$lastClass][$lastMethod] ??= false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/AttributeReflectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private function fromNameAndArgumentExpressions(string $name, array $arguments,
continue;
}
if (count($parameters) > 0) {
$lastParameter = $parameters[count($parameters) - 1];
$lastParameter = array_last($parameters);
if ($lastParameter->isVariadic()) {
$parameterName = $lastParameter->getName();
if (array_key_exists($parameterName, $namedArgTypes)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/GenericParametersAcceptorResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function resolve(array $argTypes, ParametersAcceptor $parametersAc
continue;
}
if (count($parameters) > 0) {
$lastParameter = $parameters[count($parameters) - 1];
$lastParameter = array_last($parameters);
if ($lastParameter->isVariadic()) {
$parameterName = $lastParameter->getName();
if (array_key_exists($parameterName, $namedArgTypes)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/ParametersAcceptorSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ public static function selectFromArgs(
if (isset($parameters[$i])) {
$parameter = $parameters[$i];
} elseif (count($parameters) > 0 && $singleParametersAcceptor->isVariadic()) {
$parameter = $parameters[count($parameters) - 1];
$parameter = array_last($parameters);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Rules/FunctionCallParametersCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,8 @@ private function processArguments(
break;
}

$parameter = $parameters[count($parameters) - 1];
$originalParameter = $originalParameters[count($originalParameters) - 1];
$parameter = array_last($parameters);
$originalParameter = array_last($originalParameters);
if (!$parameter->isVariadic()) {
$newArguments[$i] = [$argumentValue, $argumentValueType, $unpack, $argumentName, $argumentLine, null, null];
break; // func_get_args
Expand Down
Loading
Loading