phpstan-nette icon indicating copy to clipboard operation
phpstan-nette copied to clipboard

Call to undefined method when using Nette Events

Open Lukeluha opened this issue 7 years ago • 1 comments

I am trying to use phpstan with nette and I have a problem with not recognizing Nette Events (even if this should be supported according to README).

My code looks like this:

trait CommonTrait
{
	use SmartObject;

	/** @var array  */
	public $onUpdate = [];
...
        public function insert($data) {
                ...
                $this->onUpdate($data);
        }

But after running PHP stan with Nette extension I am getting these errors: Call to an undefined method App\Model\Db\Languages::onUpdate() And it is the same with other classes using this trait.

I am using Nette 2.4 and the latest PHPStan shim and I have tried that the Nette extension loads correctly.

Lukeluha avatar Oct 04 '18 07:10 Lukeluha

This should work, but I'm not sure if it works with traits correctly. Feel free to debug the issue. The class responsible for this is: https://github.com/phpstan/phpstan-nette/blob/master/src/Reflection/Nette/NetteObjectClassReflectionExtension.php

ondrejmirtes avatar Dec 19 '18 12:12 ondrejmirtes