Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParserClass do not resolve parent classes without use statements #38

Open
Hubbitus opened this issue Jan 5, 2022 · 6 comments · May be fixed by #39
Open

ParserClass do not resolve parent classes without use statements #38

Hubbitus opened this issue Jan 5, 2022 · 6 comments · May be fixed by #39

Comments

@Hubbitus
Copy link
Contributor

Hubbitus commented Jan 5, 2022

$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
Copy link
Contributor Author

Hubbitus commented Jan 5, 2022

At master branch 32d5b78

@Hubbitus
Copy link
Contributor Author

Hubbitus commented Jan 5, 2022

Please wait and do not merge request!

@Hubbitus
Copy link
Contributor Author

Hubbitus commented Jan 5, 2022

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...

Hubbitus pushed a commit to Hubbitus/php-avro-schema-generator that referenced this issue Jan 5, 2022
@nick-zh
Copy link
Member

nick-zh commented Jan 5, 2022

Good find, i agree, this is probably the best way to go 👍

@Hubbitus
Copy link
Contributor Author

Hubbitus commented Jan 5, 2022

Meantime that may be slow sometimes...

@nick-zh
Copy link
Member

nick-zh commented Jan 6, 2022

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 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants