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
4 changes: 2 additions & 2 deletions tools/.phpstan/composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"require-dev": {
"phpstan/phpstan": "^2.2.15",
"phpstan/phpstan": "^2.2.16",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan-phpunit": "^2.0.18",
"phpstan/phpstan-phpunit": "^2.0.19",
"phpstan/phpstan-strict-rules": "^2.0.12",
"ergebnis/phpstan-rules": "^2.14.0"
},
Expand Down
24 changes: 12 additions & 12 deletions tools/.phpstan/composer.lock

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

26 changes: 13 additions & 13 deletions tools/.phpstan/vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@
},
{
"name": "phpstan/phpstan",
"version": "2.2.15",
"version_normalized": "2.2.15.0",
"version": "2.2.16",
"version_normalized": "2.2.16.0",
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/b158556ffd26825cf615a1c1f72fb5157a2301b7",
"reference": "b158556ffd26825cf615a1c1f72fb5157a2301b7",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/46a6d9060e5a7763adfcc21ebcb8b504ebdbcb92",
"reference": "46a6d9060e5a7763adfcc21ebcb8b504ebdbcb92",
"shasum": ""
},
"require": {
Expand All @@ -202,7 +202,7 @@
"conflict": {
"phpstan/phpstan-shim": "*"
},
"time": "2026-09-23T12:23:07+00:00",
"time": "2026-09-25T09:31:51+00:00",
"bin": [
"phpstan",
"phpstan.phar"
Expand Down Expand Up @@ -255,23 +255,23 @@
},
{
"name": "phpstan/phpstan-phpunit",
"version": "2.0.18",
"version_normalized": "2.0.18.0",
"version": "2.0.19",
"version_normalized": "2.0.19.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "f5dc20ff8082d02339b60cab68ec3eb0d859fb30"
"reference": "33a190a5e8e69fd18308443a80d4f43f42d43604"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/f5dc20ff8082d02339b60cab68ec3eb0d859fb30",
"reference": "f5dc20ff8082d02339b60cab68ec3eb0d859fb30",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/33a190a5e8e69fd18308443a80d4f43f42d43604",
"reference": "33a190a5e8e69fd18308443a80d4f43f42d43604",
"shasum": ""
},
"require": {
"phar-io/version": "^3.2",
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.2.3"
"phpstan/phpstan": "^2.2.6"
},
"conflict": {
"phpunit/phpunit": "<7.0"
Expand All @@ -284,7 +284,7 @@
"phpunit/phpunit": "^9.6",
"shipmonk/name-collision-detector": "^2.1"
},
"time": "2026-07-04T12:16:09+00:00",
"time": "2026-09-26T17:07:06+00:00",
"type": "phpstan-extension",
"extra": {
"phpstan": {
Expand All @@ -310,7 +310,7 @@
],
"support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.18"
"source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.19"
},
"install-path": "../phpstan/phpstan-phpunit"
},
Expand Down
16 changes: 8 additions & 8 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' => '28f0b49879941c81f68ff69cc747fd37b54e07f3',
'reference' => '9b94a0328227df891482a39d7588e15a18e660cd',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '28f0b49879941c81f68ff69cc747fd37b54e07f3',
'reference' => '9b94a0328227df891482a39d7588e15a18e660cd',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -47,18 +47,18 @@
'dev_requirement' => true,
),
'phpstan/phpstan' => array(
'pretty_version' => '2.2.15',
'version' => '2.2.15.0',
'reference' => 'b158556ffd26825cf615a1c1f72fb5157a2301b7',
'pretty_version' => '2.2.16',
'version' => '2.2.16.0',
'reference' => '46a6d9060e5a7763adfcc21ebcb8b504ebdbcb92',
'type' => 'library',
'install_path' => __DIR__ . '/../phpstan/phpstan',
'aliases' => array(),
'dev_requirement' => true,
),
'phpstan/phpstan-phpunit' => array(
'pretty_version' => '2.0.18',
'version' => '2.0.18.0',
'reference' => 'f5dc20ff8082d02339b60cab68ec3eb0d859fb30',
'pretty_version' => '2.0.19',
'version' => '2.0.19.0',
'reference' => '33a190a5e8e69fd18308443a80d4f43f42d43604',
'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 @@ -9,7 +9,7 @@
"require": {
"php": "^7.4 || ^8.0",
"phar-io/version": "^3.2",
"phpstan/phpstan": "^2.2.3"
"phpstan/phpstan": "^2.2.6"
},
"conflict": {
"phpunit/phpunit": "<7.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/vendor
composer.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"require": {
"php": "^8.1",
"phpstan/phpstan": "@dev",
"phpstan/phpstan-phpunit": "@dev",
"phpunit/phpunit": "^12.5",
"phpstan/extension-installer": "^1.4"
},
"repositories": [
{
"type": "path",
"url": "../../"
}
],
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon

parameters:
level: 5
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use PHPUnit\Framework\Attributes\RequiresPhp;
use PHPUnit\Framework\Attributes\RequiresPhpunit;

class A extends \PHPUnit\Framework\TestCase {
#[RequiresPhp('<=8.2.0')]
public function testFoo() {}
}

class B extends \PHPUnit\Framework\TestCase {
#[RequiresPhp('<=8.0.0')]
public function testFoo() {}
}

class C extends \PHPUnit\Framework\TestCase {
#[RequiresPhp('^8.0.0')]
public function testFoo() {}
}

class D extends \PHPUnit\Framework\TestCase {
#[RequiresPhp('^8.1.0')]
public function testFoo() {}
}

class E extends \PHPUnit\Framework\TestCase {
#[RequiresPhpunit('^12.0.0')]
public function testFoo() {}
}

class F extends \PHPUnit\Framework\TestCase {
#[RequiresPhpunit('^11.0.0')]
public function testFoo() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHPStan\PhpDoc\TypeNodeResolver;
use PHPStan\PhpDoc\TypeNodeResolverAwareExtension;
use PHPStan\PhpDoc\TypeNodeResolverExtension;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
use PHPStan\Type\NeverType;
Expand Down Expand Up @@ -41,6 +42,26 @@ public function resolve(TypeNode $typeNode, NameScope $nameScope): ?Type
'PHPUnit\Framework\MockObject\Stub' => true,
];

// TypeNodeResolver resolves the union again when this returns null, so resolving every
// member here would resolve each nested union twice per level. Look at the direct
// identifier members first: they cannot nest, and a mock class in a union is written as one.
$hasMockClass = false;
foreach ($typeNode->types as $innerTypeNode) {
if (!$innerTypeNode instanceof IdentifierTypeNode) {
continue;
}

$classNames = $this->typeNodeResolver->resolve($innerTypeNode, $nameScope)->getObjectClassNames();
if (count($classNames) === 1 && array_key_exists($classNames[0], $mockClassNames)) {
$hasMockClass = true;
break;
}
}

if (!$hasMockClass) {
return null;
}

$types = $this->typeNodeResolver->resolveMultiple($typeNode->types, $nameScope);
foreach ($types as $type) {
$classNames = $type->getObjectClassNames();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PhpParser\Node;
use PhpParser\Node\Expr\CallLike;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\NodeAbstract;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
Expand Down Expand Up @@ -77,8 +78,9 @@ public function processNode(Node $node, Scope $scope): array
}

/**
* @param array<Node\Arg|Node\VariadicPlaceholder> $args
* @return list<Node\Arg|Node\VariadicPlaceholder>
* @template T of NodeAbstract
* @param array<T> $args
* @return list<T>
*/
private static function rewriteArgs(array $args): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PhpParser\Node;
use PhpParser\Node\Expr\CallLike;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\NodeAbstract;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
Expand Down Expand Up @@ -63,8 +64,9 @@ public function processNode(Node $node, Scope $scope): array
}

/**
* @param array<Node\Arg|Node\VariadicPlaceholder> $args
* @return list<Node\Arg|Node\VariadicPlaceholder>
* @template T of NodeAbstract
* @param array<T> $args
* @return list<T>
*/
private static function rewriteArgs(array $args): array
{
Expand Down
Loading
Loading