rectorphp / rector-phpunit

Rector upgrade rules for PHPUnit
https://getrector.com/find-rule?activeRectorSetGroup=phpunit
MIT License
69 stars 47 forks source link

phpunit fails with `assert($startLine > 0)` #169

Closed staabm closed 1 year ago

staabm commented 1 year ago

running phpunit on https://github.com/rectorphp/rector-phpunit/commit/8a1a1637ea4c39ff1fdbcdb3671beddbd5108978 I get errors like on my mac

➜  rector-phpunit git:(main) vendor/bin/phpunit 
PHPUnit 10.1.0 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.1.18
Configuration: /Users/staabm/workspace/rector-phpunit/phpunit.xml

.............................F.F...............................  63 / 182 ( 34%)
............................................................... 126 / 182 ( 69%)
........................................................        182 / 182 (100%)

Time: 00:18.524, Memory: 1.80 GB

There were 2 failures:

1) Rector\PHPUnit\Tests\Rector\ClassMethod\CreateMockToAnonymousClassRector\CreateMockToAnonymousClassRectorTest::test with data set #0
assert($startLine > 0)

phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflection/ReflectionClass.php:189
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflection/ReflectionClass.php:261
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php:211
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php:59
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php:1102
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php:558
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php:744
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php:558
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:1473
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:567
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:362
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:531
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:331
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php:374
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php:227
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/Application/ChangedNodeScopeRefresher.php:95
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/Rector/AbstractRector.php:367
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/Rector/AbstractRector.php:260
/Users/staabm/workspace/rector-phpunit/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:200
/Users/staabm/workspace/rector-phpunit/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:114
/Users/staabm/workspace/rector-phpunit/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:223
/Users/staabm/workspace/rector-phpunit/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:114
/Users/staabm/workspace/rector-phpunit/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:223
/Users/staabm/workspace/rector-phpunit/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:91
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/PhpParser/NodeTraverser/RectorNodeTraverser.php:33
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/Application/FileProcessor.php:41
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/Application/FileProcessor/PhpFileProcessor.php:71
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/Application/ApplicationFileProcessor.php:127
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/packages/Testing/PHPUnit/AbstractRectorTestCase.php:188
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/packages/Testing/PHPUnit/AbstractRectorTestCase.php:154
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/packages/Testing/PHPUnit/AbstractRectorTestCase.php:128
/Users/staabm/workspace/rector-phpunit/tests/Rector/ClassMethod/CreateMockToAnonymousClassRector/CreateMockToAnonymousClassRectorTest.php:16

2) Rector\PHPUnit\Tests\Rector\ClassMethod\CreateMockToAnonymousClassRector\CreateMockToAnonymousClassRectorTest::test with data set #2
assert($startLine > 0)

phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflection/ReflectionClass.php:189
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflection/ReflectionClass.php:261
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php:211
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php:59
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php:1102
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php:558
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php:744
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php:558
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:1473
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:567
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:362
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:531
phar:///Users/staabm/workspace/rector-phpunit/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:331
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php:374
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php:227
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/Application/ChangedNodeScopeRefresher.php:95
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/Rector/AbstractRector.php:367
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/Rector/AbstractRector.php:260
/Users/staabm/workspace/rector-phpunit/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:200
/Users/staabm/workspace/rector-phpunit/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:114
/Users/staabm/workspace/rector-phpunit/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:223
/Users/staabm/workspace/rector-phpunit/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:114
/Users/staabm/workspace/rector-phpunit/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:223
/Users/staabm/workspace/rector-phpunit/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:91
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/PhpParser/NodeTraverser/RectorNodeTraverser.php:33
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/Application/FileProcessor.php:41
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/Application/FileProcessor/PhpFileProcessor.php:71
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/src/Application/ApplicationFileProcessor.php:127
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/packages/Testing/PHPUnit/AbstractRectorTestCase.php:188
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/packages/Testing/PHPUnit/AbstractRectorTestCase.php:154
/Users/staabm/workspace/rector-phpunit/vendor/rector/rector-src/packages/Testing/PHPUnit/AbstractRectorTestCase.php:128
/Users/staabm/workspace/rector-phpunit/tests/Rector/ClassMethod/CreateMockToAnonymousClassRector/CreateMockToAnonymousClassRectorTest.php:16

FAILURES!
Tests: 182, Assertions: 183, Failures: 2.

➜  rector-phpunit git:(main) php -v
PHP 8.1.18 (cli) (built: Apr 12 2023 12:31:46) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.18, Copyright (c) Zend Technologies

does anyone has an idea whats going on?

samsonasik commented 1 year ago

That's seems need BetterReflection 6.x compat, see https://github.com/rectorphp/rector-src/pull/3207 for how to handle it.

samsonasik commented 1 year ago

I created PR https://github.com/rectorphp/rector-phpunit/pull/170 for it.