Skip to content

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

Description

@petrparolek

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
{

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions