Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump phpstan/phpstan-phpunit from 2.0.1 to 2.0.2 #792

Merged
merged 3 commits into from
Dec 17, 2024
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 composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"php-parallel-lint/php-parallel-lint": "1.4",
"phpstan/phpstan": "2.0.4",
"phpstan/phpstan-deprecation-rules": "2.0.1",
"phpstan/phpstan-phpunit": "2.0.1",
"phpstan/phpstan-phpunit": "2.0.2",
"phpstan/phpstan-strict-rules": "2.0.0",
"phpstan/phpstan-symfony": "2.0.0",
"spaze/phpstan-disallowed-calls": "4.0.1",
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

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

1 change: 1 addition & 0 deletions vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@
'PHPStan\\Rules\\Operators\\OperandsInArithmeticSubtractionRule' => $vendorDir . '/phpstan/phpstan-strict-rules/src/Rules/Operators/OperandsInArithmeticSubtractionRule.php',
'PHPStan\\Rules\\Operators\\OperatorRuleHelper' => $vendorDir . '/phpstan/phpstan-strict-rules/src/Rules/Operators/OperatorRuleHelper.php',
'PHPStan\\Rules\\PHPUnit\\AnnotationHelper' => $vendorDir . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AnnotationHelper.php',
'PHPStan\\Rules\\PHPUnit\\AssertEqualsIsDiscouragedRule' => $vendorDir . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertEqualsIsDiscouragedRule.php',
'PHPStan\\Rules\\PHPUnit\\AssertRuleHelper' => $vendorDir . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertRuleHelper.php',
'PHPStan\\Rules\\PHPUnit\\AssertSameBooleanExpectedRule' => $vendorDir . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameBooleanExpectedRule.php',
'PHPStan\\Rules\\PHPUnit\\AssertSameNullExpectedRule' => $vendorDir . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameNullExpectedRule.php',
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'Rector\\TypePerfect\\' => array($vendorDir . '/rector/type-perfect/src'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
'PHPStan\\' => array($vendorDir . '/phpstan/phpstan-deprecation-rules/src', $vendorDir . '/phpstan/phpstan-phpunit/src', $vendorDir . '/phpstan/phpstan-strict-rules/src', $vendorDir . '/phpstan/phpstan-symfony/src'),
'PHPStan\\' => array($vendorDir . '/phpstan/phpstan-deprecation-rules/src', $vendorDir . '/phpstan/phpstan-strict-rules/src', $vendorDir . '/phpstan/phpstan-symfony/src', $vendorDir . '/phpstan/phpstan-phpunit/src'),
'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
'Doctrine\\Deprecations\\' => array($vendorDir . '/doctrine/deprecations/src'),
'Doctrine\\DBAL\\' => array($vendorDir . '/doctrine/dbal/src'),
Expand Down
7 changes: 4 additions & 3 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ class ComposerStaticInit9cf8af24a7a084f114b4553be2a1ff9f
'PHPStan\\' =>
array (
0 => __DIR__ . '/..' . '/phpstan/phpstan-deprecation-rules/src',
1 => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src',
2 => __DIR__ . '/..' . '/phpstan/phpstan-strict-rules/src',
3 => __DIR__ . '/..' . '/phpstan/phpstan-symfony/src',
1 => __DIR__ . '/..' . '/phpstan/phpstan-strict-rules/src',
2 => __DIR__ . '/..' . '/phpstan/phpstan-symfony/src',
3 => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src',
),
'JsonSchema\\' =>
array (
Expand Down Expand Up @@ -1103,6 +1103,7 @@ class ComposerStaticInit9cf8af24a7a084f114b4553be2a1ff9f
'PHPStan\\Rules\\Operators\\OperandsInArithmeticSubtractionRule' => __DIR__ . '/..' . '/phpstan/phpstan-strict-rules/src/Rules/Operators/OperandsInArithmeticSubtractionRule.php',
'PHPStan\\Rules\\Operators\\OperatorRuleHelper' => __DIR__ . '/..' . '/phpstan/phpstan-strict-rules/src/Rules/Operators/OperatorRuleHelper.php',
'PHPStan\\Rules\\PHPUnit\\AnnotationHelper' => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AnnotationHelper.php',
'PHPStan\\Rules\\PHPUnit\\AssertEqualsIsDiscouragedRule' => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertEqualsIsDiscouragedRule.php',
'PHPStan\\Rules\\PHPUnit\\AssertRuleHelper' => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertRuleHelper.php',
'PHPStan\\Rules\\PHPUnit\\AssertSameBooleanExpectedRule' => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameBooleanExpectedRule.php',
'PHPStan\\Rules\\PHPUnit\\AssertSameNullExpectedRule' => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameNullExpectedRule.php',
Expand Down
16 changes: 8 additions & 8 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1130,22 +1130,22 @@
},
{
"name": "phpstan/phpstan-phpunit",
"version": "2.0.1",
"version_normalized": "2.0.1.0",
"version": "2.0.2",
"version_normalized": "2.0.2.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "4b6ad7fab8683ff4efd7887ba26ef8ee171c7475"
"reference": "2cedfb72dfd0e9c5d636f837b945c9f20c943bdb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/4b6ad7fab8683ff4efd7887ba26ef8ee171c7475",
"reference": "4b6ad7fab8683ff4efd7887ba26ef8ee171c7475",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/2cedfb72dfd0e9c5d636f837b945c9f20c943bdb",
"reference": "2cedfb72dfd0e9c5d636f837b945c9f20c943bdb",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.0"
"phpstan/phpstan": "^2.0.4"
},
"conflict": {
"phpunit/phpunit": "<7.0"
Expand All @@ -1155,7 +1155,7 @@
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.6"
},
"time": "2024-11-12T12:48:00+00:00",
"time": "2024-12-17T17:22:26+00:00",
"type": "phpstan-extension",
"extra": {
"phpstan": {
Expand All @@ -1178,7 +1178,7 @@
"description": "PHPUnit extensions and rules for PHPStan",
"support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.1"
"source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.2"
},
"install-path": "../phpstan/phpstan-phpunit"
},
Expand Down
10 changes: 5 additions & 5 deletions 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' => 'd3da0efde5661bb9590c7168f61f40a23db17ca0',
'reference' => 'e17dfb059dd78822fa0b66ddc2c3470a2e89b7af',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => 'd3da0efde5661bb9590c7168f61f40a23db17ca0',
'reference' => 'e17dfb059dd78822fa0b66ddc2c3470a2e89b7af',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -167,9 +167,9 @@
'dev_requirement' => false,
),
'phpstan/phpstan-phpunit' => array(
'pretty_version' => '2.0.1',
'version' => '2.0.1.0',
'reference' => '4b6ad7fab8683ff4efd7887ba26ef8ee171c7475',
'pretty_version' => '2.0.2',
'version' => '2.0.2.0',
'reference' => '2cedfb72dfd0e9c5d636f837b945c9f20c943bdb',
'type' => 'phpstan-extension',
'install_path' => __DIR__ . '/../phpstan/phpstan-phpunit',
'aliases' => array(),
Expand Down
1 change: 1 addition & 0 deletions vendor/phpstan/phpstan-phpunit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ It also contains this strict framework-specific rules (can be enabled separately
* Check that you are not using `assertSame()` with `false` as expected value. `assertFalse()` should be used instead.
* Check that you are not using `assertSame()` with `null` as expected value. `assertNull()` should be used instead.
* Check that you are not using `assertSame()` with `count($variable)` as second parameter. `assertCount($variable)` should be used instead.
* Check that you are not using `assertEquals()` with same types (`assertSame()` should be used)

## How to document mock objects in phpDocs?

Expand Down
2 changes: 1 addition & 1 deletion vendor/phpstan/phpstan-phpunit/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"require": {
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.0"
"phpstan/phpstan": "^2.0.4"
},
"conflict": {
"phpunit/phpunit": "<7.0"
Expand Down
7 changes: 7 additions & 0 deletions vendor/phpstan/phpstan-phpunit/rules.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ rules:
- PHPStan\Rules\PHPUnit\NoMissingSpaceInMethodAnnotationRule
- PHPStan\Rules\PHPUnit\ShouldCallParentMethodsRule

conditionalTags:
PHPStan\Rules\PHPUnit\AssertEqualsIsDiscouragedRule:
phpstan.rules.rule: [%strictRulesInstalled%, %featureToggles.bleedingEdge%]

services:
-
class: PHPStan\Rules\PHPUnit\DataProviderDeclarationRule
Expand All @@ -17,3 +21,6 @@ services:
deprecationRulesInstalled: %deprecationRulesInstalled%
tags:
- phpstan.rules.rule

-
class: PHPStan\Rules\PHPUnit\AssertEqualsIsDiscouragedRule
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php declare(strict_types = 1);

namespace PHPStan\Rules\PHPUnit;

use PhpParser\Node;
use PhpParser\Node\Expr\CallLike;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\Type\GeneralizePrecision;
use PHPStan\Type\TypeCombinator;
use function count;
use function strtolower;

/**
* @implements Rule<CallLike>
*/
class AssertEqualsIsDiscouragedRule implements Rule
{

public function getNodeType(): string
{
return CallLike::class;
}

public function processNode(Node $node, Scope $scope): array
{
if (!AssertRuleHelper::isMethodOrStaticCallOnAssert($node, $scope)) {
return [];
}

if (count($node->getArgs()) < 2) {
return [];
}
if (!$node->name instanceof Node\Identifier || strtolower($node->name->name) !== 'assertequals') {
return [];
}

$leftType = TypeCombinator::removeNull($scope->getType($node->getArgs()[0]->value));
$rightType = TypeCombinator::removeNull($scope->getType($node->getArgs()[1]->value));

if ($leftType->isConstantScalarValue()->yes()) {
$leftType = $leftType->generalize(GeneralizePrecision::lessSpecific());
}
if ($rightType->isConstantScalarValue()->yes()) {
$rightType = $rightType->generalize(GeneralizePrecision::lessSpecific());
}

if (
($leftType->isScalar()->yes() && $rightType->isScalar()->yes())
&& ($leftType->isSuperTypeOf($rightType)->yes())
&& ($rightType->isSuperTypeOf($leftType)->yes())
) {
return [
RuleErrorBuilder::message(
'You should use assertSame() instead of assertEquals(), because both values are scalars of the same type',
)->identifier('phpunit.assertEquals')->build(),
];
}

return [];
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
namespace PHPStan\Rules\PHPUnit;

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;
use function count;

/**
* @implements Rule<NodeAbstract>
* @implements Rule<CallLike>
*/
class AssertSameBooleanExpectedRule implements Rule
{

public function getNodeType(): string
{
return NodeAbstract::class;
return CallLike::class;
}

public function processNode(Node $node, Scope $scope): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
namespace PHPStan\Rules\PHPUnit;

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;
use function count;

/**
* @implements Rule<NodeAbstract>
* @implements Rule<CallLike>
*/
class AssertSameNullExpectedRule implements Rule
{

public function getNodeType(): string
{
return NodeAbstract::class;
return CallLike::class;
}

public function processNode(Node $node, Scope $scope): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

use Countable;
use PhpParser\Node;
use PhpParser\NodeAbstract;
use PhpParser\Node\Expr\CallLike;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\Type\ObjectType;
use function count;

/**
* @implements Rule<NodeAbstract>
* @implements Rule<CallLike>
*/
class AssertSameWithCountRule implements Rule
{

public function getNodeType(): string
{
return NodeAbstract::class;
return CallLike::class;
}

public function processNode(Node $node, Scope $scope): array
Expand Down
Loading