- Issue created by @jonathan1055
- ๐ฎ๐ณIndia vishalkhode
vishalkhode โ made their first commit to this issueโs fork.
- ๐ฌ๐งUnited Kingdom jonathan1055
@viskalkhode, it shows above that you made a commit, but there are no changes showing. I guess you did not actually do anything?
I cannot replicate this error locally, can you?In the pipelines PHPStan rus ok on 'current' core 10.3 and 'next minor' 10.4, both use PHPStan 1.11.10 and PHP 8.1.29
It is also OK on 'Max PHP' - PHPStan 1.11.10, PHP 8.3.10It only fails on 'next major' which D11, the it is running the same PHPStan 1.11.10 and PHP 8.3.10 as for 'Max PHP'
I am not sure there is actually a problem in the Scheduler code. We get this message:
Run PHPStan with -v option and post the stack trace to: https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml
This implies that the "internal error" is a bug/problem in phpstan and the maintainers want to see what went wrong.
- ๐ฎ๐ณIndia vishalkhode
Hi @jonathan1055
Yes, I've not pushed anything, just got the fork push access and re-ran the job to see if maybe it's due to some issue of CI, but unfortunately it's not, but somehow I'm able to reproduce the issue, following is the stack trace I'm seeing:-- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Error -- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Internal error: Method Drupal\scheduler\SchedulerManager::Drupal\scheduler\formatOutputText() does not exist while analysing file /Users/vishal.khode/drupal11/scheduler/src/SchedulerManager.php Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml: ## phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflection/Adapter/ReflectionClass.php(161) #0 /Users/vishal.khode/drupal11/scheduler/vendor/mglaman/phpstan-drupal/src/DeprecatedScope/IgnoreDeprecationsScope.php(31): PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass->getMethod() #1 /Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/DeprecatedScopeHelper.php(24): mglaman\PHPStanDrupal\DeprecatedScope\IgnoreDeprecationsScope->isScopeDeprecated() #2 /Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/TypeHintDeprecatedInFunctionSignatureRule.php(40): PHPStan\Rules\Deprecations\DeprecatedScopeHelper->isScopeDeprecated() #3 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(120): PHPStan\Rules\Deprecations\TypeHintDeprecatedInFunctionSignatureRule->processNode() #4 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Node/ClassStatementsGatherer.php(109): PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}() #5 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(647): PHPStan\Node\ClassStatementsGatherer->__invoke() #6 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(571): PHPStan\Analyser\NodeScopeResolver::PHPStan\Analyser\{closure}() #7 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(458): PHPStan\Analyser\NodeScopeResolver->processStmtNode() #8 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(646): PHPStan\Analyser\NodeScopeResolver->processStmtNodes() #9 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(458): PHPStan\Analyser\NodeScopeResolver->processStmtNode() #10 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(783): PHPStan\Analyser\NodeScopeResolver->processStmtNodes() #11 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(458): PHPStan\Analyser\NodeScopeResolver->processStmtNode() #12 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(753): PHPStan\Analyser\NodeScopeResolver->processStmtNodes() #13 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(423): PHPStan\Analyser\NodeScopeResolver->processStmtNode() #14 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(179): PHPStan\Analyser\NodeScopeResolver->processNodes() #15 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(139): PHPStan\Analyser\FileAnalyser->analyseFile() #16 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(111): PHPStan\Command\WorkerCommand::PHPStan\Command\{closure}() #17 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/Decoder.php(117): _PHPStan_b7fe9900d\Evenement\EventEmitter->emit() #18 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(111): _PHPStan_b7fe9900d\Clue\React\NDJson\Decoder->handleData() #19 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.php(62): _PHPStan_b7fe9900d\Evenement\EventEmitter->emit() #20 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(111): _PHPStan_b7fe9900d\React\Stream\Util::_PHPStan_b7fe9900d\React\Stream\{closure}() #21 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/DuplexResourceStream.php(168): _PHPStan_b7fe9900d\Evenement\EventEmitter->emit() #22 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201): _PHPStan_b7fe9900d\React\Stream\DuplexResourceStream->handleData() #23 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173): _PHPStan_b7fe9900d\React\EventLoop\StreamSelectLoop->waitForStreamActivity() #24 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(99): _PHPStan_b7fe9900d\React\EventLoop\StreamSelectLoop->run() #25 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\WorkerCommand->execute() #26 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(870): _PHPStan_b7fe9900d\Symfony\Component\Console\Command\Command->run() #27 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(261): _PHPStan_b7fe9900d\Symfony\Component\Console\Application->doRunCommand() #28 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157): _PHPStan_b7fe9900d\Symfony\Component\Console\Application->doRun() #29 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(124): _PHPStan_b7fe9900d\Symfony\Component\Console\Application->run() #30 phar:///Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(125): _PHPStan_b7fe9900d\{closure}() #31 /Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan/phpstan(8): require('...') #32 /Users/vishal.khode/drupal11/scheduler/vendor/bin/phpstan(119): include('...') #33 {main} -- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [ERROR] Found 1 error PHP runtime version: 8.3.6 PHP version for analysis: 8.3.6 (from runtime) PHPStan version: 1.11.10 PHPStan running from: /Users/vishal.khode/drupal11/scheduler/vendor/phpstan/phpstan Extension installer: composer/composer: 2.7.7 composer/pcre: 3.2.0 mglaman/phpstan-drupal: 1.2.12 phpstan/phpstan-deprecation-rules: 1.2.0 phpstan/phpstan-phpunit: 1.4.0 Discovered Composer project root: /Users/vishal.khode/drupal11/scheduler Parallel processing scheduler: # of detected CPU cores: 12 # of analysed files: 1 # of jobs: 1 # of spawned processes: 1 โ ๏ธ Result is incomplete because of severe errors. โ ๏ธ Fix these errors first and then re-run PHPStan to get all reported errors. Elapsed time: 7 seconds Used memory: 128.5 MB
- ๐ฎ๐ณIndia vishalkhode
Further debugging, I found that the code in
mglaman/phpstan-drupal
extension is causing the issue. When I downgraded the mglaman/phpstan-drupal extension from 1.2.12 to 1.2.11, the error doesn't show up. I think @mglaman can help us here. - ๐ฎ๐ณIndia vishalkhode
@jonathan1055: Ok, so I tweaked the method
formatOutputText()
and converted the regular function to an anonymous function (or closure) and assigned to the$formatOutputText
variable. This allows us to use it like a regular function within theresetFormDisplayFields
method. Because anyways defining a function inside another function or method, is I think generally not a good practice in PHP.But now, I can see different PHPStan errors in Current and Next Major Drupal Core version. Ex: https://git.drupalcode.org/issue/scheduler-3467349/-/pipelines/253073
But I strongly think, this shouldn't have been caused due to my changes: https://git.drupalcode.org/issue/scheduler-3467349/-/compare/2.x...34673... - Status changed to Needs review
3 months ago 7:42pm 13 August 2024 - ๐ฎ๐ณIndia vishalkhode
Ok, so the error was there, because I fixed the error, but didn't notice that the same error was added to ignore in PHPStan baseline file. But now I've updated the baseline file and removed that portion and so everything looks good now. Hence, requesting review.
But now, I can see different PHPStan errors in Current and Next Major Drupal Core version. Ex: https://git.drupalcode.org/issue/scheduler-3467349/-/pipelines/253073.
- ๐ฌ๐งUnited Kingdom jonathan1055
Thank you for working on this. It does sound like a fault in eem like a problem in mglaman/phpstan-drupal 1.2.12 if there is no error after you downgrade to 1.2.11
I like your solution to convert the function into a anonymous one, that is better, and also removes two ignored messages from the baseline.
- Status changed to Fixed
3 months ago 3:28pm 14 August 2024 - ๐ฌ๐งUnited Kingdom jonathan1055
Committed and fixed, thanks.
The newly-failing PHPunit test at 'next major' is unrelated to this change. It was running OK on 11 August but ,failing on 14 August. It must be due to a change in the Commerce or Commerce Product dev repo we are using.
-
jonathan1055 โ
committed 1e7762ca on 2.x authored by
vishalkhode โ
Issue #3467349 by vishalkhode: PHPStan at D11 - Drupal\scheduler\...
-
jonathan1055 โ
committed 1e7762ca on 2.x authored by
vishalkhode โ
Automatically closed - issue fixed for 2 weeks with no activity.