I have a class which includes a file in a method like below:
In class.php file:
class A {
const CONST1 = 5;
/** @var int $a */
var $a = 5;
public function call()
{
include( 'b.php' );
}
public function do_some_magic()
{
// magic stuff...
}
public static function static_func()
{
// some code...
}
}
file b.php:
<?php
/** @var A $this */
/** @var A self */ // This doesn't work
$this->do_some_magic();
echo '['.$this->a.']';
self::static_func();
echo '['.self::CONST1.']';
I use PhpStorm as IDE and in b.php file if I want to go to definition of do_some_magic() or definition of a variable it will correctly go to corresponding method or variable definition in class.php file, but if I want to go to definition of constant CONST1 or to definition of static method static_func() it says "Cannot find definition to go to", so I think /** @var A self */ is not a valid notation in included file.
My question is: Is there any way in PhpDoc to tell IDE of what type self is in included file?
include()within a class method?