Skip to content

Commit fabdaa5

Browse files
committed
Fix errors reported by phpstan
1 parent 5174004 commit fabdaa5

File tree

4 files changed

+73
-22
lines changed

4 files changed

+73
-22
lines changed

phpstan.neon

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,59 @@
11
parameters:
2-
level: 4
2+
level: 6
3+
checkMissingIterableValueType: false
4+
checkGenericClassInNonGenericObjectType: false
35
ignoreErrors:
4-
- '#Method Muffin\\Webservice\\Query::endpoint\(\) should return \$this\(Muffin\\Webservice\\Query\)|Muffin\\Webservice\\Model\\Endpoint but returns Cake\Datasource\RepositoryInterface#'
5-
- '#Call to an undefined method Cake\\Datasource\\RepositoryInterface::callFinder\(\)#'
6-
- '#Call to an undefined method Cake\\Datasource\\RepositoryInterface::dispatchEvent\(\)#'
7-
- '#Method Muffin\\Webservice\\Query::offset\(\) should return \$this\(Cake\\Datasource\\QueryInterface\) but returns \$this\(Muffin\\Webservice\\Query\)#'
8-
- '#Return type \(array\) of method Muffin\\Webservice\\Query::aliasField\(\) should be compatible with return type \(string\) of method Cake\\Datasource\\QueryInterface::aliasField\(\)#'
9-
- '#Call to an undefined method Cake\\Datasource\\RepositoryInterface::getName\(\)#'
10-
- '#Call to an undefined method Traversable::count\(\)#'
11-
- '#Strict comparison using === between string and null will always evaluate to false#'
12-
- '#Negated boolean expression is always false#'
6+
-
7+
message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#"
8+
count: 1
9+
path: src/Marshaller.php
10+
11+
-
12+
message: "#^Negated boolean expression is always false\\.$#"
13+
count: 3
14+
path: src/Model/Endpoint.php
15+
16+
-
17+
message: "#^Result of \\|\\| is always true\\.$#"
18+
count: 1
19+
path: src/Model/Endpoint.php
20+
21+
-
22+
message: "#^Unreachable statement \\- code above always terminates\\.$#"
23+
count: 1
24+
path: src/Model/Endpoint.php
25+
26+
-
27+
message: "#^Call to an undefined method Traversable\\:\\:count\\(\\)\\.$#"
28+
count: 1
29+
path: src/Model/Endpoint.php
30+
31+
-
32+
message: "#^Parameter \\#1 \\$connection of method Muffin\\\\Webservice\\\\Model\\\\Endpoint\\:\\:setConnection\\(\\) expects Muffin\\\\Webservice\\\\Connection, Muffin\\\\Webservice\\\\AbstractDriver given\\.$#"
33+
count: 1
34+
path: src/Model/Endpoint.php
35+
36+
-
37+
message: "#^Method Muffin\\\\Webservice\\\\Query\\:\\:endpoint\\(\\) should return \\$this\\(Muffin\\\\Webservice\\\\Query\\)\\|Muffin\\\\Webservice\\\\Model\\\\Endpoint but returns Cake\\\\Datasource\\\\RepositoryInterface\\.$#"
38+
count: 1
39+
path: src/Query.php
40+
41+
-
42+
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:callFinder\\(\\)\\.$#"
43+
count: 1
44+
path: src/Query.php
45+
46+
-
47+
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:getName\\(\\)\\.$#"
48+
count: 1
49+
path: src/Query.php
50+
51+
-
52+
message: "#^Return type \\(array\\) of method Muffin\\\\Webservice\\\\Query\\:\\:aliasField\\(\\) should be compatible with return type \\(string\\) of method Cake\\\\Datasource\\\\QueryInterface\\:\\:aliasField\\(\\)$#"
53+
count: 1
54+
path: src/Query.php
55+
56+
-
57+
message: "#^Call to an undefined method Cake\\\\Datasource\\\\RepositoryInterface\\:\\:dispatchEvent\\(\\)\\.$#"
58+
count: 1
59+
path: src/Query.php

src/AbstractDriver.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,18 @@ abstract class AbstractDriver implements LoggerAwareInterface
1616
use InstanceConfigTrait;
1717
use LoggerAwareTrait;
1818

19+
/**
20+
* Client
21+
*
22+
* @var object
23+
*/
1924
protected $_client;
2025

26+
/**
27+
* Default config
28+
*
29+
* @var array
30+
*/
2131
protected $_defaultConfig = [];
2232

2333
/**
@@ -195,7 +205,7 @@ public function logQueries($enable = null)
195205
return $this->_logQueries;
196206
}
197207

198-
$this->_logQueries = $enable;
208+
return $this->_logQueries = $enable;
199209
}
200210

201211
/**

src/Model/Endpoint.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Endpoint implements RepositoryInterface, EventListenerInterface, EventDisp
4949
/**
5050
* Connection instance this endpoint uses
5151
*
52-
* @var \Muffin\Webservice\Connection|null $connection Connection instance
52+
* @var \Muffin\Webservice\Connection
5353
*/
5454
protected $_connection;
5555

@@ -635,9 +635,9 @@ public function getResourceClass()
635635
$name = implode('\\', array_slice($parts, 0, -1)) . '\Resource\\' . $alias;
636636
if (!class_exists($name)) {
637637
return $this->_resourceClass = $default;
638-
} else {
639-
return $this->_resourceClass = $name;
640638
}
639+
640+
return $this->_resourceClass = $name;
641641
}
642642

643643
return $this->_resourceClass;
@@ -695,13 +695,7 @@ public function webservice($webservice = null)
695695
return $this->setWebservice($this->getName(), $webservice);
696696
}
697697

698-
if ($webservice === null) {
699-
return $this->getWebservice();
700-
}
701-
702-
$this->_webservice = $webservice;
703-
704-
return $this;
698+
return $this->getWebservice();
705699
}
706700

707701
/**

src/Webservice/Webservice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ protected function _logQuery(Query $query, LoggerInterface $logger)
345345
return;
346346
}
347347

348-
$logger->debug($query->endpoint(), [
348+
$logger->debug($query->endpoint()->getName(), [
349349
'params' => $query->where(),
350350
]);
351351
}

0 commit comments

Comments
 (0)