From 5fb8ba14c3ab52ec74e3960b6bc8764050e2ade6 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 28 Jul 2019 20:44:28 +0530 Subject: [PATCH] Fix issues reported by phpstan. --- .travis.yml | 7 +++++++ phpstan.neon | 5 +++++ src/Model/Behavior/UploadBehavior.php | 6 +++--- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 phpstan.neon diff --git a/.travis.yml b/.travis.yml index 3cf305e1..85bc5bc1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,9 @@ matrix: - php: 7.3 env: PHPCS=1 DEFAULT=0 + - php: 7.3 + env: STATIC_ANALYSIS=1 DEFAULT=0 + - php: 5.6 env: PREFER_LOWEST=1 @@ -34,6 +37,8 @@ before_script: - 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 [[ $STATIC_ANALYSIS = 1 ]]; then composer require --dev phpstan/phpstan-shim:^0.11; fi + script: - | if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.3 ]]; then @@ -45,6 +50,8 @@ script: - if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs -n -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi + - if [[ $STATIC_ANALYSIS = 1 ]]; then vendor/bin/phpstan.phar analyse src/; fi + after_success: - | if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.3 ]]; then diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 00000000..94d8acda --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: 5 + ignoreErrors: + - '#Constant ROOT not found#' + - '#Parameter \#2 \$options of static method Cake\\Utility\\Text::slug\(\) expects array, string given#' diff --git a/src/Model/Behavior/UploadBehavior.php b/src/Model/Behavior/UploadBehavior.php index 55d35899..07bbbbce 100644 --- a/src/Model/Behavior/UploadBehavior.php +++ b/src/Model/Behavior/UploadBehavior.php @@ -123,7 +123,7 @@ public function beforeSave(Event $event, Entity $entity, ArrayObject $options) * @param \Cake\Event\Event $event The afterDelete event that was fired * @param \Cake\ORM\Entity $entity The entity that was deleted * @param \ArrayObject $options the options passed to the delete method - * @return void|false + * @return bool */ public function afterDelete(Event $event, Entity $entity, ArrayObject $options) { @@ -167,7 +167,7 @@ public function afterDelete(Event $event, Entity $entity, ArrayObject $options) * @param array $data the data being submitted for a save * @param string $field the field for which data will be saved * @param array $settings the settings for the current field - * @return \Josegonzalez\Upload\File\Path\AbstractProcessor + * @return \Josegonzalez\Upload\File\Path\ProcessorInterface */ public function getPathProcessor(Entity $entity, $data, $field, $settings) { @@ -190,7 +190,7 @@ public function getPathProcessor(Entity $entity, $data, $field, $settings) * @param array $data the data being submitted for a save * @param string $field the field for which data will be saved * @param array $settings the settings for the current field - * @return \Josegonzalez\Upload\File\Path\AbstractProcessor + * @return \Josegonzalez\Upload\File\Writer\WriterInterface */ public function getWriter(Entity $entity, $data, $field, $settings) {