Skip to content

Commit d91ae04

Browse files
authored
Merge pull request #45 from UseMuffin/phpstan
Run phpstan checks.
2 parents b0bfe90 + 316fcb5 commit d91ae04

File tree

6 files changed

+24
-9
lines changed

6 files changed

+24
-9
lines changed

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,23 @@ matrix:
2121
- php: 7.0
2222
env: PHPCS=1 DEFAULT=0
2323

24+
- php: 7.0
25+
env: PHPSTAN=1 DEFAULT=0
26+
2427
before_script:
2528
- if [[ $TRAVIS_PHP_VERSION != 7.0 ]]; then phpenv config-rm xdebug.ini; fi
2629

27-
- composer install --prefer-dist --no-interaction
30+
- if [[ $PHPSTAN = 1 ]]; then composer require --dev phpstan/phpstan; fi
31+
- if [[ $PHPSTAN != 1 ]]; then composer install --no-interaction; fi
2832

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

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

39+
- if [[ $PHPSTAN = 1 ]]; then vendor/bin/phpstan analyse -l 2 src; fi
40+
3541
after_success:
3642
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then bash <(curl -s https://codecov.io/bash); fi
3743

src/Connection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
class Connection
1010
{
11+
/**
12+
* Driver
13+
*
14+
* @var \Muffin\Webservice\AbstractDriver
15+
*/
16+
protected $_driver;
17+
1118
/**
1219
* Constructor
1320
*

src/Marshaller.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use ArrayObject;
55
use Cake\Collection\Collection;
66
use Cake\Datasource\EntityInterface;
7+
use Cake\Datasource\InvalidPropertyInterface;
78
use Muffin\Webservice\Model\Endpoint;
89
use RuntimeException;
910

@@ -211,7 +212,7 @@ public function merge(EntityInterface $entity, array $data, array $options = [])
211212
$properties = [];
212213
foreach ($data as $key => $value) {
213214
if (!empty($errors[$key])) {
214-
if (method_exists($entity, 'invalid')) {
215+
if ($entity instanceof InvalidPropertyInterface) {
215216
$entity->invalid($key, $value);
216217
}
217218
continue;

src/Model/Endpoint.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,11 @@ public function endpoint($endpoint = null)
231231
*/
232232
public function alias($alias = null)
233233
{
234-
if ($alias === null) {
235-
return $this->_alias;
234+
if ($alias !== null) {
235+
$this->_alias = $alias;
236236
}
237237

238-
$this->_alias = $alias;
239-
240-
return $this;
238+
return $this->_alias;
241239
}
242240

243241
/**
@@ -968,6 +966,7 @@ protected function _dynamicFinder($method, $args)
968966
);
969967
}
970968

969+
$conditions = [];
971970
if ($hasOr === false && $hasAnd === false) {
972971
$conditions = $makeConditions([$fields], $args);
973972
} elseif ($hasOr !== false) {

src/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function firstOrFail()
234234
* @param string $field The field to alias.
235235
* @param null $alias Not being used
236236
*
237-
* @return string The field prefixed with the endpoint alias.
237+
* @return array The field prefixed with the endpoint alias.
238238
*/
239239
public function aliasField($field, $alias = null)
240240
{

src/Schema.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Muffin\Webservice;
44

5+
use Cake\Database\Type;
6+
57
/**
68
* Represents a single endpoint in a database schema.
79
*
@@ -226,7 +228,7 @@ public function columnType($name, $type = null)
226228
* based upon.
227229
*
228230
* @param string $column The column name to get the base type from
229-
* @return string The base type name
231+
* @return string|null The base type name
230232
*/
231233
public function baseColumnType($column)
232234
{

0 commit comments

Comments
 (0)