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 @@ -2,7 +2,7 @@
"require-dev": {
"phpstan/phpstan": "^2.2.4",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan-phpunit": "^2.0.17",
"phpstan/phpstan-phpunit": "^2.0.18",
"phpstan/phpstan-strict-rules": "^2.0.11",
"tomasvotruba/type-coverage": "^2.2.2",
"ergebnis/phpstan-rules": "^2.13.1"
Expand Down
14 changes: 7 additions & 7 deletions tools/.phpstan/composer.lock

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

14 changes: 7 additions & 7 deletions tools/.phpstan/vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,17 @@
},
{
"name": "phpstan/phpstan-phpunit",
"version": "2.0.17",
"version_normalized": "2.0.17.0",
"version": "2.0.18",
"version_normalized": "2.0.18.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "c2f977551f0736d60467b3d754b2e0cf4e337b3f"
"reference": "f5dc20ff8082d02339b60cab68ec3eb0d859fb30"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/c2f977551f0736d60467b3d754b2e0cf4e337b3f",
"reference": "c2f977551f0736d60467b3d754b2e0cf4e337b3f",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/f5dc20ff8082d02339b60cab68ec3eb0d859fb30",
"reference": "f5dc20ff8082d02339b60cab68ec3eb0d859fb30",
"shasum": ""
},
"require": {
Expand All @@ -279,7 +279,7 @@
"phpunit/phpunit": "^9.6",
"shipmonk/name-collision-detector": "^2.1"
},
"time": "2026-06-29T05:32:23+00:00",
"time": "2026-07-04T12:16:09+00:00",
"type": "phpstan-extension",
"extra": {
"phpstan": {
Expand All @@ -305,7 +305,7 @@
],
"support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.17"
"source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.18"
},
"install-path": "../phpstan/phpstan-phpunit"
},
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' => 'ade0ea39dc79debd1c2c46bcc19830acfe449afc',
'reference' => '7fa079b9c95cf84f46ba074010f8d1e79f689af8',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => 'ade0ea39dc79debd1c2c46bcc19830acfe449afc',
'reference' => '7fa079b9c95cf84f46ba074010f8d1e79f689af8',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -56,9 +56,9 @@
'dev_requirement' => true,
),
'phpstan/phpstan-phpunit' => array(
'pretty_version' => '2.0.17',
'version' => '2.0.17.0',
'reference' => 'c2f977551f0736d60467b3d754b2e0cf4e337b3f',
'pretty_version' => '2.0.18',
'version' => '2.0.18.0',
'reference' => 'f5dc20ff8082d02339b60cab68ec3eb0d859fb30',
'type' => 'phpstan-extension',
'install_path' => __DIR__ . '/../phpstan/phpstan-phpunit',
'aliases' => array(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use function is_numeric;
use function preg_match;
use function sprintf;
use function strpos;
use function substr_count;
use function version_compare;

Expand All @@ -43,9 +44,9 @@ final class AttributeVersionRequirementHelper

public function __construct(
PHPUnitVersion $PHPUnitVersion,
bool $deprecationRulesInstalled,
PhpVersion $phpVersion,
bool $bleedingEdge,
bool $deprecationRulesInstalled = false,
bool $bleedingEdge = false,
bool $warnAboutIncompleteVersion = true
)
{
Expand Down Expand Up @@ -96,11 +97,18 @@ public function checkVersionRequirement(array $attributes, Scope $scope): array
continue;
}

$pharIoVersions = strpos($attr->getName(), 'RequiresPhpunit') !== false
? $this->PHPUnitVersion->getPharIoVersions()
: $phpstanPharIoVersions;
if ($pharIoVersions === []) {
continue;
}

try {
// check composer like version constraints, e.g. ^1 or ~2
$testPhpVersionConstraint = $parser->parse($versionRequirement);

foreach ($phpstanPharIoVersions as $pharIoVersion) {
foreach ($pharIoVersions as $pharIoVersion) {
if ($testPhpVersionConstraint->complies($pharIoVersion)) {
// one of the versions within range matched, check next attribute
continue 2;
Expand All @@ -120,7 +128,7 @@ public function checkVersionRequirement(array $attributes, Scope $scope): array

$operator = $matches['operator'] !== '' ? $matches['operator'] : '>=';

foreach ($phpstanPharIoVersions as $pharIoVersion) {
foreach ($pharIoVersions as $pharIoVersion) {
if (version_compare($pharIoVersion->getVersionString(), $matches['version'], $operator)) {
// one of the versions within range matched, check next attribute
continue 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace PHPStan\Rules\PHPUnit;

use PharIo\Version\Version;
use PHPStan\TrinaryLogic;
use function sprintf;

class PHPUnitVersion
{
Expand All @@ -17,6 +19,21 @@ public function __construct(?int $majorVersion, ?int $minorVersion)
$this->minorVersion = $minorVersion;
}

/**
* @return array{}|array{Version, Version}
*/
public function getPharIoVersions(): array
{
if ($this->majorVersion === null || $this->minorVersion === null) {
return [];
}

return [
new Version(sprintf('%d.%d.0', $this->majorVersion, $this->minorVersion)),
new Version(sprintf('%d.%d.99', $this->majorVersion, $this->minorVersion)),
];
}

public function supportsDataProviderAttribute(): TrinaryLogic
{
if ($this->majorVersion === null) {
Expand Down