Call to undefined method when using Nette Events

Open
#29 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
php
Domain
tooling

Research direction

Start by reproducing the reported PHPStan error with the CommonTrait example, Nette 2.4, and the Nette extension. Compare the extension's handling of the SmartObject event pattern with the reported onUpdate call; done means the example no longer reports an undefined method.

Written by the indexing model from the issue text.

Description

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.

Dominant language
PHP
Stars
118
Forks
44
Avg merge
17d 5h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from phpstan/phpstan-nette

All issues in phpstan/phpstan-nette

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.