Skip to content

Function roundingmode stub not found error after migrating to PHP 8.4 #12549

@speller

Description

@speller

Bug report

 -- -------------------------------------------------------------------------------------------------------------------------------------------------------
     Error

 -- -------------------------------------------------------------------------------------------------------------------------------------------------------
     Internal error: Function roundingmode stub not found in

     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/SignatureMap/../../../vendor/phpstan/php-8-stubs/stubs/ext/standard/RoundingMode.stub.
     while analysing file /app/src/Form/EasyAdmin/Field/DecimalField.php



     Run PHPStan with -v option and post the stack trace to:

     https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml



 -- -------------------------------------------------------------------------------------------------------------------------------------------------------


⚠️  Result is incomplete because of severe errors. ⚠️
   Fix these errors first and then re-run PHPStan
   to get all reported errors.

 [ERROR] Found 1 error

At the same time, there's NO roundingmode function usage in the source file. The error started happening after PHP 8.3 to 8.4 migration.
PHPStan version: 2.1.3

Reproducer:

<?php

class Foo
{
    public const string OPTION_ROUNDING_MODE = 'roundingMode';

    public function setRoundingMode(): void
    {
        $this->bar(self::OPTION_ROUNDING_MODE);
    }
}
     Internal error: Function roundingmode stub not found in                                                                                                                          
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/SignatureMap/../../../vendor/phpstan/php-8-stubs/stubs/ext/standard/RoundingMode.stub.                            
     while analysing file /app/src/Form/EasyAdmin/Field/DecimalField2.php                                                                                                             
     Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml:                                                                        
     ## phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/SignatureMap/Php8SignatureMapProvider.php(179)                                                                 
     #0 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/SignatureMap/NativeFunctionReflectionProvider.php(85):                                                         
     PHPStan\Reflection\SignatureMap\Php8SignatureMapProvider->getFunctionSignatures('roundingmode', NULL, NULL)                                                                      
     #1 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php(291):                                                            
     PHPStan\Reflection\SignatureMap\NativeFunctionReflectionProvider->findFunctionReflection('roundingMode')                                                                         
     #2 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php(363):                                                            
     PHPStan\Reflection\BetterReflection\BetterReflectionProvider->{closure:PHPStan\Reflection\BetterReflection\BetterReflectionProvider::resolveFunctionName():282}('roundingMode')  
     #3 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php(282):                                                            
     PHPStan\Reflection\BetterReflection\BetterReflectionProvider->resolveName(Object(PhpParser\Node\Name), Object(Closure), NULL)                                                    
     #4 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php(211):                                                            
     PHPStan\Reflection\BetterReflection\BetterReflectionProvider->resolveFunctionName(Object(PhpParser\Node\Name), NULL)                                                             
     #5 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php(60):                                                        
     PHPStan\Reflection\BetterReflection\BetterReflectionProvider->hasFunction(Object(PhpParser\Node\Name), NULL)                                                                     
     #6 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Type/Constant/ConstantStringType.php(172):                                                                                
     PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider->hasFunction(Object(PhpParser\Node\Name), NULL)                                                                
     #7 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(3779):                                                                                     
     PHPStan\Type\Constant\ConstantStringType->isCallable()                                                                                                                           
     #8 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2120):                                                                                     
     PHPStan\Analyser\NodeScopeResolver->processArgs(Object(PhpParser\Node\Stmt\Expression), Object(PHPStan\Reflection\ResolvedMethodReflection),                                     
     Object(PHPStan\Reflection\Php\PhpMethodReflection), Object(PHPStan\Reflection\ResolvedFunctionVariantWithOriginal),                                                              
     Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\ExpressionContext))                                     
     #9 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(730):                                                                                      
     PHPStan\Analyser\NodeScopeResolver->processExprNode(Object(PhpParser\Node\Stmt\Expression), Object(PhpParser\Node\Expr\MethodCall),                                              
     Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\ExpressionContext))                                                                             
     #10 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(456):                                                                                     
     PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Expression), Object(PHPStan\Analyser\MutatingScope),                                              
     Object(Closure), Object(PHPStan\Analyser\StatementContext))                                                                                                                      
     #11 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(653):                                                                                     
     PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\ClassMethod), Array, Object(PHPStan\Analyser\MutatingScope),                                     
     Object(Closure), Object(PHPStan\Analyser\StatementContext))                                                                                                                      
     #12 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(456):                                                                                     
     PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\ClassMethod), Object(PHPStan\Analyser\MutatingScope),                                             
     Object(PHPStan\Node\ClassStatementsGatherer), Object(PHPStan\Analyser\StatementContext))                                                                                         
     #13 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(793):                                                                                     
     PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Class_), Array, Object(PHPStan\Analyser\MutatingScope),                                          
     Object(PHPStan\Node\ClassStatementsGatherer), Object(PHPStan\Analyser\StatementContext))                                                                                         
     #14 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(456):                                                                                     
     PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Class_), Object(PHPStan\Analyser\MutatingScope),                                                  
     Object(Closure), Object(PHPStan\Analyser\StatementContext))                                                                                                                      
     #15 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(760):                                                                                     
     PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Namespace_), Array, Object(PHPStan\Analyser\MutatingScope),                                      
     Object(Closure), Object(PHPStan\Analyser\StatementContext))                                                                                                                      
     #16 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(404):                                                                                     
     PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Namespace_), Object(PHPStan\Analyser\MutatingScope),                                              
     Object(Closure), Object(PHPStan\Analyser\StatementContext))                                                                                                                      
     #17 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(162):                                                                                          
     PHPStan\Analyser\NodeScopeResolver->processNodes(Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))                                                                 
     #18 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(136):                                                                                          
     PHPStan\Analyser\FileAnalyser->analyseFile('/app/src/Form/E...', Array, Object(PHPStan\Rules\LazyRegistry),                                                                      
     Object(PHPStan\Collectors\Registry), NULL)                                                                                                                                       
     #19 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(111):                                                                   
     PHPStan\Command\WorkerCommand::{closure:PHPStan\Command\WorkerCommand::runWorker():117}(Array)                                                                                   
     #20 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/Decoder.php(117):                                                                               
     _PHPStan_d54478210\Evenement\EventEmitter->emit('data', Array)                                                                                                                   
     #21 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(111):                                                                   
     _PHPStan_d54478210\Clue\React\NDJson\Decoder->handleData(Array)                                                                                                                  
     #22 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.php(62):                                                                                        
     _PHPStan_d54478210\Evenement\EventEmitter->emit('data', Array)                                                                                                                   
     #23 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(111):                                                                   
     _PHPStan_d54478210\React\Stream\Util::{closure:_PHPStan_d54478210\React\Stream\Util::forwardEvents():61}('{"action":"anal...')                                                   
     #24 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/DuplexResourceStream.php(168):                                                                       
     _PHPStan_d54478210\Evenement\EventEmitter->emit('data', Array)                                                                                                                   
     #25 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201):                                                                       
     _PHPStan_d54478210\React\Stream\DuplexResourceStream->handleData(Resource id #6156)                                                                                              
     #26 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173):                                                                       
     _PHPStan_d54478210\React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)                                                                                                 
     #27 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(96):                                                                                           
     _PHPStan_d54478210\React\EventLoop\StreamSelectLoop->run()                                                                                                                       
     #28 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259):                                                                             
     PHPStan\Command\WorkerCommand->execute(Object(_PHPStan_d54478210\Symfony\Component\Console\Input\ArgvInput),                                                                     
     Object(_PHPStan_d54478210\Symfony\Component\Console\Output\ConsoleOutput))                                                                                                       
     #29 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(870):                                                                                 
     _PHPStan_d54478210\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_d54478210\Symfony\Component\Console\Input\ArgvInput),                                          
     Object(_PHPStan_d54478210\Symfony\Component\Console\Output\ConsoleOutput))                                                                                                       
     #30 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(261):                                                                                 
     _PHPStan_d54478210\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\WorkerCommand),                                                                    
     Object(_PHPStan_d54478210\Symfony\Component\Console\Input\ArgvInput),                                                                                                            
     Object(_PHPStan_d54478210\Symfony\Component\Console\Output\ConsoleOutput))                                                                                                       
     #31 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157):                                                                                 
     _PHPStan_d54478210\Symfony\Component\Console\Application->doRun(Object(_PHPStan_d54478210\Symfony\Component\Console\Input\ArgvInput),                                            
     Object(_PHPStan_d54478210\Symfony\Component\Console\Output\ConsoleOutput))                                                                                                       
     #32 phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(114): _PHPStan_d54478210\Symfony\Component\Console\Application->run()                                            
     #33 phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(115):                                                                                                            
     {closure:phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan:14}()                                                                                                       
     #34 /app/vendor/phpstan/phpstan/phpstan(8): require('phar:///app/ven...')                                                                                                        
     #35 /app/vendor/bin/phpstan(119): include('/app/vendor/php...')                                                                                                                  
     #36 {main}                                          

Code snippet that reproduces the problem

https://phpstan.org/r/18a729ea-2e2f-4614-b755-27002042998c

Expected output

No errors

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions