Browse Source

Fix issues reported by phpstan in Database package.

ADmad 8 years ago
parent
commit
360319acdb
4 changed files with 6 additions and 3 deletions
  1. 1 0
      phpstan.neon
  2. 1 1
      src/Database/Driver.php
  3. 3 1
      src/Database/Statement/SqliteStatement.php
  4. 1 1
      src/ORM/EagerLoader.php

+ 1 - 0
phpstan.neon

@@ -24,6 +24,7 @@ parameters:
         - '#Call to an undefined method Cake\\Collection\\Iterator\\ZipIterator::getInnerIterator\(\)#'
         - '#Result of method Cake\\Http\\Response::send\(\) \(void\) is used#'
         - '#Method Cake\\View\\Form\\ContextInterface::val\(\) invoked with 2 parameters, 1 required#'
+        - '#Access to an undefined property Exception::\$queryString#'
     earlyTerminatingMethodCalls:
         Cake\Shell\Shell:
             - abort

+ 1 - 1
src/Database/Driver.php

@@ -86,7 +86,7 @@ abstract class Driver
      * If first argument is passed,
      *
      * @param null|\PDO $connection The connection object
-     * @return \Cake\Database\Connection
+     * @return \PDO
      */
     abstract public function connection($connection = null);
 

+ 3 - 1
src/Database/Statement/SqliteStatement.php

@@ -48,7 +48,9 @@ class SqliteStatement extends StatementDecorator
      */
     public function rowCount()
     {
-        if (preg_match('/^(?:DELETE|UPDATE|INSERT)/i', $this->_statement->queryString)) {
+        if ($this->_statement instanceof BufferedStatement
+            && preg_match('/^(?:DELETE|UPDATE|INSERT)/i', $this->_statement->queryString)
+        ) {
             $changes = $this->_driver->prepare('SELECT CHANGES()');
             $changes->execute();
             $count = $changes->fetch()[0];

+ 1 - 1
src/ORM/EagerLoader.php

@@ -813,7 +813,7 @@ class EagerLoader
      * Helper function used to iterate a statement and extract the columns
      * defined in $collectKeys
      *
-     * @param \Cake\Database\StatementInterface $statement The statement to read from.
+     * @param \Cake\Database\BufferedStatement $statement The statement to read from.
      * @param array $collectKeys The keys to collect
      * @return array
      */