Question on PhpStorm Advanced Metadata
Assume the following code/files
<?php namespace PHPSTORM_META { // we want to avoid the pollution
$STATIC_METHOD_TYPES = [ // we make sections for scopes \Load::Component('') => [ // call to match
'Filter' instanceof \FilterComponent, ], 'Filter' instanceof \FilterComponent, ] ]; } |
filter.php
<?php classFilterComponent extends Component {
function getDate($returnStyle = null){
$date = strtotime('Today'); } } |
component.php
<?php class Component {
protected function component($objName){
}
|
testUsage.php
<?php class TestComponent extends Component {
function test() {
$date = $this->component('Filter')->getDate('java');
} } |
In the testUsage.php file, the first call in the test function, $this->component('Filter')->getDate('java'); PhpStorm will say "cannot find declaration to go to" for getDate()
However it will work in the 2nd call, Load::component('Filter')->getDate('java');
Is there any possible way for me to get this to work with the 1st call?
Please sign in to leave a comment.
Hi there,
ATM PhpStorm supports static factories only (
I'm not sure about " (how exactly it will work/what syntax has to be used) but such support for not-static factories was added in most recent v9 EAP build. Unfortunately there is no documentation yet available (but expected soon).
In any case -- it will be supported in v9 when it will be released (some point in July).
Actually -- documentation was updated: https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata
Just those example metadata file uses truff like "$factory->component()" while you have "$this->component()" -- not sure how it supposed to be declared here...