core: ReflectionException: Class not found

API Platform version(s) affected: 2.5.4 (from commit https://github.com/api-platform/core/commit/baf054234eff3b9276b6783efb825bff7099d5c9)

Description / How to reproduce
Loading the api docs causes several “class not found” ReflectionExceptions. Screenshot from 2020-01-20 13-53-51 Possibly related to https://github.com/api-platform/core/issues/3344

Possible Solution
Seems to be related to src/JsonSchema/TypeFactory:102. If the check in changed from and to or, everything works (working example below)

        if ($this->isResourceClass($className) || true !== $readableLink) {
            return [
                'type' => 'string',
                'format' => 'iri-reference',
            ];
        }

Unfortunately I don’t know the internals enough to know if this breaks anything.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 27 (13 by maintainers)

Commits related to this issue

Most upvoted comments

I proposed a fix: https://github.com/symfony/symfony/pull/40874

However, there is a workaround for the Knp\DoctrineBehaviors case only, import directly the trait imported by the main one.

In a nutshell:

use Knp\DoctrineBehaviors\Model\Translatable\TranslatableMethodsTrait;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatablePropertiesTrait;

class Accounting implements TranslatableInterface
{
    use TranslatablePropertiesTrait;
    use TranslatableMethodsTrait;
}

Hope it helps!

@soyuka Do you have some news about this issue ? Because i tried to used https://github.com/KnpLabs/DoctrineBehaviors/blob/master/docs/translatable.md and i have : Class App\Entity\TranslationInterface does not exist

Symfony : 5.0.9 API Platform : 2.5.6

error

FYi, I’ve got a funny one, because of that error in a vendor @return Returns blablablab:

https://github.com/KnpLabs/DoctrineBehaviors/blob/9cc036ee32483c306fb32b4efbf33014ddfb654f/src/Model/Translatable/TranslatableMethods.php#L149

I got errors like

In SchemaFactory.php line 216:
                                                                  
  Class Lib\Core\Entity\Catalog\Reference\Returns does not exist  

Because in a class in namespace Lib\Core\Entity\Catalog\Reference i’ve a use TranslatableTrait which use TranslatableMethods

nevermind I got to reproduce the bug! thanks

So, I tracked the bugs to php documentor I’ll open issues their regarding these issues.

In the mean time you should use the FQDN in the Trait property… I’ll try to find a quicker solution to these problems.