Skip to content

class not found on class-constants #7365

@staabm

Description

@staabm

Bug report

Stacktrace:

-------------------------------------------------------------------------------------------------------------------
     Error
 -- -------------------------------------------------------------------------------------------------------------------
     Internal error: Internal error: Class "Fare_Warengruppen" not found in file
     C:\dvl\Workspace\fare\application\fare.deRocket\controllers\DbhController.php

     Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md:
     #0
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-re
     flection/src/SourceLocator/SourceStubber/ReflectionSourceStubber.php(294):
     ReflectionClass->getDefaultProperties()
     #1
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-re
     flection/src/SourceLocator/SourceStubber/ReflectionSourceStubber.php(97):
     PHPStan\BetterReflection\SourceLocator\SourceStubber\ReflectionSourceStubber->addProperties()
     #2
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflecti
     on/SourceLocator/ReflectionClassSourceLocator.php(37):
     PHPStan\BetterReflection\SourceLocator\SourceStubber\ReflectionSourceStubber->generateClassStub()
     #3
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflecti
     on/SourceLocator/AutoloadFunctionsSourceLocator.php(37):
     PHPStan\Reflection\BetterReflection\SourceLocator\ReflectionClassSourceLocator->locateIdentifier()
     #4
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-re
     flection/src/SourceLocator/Type/AggregateSourceLocator.php(28):
     PHPStan\Reflection\BetterReflection\SourceLocator\AutoloadFunctionsSourceLocator->locateIdentifier()
     #5
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-re
     flection/src/SourceLocator/Type/MemoizingSourceLocator.php(33):
     PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator->locateIdentifier()
     #6
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-re
     flection/src/Reflector/DefaultReflector.php(32):
     PHPStan\BetterReflection\SourceLocator\Type\MemoizingSourceLocator->locateIdentifier()
     #7
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflecti
     on/Reflector/MemoizingReflector.php(45): PHPStan\BetterReflection\Reflector\DefaultReflector->reflectClass()
     #8
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflecti
     on/BetterReflectionProvider.php(166):
     PHPStan\Reflection\BetterReflection\Reflector\MemoizingReflector->reflectClass()
     #9
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProv
     ider/MemoizingReflectionProvider.php(43):
     PHPStan\Reflection\BetterReflection\BetterReflectionProvider->getClass()
     #10
     C:\dvl\Workspace\fare\vendor-bin\phpstan\vendor\phpstan\phpstan-deprecation-rules\src\Rules\Deprecations\Implemen
     tationOfDeprecatedInterfaceRule.php(42):
     PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider->getClass()
     #11
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php
     (102): PHPStan\Rules\Deprecations\ImplementationOfDeprecatedInterfaceRule->processNode()
     #12
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolve
     r.php(380): PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}()
     #13
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolve
     r.php(296): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
     #14
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php
     (189): PHPStan\Analyser\NodeScopeResolver->processNodes()
     #15
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php
     (143): PHPStan\Analyser\FileAnalyser->analyseFile()
     #16
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/sr
     c/Evenement/EventEmitterTrait.php(97): PHPStan\Command\WorkerCommand->PHPStan\Command\{closure}()
     #17
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/
     Decoder.php(110): _PHPStan_9df114220\Evenement\EventEmitter->emit()
     #18
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/sr
     c/Evenement/EventEmitterTrait.php(97): _PHPStan_9df114220\Clue\React\NDJson\Decoder->handleData()
     #19
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.
     php(62): _PHPStan_9df114220\Evenement\EventEmitter->emit()
     #20
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/sr
     c/Evenement/EventEmitterTrait.php(97):
     _PHPStan_9df114220\React\Stream\Util::_PHPStan_9df114220\React\Stream\{closure}()
     #21
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Duple
     xResourceStream.php(154): _PHPStan_9df114220\Evenement\EventEmitter->emit()
     #22
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/S
     treamSelectLoop.php(201): _PHPStan_9df114220\React\Stream\DuplexResourceStream->handleData()
     #23
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/S
     treamSelectLoop.php(173): _PHPStan_9df114220\React\EventLoop\StreamSelectLoop->waitForStreamActivity()
     #24
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php
     (106): _PHPStan_9df114220\React\EventLoop\StreamSelectLoop->run()
     #25
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Comman
     d/Command.php(259): PHPStan\Command\WorkerCommand->execute()
     #26
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Applic
     ation.php(856): _PHPStan_9df114220\Symfony\Component\Console\Command\Command->run()
     #27
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Applic
     ation.php(259): _PHPStan_9df114220\Symfony\Component\Console\Application->doRunCommand()
     #28
     phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Applic
     ation.php(157): _PHPStan_9df114220\Symfony\Component\Console\Application->doRun()
     #29 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(120):
     _PHPStan_9df114220\Symfony\Component\Console\Application->run()
     #30 phar://C:/dvl/Workspace/fare/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(121):
     _PHPStan_9df114220\{closure}()
     #31 C:\dvl\Workspace\fare\vendor-bin\phpstan\vendor\phpstan\phpstan\phpstan(8): require('...')
     #32 C:\dvl\Workspace\fare\vendor\bin\phpstan(117): include('...')
     #33 {main}
     Child process error (exit code 1):

code in question looks like

<?php


class DbhController 
{
    protected $warengruppenid = [
        Fare_Warengruppen::WARENGRUPPE_STOCKSCHIRME,
        Fare_Warengruppen::WARENGRUPPE_TASCHENSCHIRME,
    ];
}

Code snippet that reproduces the problem

I am in the process of creating a repro repo

Expected output

no error

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