Skip to content

Commit

Permalink
Add annotations for missing methods to interfaces.
Browse files Browse the repository at this point in the history
This prevents static analyzers like phpstan complaining when an argument is
typehinted as interface and a method used on object is not present in the interface.

Closes #11051
  • Loading branch information
ADmad committed Aug 19, 2017
1 parent 5b082ca commit 7544a08
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/Datasource/EntityInterface.php
Expand Up @@ -37,6 +37,8 @@
* @method bool isAccessible($property)
* @method $this setSource($source)
* @method array getSource()
* @method array extractOriginal(array $properties)
* @method array extractOriginalChanged(array $properties)
*
* @property mixed $id Alias for commonly used primary key.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Datasource/QueryInterface.php
Expand Up @@ -18,7 +18,7 @@
/**
* The basis for every query object
*
* @package Cake\Datasource
* @method $this andWhere($conditions, $types = [])
*/
interface QueryInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Association.php
Expand Up @@ -947,7 +947,7 @@ public function attachTo(Query $query, array $options = [])
* Conditionally adds a condition to the passed Query that will make it find
* records where there is no match with this association.
*
* @param \Cake\ORM\Query $query The query to modify
* @param \Cake\Datasource\QueryInterface $query The query to modify
* @param array $options Options array containing the `negateMatch` key.
* @return void
*/
Expand Down
5 changes: 2 additions & 3 deletions src/ORM/Behavior/CounterCacheBehavior.php
Expand Up @@ -18,7 +18,6 @@
use Cake\Event\Event;
use Cake\ORM\Association;
use Cake\ORM\Behavior;
use Cake\ORM\Entity;

/**
* CounterCache behavior
Expand Down Expand Up @@ -199,12 +198,12 @@ protected function _processAssociations(Event $event, EntityInterface $entity)
* Updates counter cache for a single association
*
* @param \Cake\Event\Event $event Event instance.
* @param \Cake\ORM\Entity $entity Entity
* @param \Cake\Datasource\EntityInterface $entity Entity
* @param \Cake\ORM\Association $assoc The association object
* @param array $settings The settings for for counter cache for this association
* @return void
*/
protected function _processAssociation(Event $event, Entity $entity, Association $assoc, array $settings)
protected function _processAssociation(Event $event, EntityInterface $entity, Association $assoc, array $settings)
{
$foreignKeys = (array)$assoc->getForeignKey();
$primaryKeys = (array)$assoc->getBindingKey();
Expand Down
4 changes: 2 additions & 2 deletions src/ORM/Marshaller.php
Expand Up @@ -159,7 +159,7 @@ protected function _buildPropertyMap($data, $options)
*
* @param array $data The data to hydrate.
* @param array $options List of options
* @return \Cake\ORM\Entity
* @return \Cake\Datasource\EntityInterface
* @see \Cake\ORM\Table::newEntity()
* @see \Cake\ORM\Entity::$_accessible
*/
Expand All @@ -169,7 +169,7 @@ public function one(array $data, array $options = [])

$primaryKey = (array)$this->_table->getPrimaryKey();
$entityClass = $this->_table->getEntityClass();
/* @var \Cake\ORM\Entity $entity */
/* @var \Cake\Datasource\EntityInterface $entity */
$entity = new $entityClass();
$entity->setSource($this->_table->getRegistryAlias());

Expand Down

0 comments on commit 7544a08

Please sign in to comment.