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 tools/.phpstan/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"phpstan/phpstan": "^2.2.5",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan-phpunit": "^2.0.18",
"phpstan/phpstan-strict-rules": "^2.0.11",
"phpstan/phpstan-strict-rules": "^2.0.12",
"tomasvotruba/type-coverage": "^2.2.2",
"ergebnis/phpstan-rules": "^2.13.1"
},
Expand Down
19 changes: 10 additions & 9 deletions tools/.phpstan/composer.lock

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

19 changes: 10 additions & 9 deletions tools/.phpstan/vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,30 +311,31 @@
},
{
"name": "phpstan/phpstan-strict-rules",
"version": "2.0.11",
"version_normalized": "2.0.11.0",
"version": "2.0.12",
"version_normalized": "2.0.12.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-strict-rules.git",
"reference": "9b000a578b85b32945b358b172c7b20e91189024"
"reference": "2bc5ae19ae965663b62ac907ee6342c3903ec93b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/9b000a578b85b32945b358b172c7b20e91189024",
"reference": "9b000a578b85b32945b358b172c7b20e91189024",
"url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/2bc5ae19ae965663b62ac907ee6342c3903ec93b",
"reference": "2bc5ae19ae965663b62ac907ee6342c3903ec93b",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.1.39"
"phpstan/phpstan": "^2.1.52"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^9.6"
"phpunit/phpunit": "^9.6",
"shipmonk/name-collision-detector": "^2.1"
},
"time": "2026-05-02T06:54:10+00:00",
"time": "2026-07-19T07:24:06+00:00",
"type": "phpstan-extension",
"extra": {
"phpstan": {
Expand All @@ -359,7 +360,7 @@
],
"support": {
"issues": "https://github.com/phpstan/phpstan-strict-rules/issues",
"source": "https://github.com/phpstan/phpstan-strict-rules/tree/2.0.11"
"source": "https://github.com/phpstan/phpstan-strict-rules/tree/2.0.12"
},
"install-path": "../phpstan/phpstan-strict-rules"
},
Expand Down
10 changes: 5 additions & 5 deletions tools/.phpstan/vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '0ac6e384ac13a51b8b4b0ea6222ad8a83fe4c0fb',
'reference' => '62e92853bd9c3d5d562ce1bf07ab8c47b7d9e98e',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '0ac6e384ac13a51b8b4b0ea6222ad8a83fe4c0fb',
'reference' => '62e92853bd9c3d5d562ce1bf07ab8c47b7d9e98e',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -65,9 +65,9 @@
'dev_requirement' => true,
),
'phpstan/phpstan-strict-rules' => array(
'pretty_version' => '2.0.11',
'version' => '2.0.11.0',
'reference' => '9b000a578b85b32945b358b172c7b20e91189024',
'pretty_version' => '2.0.12',
'version' => '2.0.12.0',
'reference' => '2bc5ae19ae965663b62ac907ee6342c3903ec93b',
'type' => 'phpstan-extension',
'install_path' => __DIR__ . '/../phpstan/phpstan-strict-rules',
'aliases' => array(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
"keywords": ["static analysis"],
"require": {
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.1.39"
"phpstan/phpstan": "^2.1.52"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^9.6"
"phpunit/phpunit": "^9.6",
"shipmonk/name-collision-detector": "^2.1"
},
"config": {
"platform": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace PHPStan\Rules\Operators;

use PhpParser\Node\Expr;
use PhpParser\Node\Scalar\Int_;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\RuleLevelHelper;
use PHPStan\Type\Accessory\AccessoryNumericStringType;
Expand Down Expand Up @@ -38,7 +39,20 @@ public function isValidForArithmeticOperation(Scope $scope, Expr $expr): bool
return true;
}

return $this->isSubtypeOfNumber($scope, $expr);
if ($this->isSubtypeOfNumber($scope, $expr)) {
return true;
}

// Check if the type supports arithmetic via operator overloading extensions
// (only applies to object types like GMP, BCMath\Number)
if ($type->isObject()->yes()) {
$resultType = $scope->getType(new Expr\BinaryOp\Plus($expr, new Int_(1)));
if (!$resultType instanceof ErrorType) {
return true;
}
}

return false;
}

public function isValidForIncrement(Scope $scope, Expr $expr): bool
Expand All @@ -53,7 +67,18 @@ public function isValidForIncrement(Scope $scope, Expr $expr): bool
return true;
}

return $this->isSubtypeOfNumber($scope, $expr);
if ($this->isSubtypeOfNumber($scope, $expr)) {
return true;
}

if ($type->isObject()->yes()) {
$resultType = $scope->getType(new Expr\PreInc($expr));
if (!$resultType instanceof ErrorType) {
return true;
}
}

return false;
}

public function isValidForDecrement(Scope $scope, Expr $expr): bool
Expand All @@ -63,7 +88,18 @@ public function isValidForDecrement(Scope $scope, Expr $expr): bool
return true;
}

return $this->isSubtypeOfNumber($scope, $expr);
if ($this->isSubtypeOfNumber($scope, $expr)) {
return true;
}

if ($type->isObject()->yes()) {
$resultType = $scope->getType(new Expr\PreDec($expr));
if (!$resultType instanceof ErrorType) {
return true;
}
}

return false;
}

private function isSubtypeOfNumber(Scope $scope, Expr $expr): bool
Expand Down