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

support nette/robot-loader@3.0 #304

Closed
wants to merge 1 commit into from
Closed

Conversation

adaamz
Copy link

@adaamz adaamz commented Aug 19, 2017

This change is Reviewable

@janatjak
Copy link
Contributor

There are two problems with robot loader 3.0 BC breaks

RobotLoader::setCacheStorage() is removed

$this->setCacheStorage($cacheStorage);

RobotLoader::$autoRebuild is private

$this->autoRebuild = TRUE;

@adaamz
Copy link
Author

adaamz commented Aug 19, 2017

yes i know, currently fixing it :-)

@adaamz
Copy link
Author

adaamz commented Aug 19, 2017

@janatjak i fixed those bc breaks. do you know why it is failing now?

@janatjak
Copy link
Contributor

@CzechBoy Check travis...

btw IMHO using "$path/temp" directory is not good idea, because:

  • there can be existing directory
  • script does not have write access to this folder (same cases)

One question: Is your code compatible with robot-loader <= 3.0? New BC break?

@adaamz
Copy link
Author

adaamz commented Aug 19, 2017

@janatjak Yes i know that it is not good idea for many reasons, but idk how to solve it in right way.
Upgrading will come from all libraries. Currently only phpstan requires robotloader>=3.0.2

And my app itself does not use robotloader.

@janatjak
Copy link
Contributor

V ramci urychleni prejdu do cestiny.
Dneska jsem resil presne tehle problem a docasne to vyresil takto:

composer.json

"nette/robot-loader": "3.0.2 as 2.4"

Nova class NewAnnotationDriver, ktera jen prohazuje parametry konstruktoru

class NewAnnotationDriver extends Doctrine\ORM\Mapping\Driver\AnnotationDriver
{
    public function __construct(array $paths, Reader $reader)
    {
        parent::__construct($reader, $paths);
    }
}

Ve vlastnim AppExtension prepisuji OrmExtension::$metadataDriverClasses pole, je ale potreba ho umistit v configu pred OrmExtension.

...
public function loadConfiguration()
{
    $ormExtension = $this->compiler->getExtensions(OrmExtension::class)['doctrine'];
    $ormExtension->metadataDriverClasses[OrmExtension::ANNOTATION_DRIVER] = NewAnnotationDriver::class;
}

@adaamz
Copy link
Author

adaamz commented Aug 19, 2017

Ano, jak píšeš dočasně. Chtěl bych problém vyřešit a nezaseknout celej balík jenom na jedný jednosouborový závislosti.
Ono by to šlo pořešit tak, že by se prostě vložil ten RobotLoader.php do balíčku celý z verze 2.4 (stejně už je vytvořený a používá se ten poděděný).

vhenzl added a commit to vhenzl-archive/phpstan-kdyby-doctrine that referenced this pull request Sep 14, 2017
Because of conflict in dependency on nette/robot-loader between PHPStan and Kdyby/Doctine (see Kdyby/Doctrine#304),
Kdyby package can't be installed.
@enumag
Copy link
Member

enumag commented Dec 3, 2017

I'm not quite sure why is RobotLoader even used in the AnnotationDriver. Do you guys know? I'd prefer to remove the RobotLoader dependency completely.

@enumag
Copy link
Member

enumag commented Dec 3, 2017

@Majkl578 Yeah I found that... But I don't understand the purpose. I think it's some autoloading for proxies but why is such a thing necessary?

@fprochazka
Copy link
Member

@enumag I'm not sure entirely, but IMHO RobotLoader was simply the easiest way to get all classes in the given path.

@@ -94,15 +95,20 @@ public function getFileExtensions()
*/
protected function findAllClasses($path)
{
$loader = new RobotLoader($this->cache !== NULL ? new ReversedStorageDecorator($this->cache) : new MemoryStorage());
$loader = new RobotLoader();
$loader->setTempDirectory("$path/temp");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly then this will create a temp dir in every directory configured for searching doctrine entities, right? The problem is that such directory can be set to read-only in production which is why I can't merge this PR.

@enumag enumag mentioned this pull request Dec 21, 2017
@JanGalek
Copy link
Contributor

so, we need get classes in path and remove dependency of nette/robot-loader ? We can try use Composer ClassLoader maybe ?

@Majkl578
Copy link
Member

You can't use Composer's classmap, it may not exist. But you can use similar approach Composer uses to scan directory for classes: https://github.com/composer/composer/blob/master/src/Composer/Autoload/ClassMapGenerator.php

@enumag
Copy link
Member

enumag commented Dec 21, 2017

@Majkl578 Still why is some custom autoloading for proxies needed? I mean even Doctrine's native implementation would load them when needed, right?

@JanGalek
Copy link
Contributor

@enumag ok you mean We should create Kdyby/Doctrine classLoader ?

@enumag
Copy link
Member

enumag commented Dec 21, 2017

@JanGalek I mean that I'd like to know why Doctrine's native implementation for proxies is not enough.

@JanGalek
Copy link
Contributor

JanGalek commented Dec 21, 2017

@enumag ok, I added log when it calls, and it calls with orm:info, I tried comments our loading and output is same. This is call in MappingDescribeCommand too

EDIT: orm:mapping:describe tested, and everything is same with and withou Kdyby AnnotationDriver method getAllClassNames

@enumag
Copy link
Member

enumag commented Dec 21, 2017

@JanGalek Can you check if this test passes with the native implementation?

@JanGalek
Copy link
Contributor

JanGalek commented Dec 21, 2017

@enumag I run test, fail:

actual

array(
	'KdybyTests\\Doctrine\\AnnotationDriver\\App\\Bar',
	'KdybyTests\\Doctrine\\AnnotationDriver\\App\\FooEntity',
	'KdybyTests\\Doctrine\\AnnotationDriver\\Something\\Baz',
)

expected

array(
	'KdybyTests\\Doctrine\\AnnotationDriver\\App\\FooEntity',
	'KdybyTests\\Doctrine\\AnnotationDriver\\Something\\Baz',
)

So I think that native not apply filter *Entity.php, maybe should call parent and return filtered ?

@JanGalek
Copy link
Contributor

JanGalek commented Dec 21, 2017

@enumag We need filter like path/to/file/*Entity.php ? , Native implementation find all classes with annotation @ORM\Entity.

@enumag
Copy link
Member

enumag commented Dec 21, 2017

@JanGalek Well apparently that's the reason for this. Whether we need it or not, personally I'd say no - it's a magic and if anyone needs it they can implement it outside of Kdyby/Doctrine. I'd like to simplify things in this package which in this case means to remove both the custom AnnotationDriver and robot-loader dependency.

@fprochazka @Majkl578 Your opinions?

@fprochazka
Copy link
Member

I'd consider dropping the custom AnnotationDriver. It solved a very rare edge-case. I don't think anyone depends on it.

@enumag
Copy link
Member

enumag commented Dec 21, 2017

Good. Now I'm not talking to anyone in particular but if someone could send a PR with removal of AnnotationDriver and robot-loader it would be great. Please target the newly created branch v3.3.

@enumag
Copy link
Member

enumag commented Jan 11, 2018

Closed by #311.

@enumag enumag closed this Jan 11, 2018
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 this pull request may close these issues.

6 participants