Help with PhpStorm advanced metadata

Hi,

I can't undertand why PhpStorm advanced metadata is not working for me. Any help would be appreciated.

Version :PHPStorm 2018.3.3, IDE restarted

 

.phpstorm.meta.php\mea.meta.php

<?php
// https://www.jetbrains.com/help/phpstorm/ide-advanced-metadata.html
namespace PHPSTORM_META {
override(\Doctrine\ORM\EntityManagerInterface::getReference(0), map([
'' => '@',
]));
}

The hint is always \Doctrine\Common\Proxy\Proxy|object

Thanks

 

12 comments

That's hard to say without having a look at the actual project. Could you please share it?

0

Thank you for your reply. I deduce from your answer that the code in my question is correct. I can't share the whole project with you, but will create a POC to depict the problem during the weekend.

Best regards

0

I don't see any syntax issues, but it's still possible that there are some. Looking forward to a reproducible sample. Thank you!

0

Eugene,

Here is a link to download a tiny project with the problem : https://we.tl/t-CAylrG68qN

The project contains 3 sources and a composer.json to download Doctrine vendor sources. Check CompanyManager.php file as below to see the error.

Thank you

0

Sebastien, PhpStorm is not able to pick up the intended type behind 'CompanyActorBundle:CompanyType', and to be honest, neither am I. What type should getReference() return?

Please note that @ in the metadata should be something resolvable.

0

Eugene,

Thank you for your answer, you point me the right problem : the class reference is a Doctrine alias. So 'CompanyActorBundle:OptionActor' will be resolved by Doctrine as 'Company\ActorBundle\Entity\OptionActor'.

Is there a way to use PhpStorm advanced metadata to rewrite 'CompanyActorBundle:OptionActor' to 'Company\ActorBundle\Entity\OptionActor' without defining every entities in the map? I mean, something dynamic to be easily reusable?

It is working if the fully qualified name is used (something resolvable :o)

Best regards

0

Another quick question,

I adapt the solution above in my project, but got strange behavior if I don't explicitly cast the constant value which is already an integer. Do you know why?

Best regards

0

Is there a way to use PhpStorm advanced metadata to rewrite 'CompanyActorBundle:OptionActor' to 'Company\ActorBundle\Entity\OptionActor' without defining every entities in the map?

Currently, no, as we don't even support Doctrine aliases. Here's a request for that: https://youtrack.jetbrains.com/issue/WI-44664

I suppose once we have references bind to such strings, metadata would also start working, but that's not for sure.

I mean, something dynamic to be easily reusable?

Metadata pattern syntax is pretty basic, you can only use the whole parameter, either as whole or as a part of something else. You can't parse the parameter in any way. https://youtrack.jetbrains.com/issue/WI-27832

I adapt the solution above in my project, but got strange behavior if I don't explicitly cast the constant value which is already an integer. Do you know why?

I don't have this warning on the call. Please hover the pointer over it and take a screenshot of the exact inspection message.

0

Eugene,

Thank your very much for your answer.

Here is another screen shot. I really don't understand why I need to cast the constant.

Best regards

Sébastien

0

The project you shared doesn't have the LinkCompanyTypeToCompany class, so I can't reproduce that locally.
Is there a chance you could share the whole project?

0

Eugene,

No, unfortunately I can't share the project. I don't think this problem is related to the project because as you can see in the image, there is no reason than the constant used without casting doesn't invoke the custom meta data isn't it?

Or am I doing something wrong?

Best regards

<?php
// https://www.jetbrains.com/help/phpstorm/ide-advanced-metadata.html
namespace PHPSTORM_META {
override(\Doctrine\ORM\EntityManagerInterface::getReference(0), map([
'' => '@',
]));
}
0

The thing is that the second and etc parameters should not affect metadata usage in any way - it's only the first parameter that counts: https://youtrack.jetbrains.com/issue/WI-32168

Thus, I can't reproduce that, and I need a reproducible sample to qualify the bug somehow.

0

Please sign in to leave a comment.