Access to an undefined property App\Forms\SomeForm::$presenter is not shown

Open Beginner friendly
#213 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
php
Domain
tooling

Research direction

Start with the reproducer in the issue and inspect stubs/Application/UI/Component.stub, which is identified as the possible solution. Verify the undefined-property diagnostic for SomeForm::$presenter, then update the stub so the expected error is reported and rerun the reproduction to confirm the result.

Written by the indexing model from the issue text.

Description

Versions:
phpstan/phpstan-nette: 2.0.12
nette/application: 3.3.0

Bug Description

Error is not shown.

Steps To Reproduce
<?php declare(strict_types = 1);

namespace App\Forms;

use Nette\Application\UI\Control;
use Nette\Application\UI\Form;

final class SomeForm extends Control
{

	public function render(): void
	{
		$this->getTemplate()->setFile(__DIR__ . '/someForm.latte')
			->render();
	}

	protected function createComponentSomeForm(): Form
	{
		$form = new Form();

		$form->addSubmit('edit', 'OK');

		$form->onSuccess[] = function (Form $form, array $values): void {
			$this->presenter->redirect('this')
		};

		return $form;
	}

}


Expected error:
 ------ -------------------------------------------------------------------------------------------------------- 
  Line   app/Forms/SomeForm.php                                           
 ------ -------------------------------------------------------------------------------------------------------- 
  24    Access to an undefined property App\\Forms\SomeForm::$presenter.  
         🪪  property.notFound                                                                                   
         💡  Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                   
 ------ -------------------------------------------------------------------------------------------------------- 

Possible Solution

update stub file in stubs/Application/UI/Component.stub

<?php

namespace Nette\Application\UI;

/**
 * @property-deprecated Presenter $presenter
 * @property-read bool $linkCurrent
 * @phpstan-implements \ArrayAccess<string, \Nette\ComponentModel\IComponent>
 */
abstract class Component implements \ArrayAccess
{

}
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.