Skip to content

Commit 06094b5

Browse files
committed
Fix errors reported by phpstan.
1 parent 6206c17 commit 06094b5

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ matrix:
2727
before_script:
2828
- if [[ $TRAVIS_PHP_VERSION != 7.0 ]]; then phpenv config-rm xdebug.ini; fi
2929

30-
- if [[ $PHPSTAN = 1 ]]; then composer require --dev phpstan/phpstan; fi
30+
- if [[ $PHPSTAN = 1 ]]; then composer require --dev phpstan/phpstan:^0.9; fi
3131
- if [[ $PHPSTAN != 1 ]]; then composer install --no-interaction; fi
3232

3333
script:

src/Marshaller.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,23 @@ public function one(array $data, array $options = [])
106106
*/
107107
protected function _validate($data, $options, $isNew)
108108
{
109-
if (!$options['validate']) {
110-
return [];
111-
}
109+
$validator = null;
110+
112111
if ($options['validate'] === true) {
113-
$options['validate'] = $this->_endpoint->getValidator('default');
112+
$validator = $this->_endpoint->getValidator('default');
113+
} elseif (is_string($options['validate'])) {
114+
$validator = $this->_endpoint->getValidator($options['validate']);
115+
} elseif (is_object($options['validate'])) {
116+
$validator = $options['validate'];
114117
}
115-
if (is_string($options['validate'])) {
116-
$options['validate'] = $this->_endpoint->getValidator($options['validate']);
117-
}
118-
if (!is_object($options['validate'])) {
118+
119+
if ($validator === null) {
119120
throw new RuntimeException(
120121
sprintf('validate must be a boolean, a string or an object. Got %s.', gettype($options['validate']))
121122
);
122123
}
123124

124-
return $options['validate']->errors($data, $isNew);
125+
return $validator->errors($data, $isNew);
125126
}
126127

127128
/**

src/Model/Endpoint.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414
use Cake\Event\EventDispatcherTrait;
1515
use Cake\Event\EventListenerInterface;
1616
use Cake\Event\EventManager;
17-
use Cake\Network\Exception\NotImplementedException;
1817
use Cake\Utility\Inflector;
1918
use Cake\Validation\ValidatorAwareTrait;
2019
use Muffin\Webservice\Exception\MissingResourceClassException;
2120
use Muffin\Webservice\Exception\UnexpectedDriverException;
2221
use Muffin\Webservice\Marshaller;
2322
use Muffin\Webservice\Query;
2423
use Muffin\Webservice\Schema;
25-
use Muffin\Webservice\StreamQuery;
2624

2725
/**
2826
* The table equivalent of a webservice endpoint

0 commit comments

Comments
 (0)