Skip to content

2.1.0 - Detect Behaviors methods on Tables

Choose a tag to compare

@raul338 raul338 released this 25 Mar 02:35

This only works if the method name is not modified in implementedMethods. Otherwise the analysis may be wrong, or
you'll have to decorate your code with dockblocks

/**
 * @mixin \Cake\ORM\Behavior\TimestampBehavior
 */
public class UsersTable extends Table
{
    public function initialize(array $config)
    {
        parent::initialize($config);
        $this->addBehavior('Timestamp');
    }
}

// somewhere else - phpstan will know its the Timestamp touch method
$this->Users->touch($user);