php-kafka / php-avro-schema-generator

PHP avro subschema merger and experimental PHP Class avro schema generator
BSD 3-Clause "New" or "Revised" License
5 stars 5 forks source link

ParserClass do not resolve parent classes without use statements #38

Open Hubbitus opened 2 years ago

Hubbitus commented 2 years ago
$registry = (new ClassRegistry($converter))
            ->addClassDirectory($this->projectDir . '/vendor/pimcore/pimcore/lib/Loader/')
                ->load();

And I have got error:

In ClassParser.php line 197:                                                  
  Class "AbstractClassNameLoader" does not exist  

Problem happened on class declaration starting from:

<?php

declare(strict_types = 1);

namespace Pimcore\Loader\ImplementationLoader;

class ClassMapLoader extends AbstractClassNameLoader
{
...

Class AbstractClassNameLoader indeed did not listed in the use statements, but that present in the same namespace and directory.

Hubbitus commented 2 years ago

At master branch 32d5b78be50ba2ef6fb89334cea8646cce895c12

Hubbitus commented 2 years ago

Please wait and do not merge request!

Hubbitus commented 2 years ago

Situation became even worst, please look at the class Pimcore\Model\Listing\Dao\AbstractDao:

<?php

namespace Pimcore\Model\Listing\Dao;

use Pimcore\Model;

abstract class AbstractDao extends Model\Dao\AbstractDao
{

There use Pimcore\Model; is not class use, but namespace! And class extend the same-named class from another namespace!

So, I see only single robust solution to resolve all such cases - use reflection instead of parsing...

nick-zh commented 2 years ago

Good find, i agree, this is probably the best way to go :+1:

Hubbitus commented 2 years ago

Meantime that may be slow sometimes...

nick-zh commented 2 years ago

I think that's an acceptable trade off, since this is not something that needs to be super fast but accurate. Impact should be negligible 😁