0

When run PHPStan for CakePHP3 app, Call to an undefined method errors always occurs in the lines using CakePHP3 Dynamic Finders

How do I remove errors like dynamic methods?

/**
 * @property \App\Model\Table\ArticlesTable $Articles
 */
class ArticlesController extends AppController
{
    public function view($slug = null)
    {
        $article = $this->Articles->findBySlug($slug)->firstOrFail();
        $this->set(compact('article'));
    }
------ ---------------------------------------------------------------------------- 
  Line   Controller/ArticlesController.php                                           
 ------ ---------------------------------------------------------------------------- 
  58     Call to an undefined method App\Model\Table\ArticlesTable::findBySlug().    
 ...
masy
  • 23
  • 3

1 Answers1

1

The concept of magic properties and methods is understood by PHPStan with the help of so-called class reflection extensions. See Docs for more details.

Lex
  • 4,749
  • 3
  • 45
  • 66
Ondřej Mirtes
  • 5,054
  • 25
  • 36