Skip to content

Commit

Permalink
Fix errors reported by phpstan.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Apr 17, 2018
1 parent e53ffa7 commit f9fc464
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
15 changes: 8 additions & 7 deletions .travis.yml
Expand Up @@ -19,37 +19,38 @@ matrix:
fast_finish: true

include:
- php: 7.0
- php: 7.1
env: PHPCS=1 DEFAULT=0

- php: 7.0
- php: 7.1
env: PHPSTAN=1 DEFAULT=0

- php: 5.6
env: PREFER_LOWEST=1

before_script:
- if [[ $TRAVIS_PHP_VERSION != 7.0 ]]; then phpenv config-rm xdebug.ini; fi
- if [[ $TRAVIS_PHP_VERSION != 7.1 ]]; then phpenv config-rm xdebug.ini; fi

- if [[ $PREFER_LOWEST != 1 ]]; then composer update --no-interaction ; fi
- if [[ $PREFER_LOWEST == 1 ]]; then composer update --no-interaction --prefer-lowest --prefer-stable; fi

- if [[ $PHPSTAN = 1 ]]; then composer require phpstan/phpstan; fi

- if [[ $DB = 'mysql' ]]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi
- if [[ $DB = 'pgsql' ]]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi

- if [[ $PHPCS = 1 ]]; then composer require cakephp/cakephp-codesniffer:"^3.0"; fi
- if [[ $PHPSTAN = 1 ]]; then composer require phpstan/phpstan; fi

script:
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.0 ]]; then vendor/bin/phpunit; fi
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.1 ]]; then vendor/bin/phpunit; fi
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.1 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi

- if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs -n -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi

- if [[ $PHPSTAN = 1 ]]; then vendor/bin/phpstan analyse -c phpstan.neon -l 5 src; fi

after_success:
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then bash <(curl -s https://codecov.io/bash); fi
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.1 ]]; then bash <(curl -s https://codecov.io/bash); fi

notifications:
email: false
8 changes: 5 additions & 3 deletions src/Model/Behavior/TrashBehavior.php
Expand Up @@ -106,7 +106,7 @@ public function beforeDelete(Event $event, EntityInterface $entity, ArrayObject
$event->stopPropagation();

/** @var \Cake\ORM\Table $table */
$table = $event->subject();
$table = $event->getSubject();
$table->dispatchEvent('Model.afterDelete', [
'entity' => $entity,
'options' => $options,
Expand All @@ -127,8 +127,10 @@ public function trash(EntityInterface $entity, array $options = [])
{
$primaryKey = (array)$this->_table->getPrimaryKey();

if (!$entity->has($primaryKey)) {
throw new RuntimeException();
foreach ($primaryKey as $field) {
if (!$entity->has($field)) {
throw new RuntimeException();
}
}

foreach ($this->_table->associations() as $association) {
Expand Down

0 comments on commit f9fc464

Please sign in to comment.