title: Cakephp3 / PHP72 Paginator, Parameter must be an array or an object that implements Countable
body: <p>After migrating from php5.6 to php7.2 a classical row goes to this error</p>
  
  <pre><code>$books = $this-&gt;paginate($query, ['limit' =&gt; 10]);
  </code></pre>
  
  <p>I read about first use <code>-&gt;toList()</code> before using <code>count()</code> but in this case...
  Any idea how can i solve this ?
  I use cakephp 3.4.7.</p>
  
  <p>PS:
  there is no count() in my code, maybe inside paginator. <br /></p>
  
  <pre><code>$conditions = [];
  $query = $this-&gt;Books-&gt;find('all')
              -&gt;contain(['Autors', 'Titles', 'Edituras'])
              -&gt;order(['Books.id' =&gt; 'asc']);
  if(!empty($conditions)){
      $query-&gt;where(['OR' =&gt; $conditions]);
  } else {
      if(isset($this-&gt;request-&gt;params['?']['page'])){
          $query-&gt;where([]);
      } else {
          $query-&gt;where(['1=2']);
      }
  }
  $this-&gt;set('books', $this-&gt;paginate($query, ['limit' =&gt; 10]));
  </code></pre>
  
  <p>By default, $conditions is empty and the errorlog point to the last row</p>
  
  <p>the error log:</p>
  
  <pre><code>2018-07-02 06:08:51 Warning: Warning (2): count() [&lt;a href='http://php.net/function.count'&gt;function.count&lt;/a&gt;]: Parameter must be an array or an object that implements Countable
  Request URL: /
  Client IP: 81.196.46.249
  Trace:
  Cake\Error\BaseErrorHandler::handleError() - CORE/src/Error/BaseErrorHandler.php, line 153 
  count - [internal], line ??
  BCake\Database\QueryCompiler::Cake\Database\{closure}() - CORE/src/Database/QueryCompiler.php, line 128
  Cake\Database\Query::traverse() - CORE/src/Database/Query.php, line 311
  Cake\Database\QueryCompiler::compile() - CORE/src/Database/QueryCompiler.php, line 99
  Cake\Database\Driver::compileQuery() - CORE/src/Database/Driver.php, line 359
  Cake\Database\Connection::compileQuery() - CORE/src/Database/Connection.php, line 299
  Cake\Database\Query::sql() - CORE/src/Database/Query.php, line 282
  Cake\ORM\Query::sql() - CORE/src/ORM/Query.php, line 992
  Cake\Database\Driver\Mysql::prepare() - CORE/src/Database/Driver/Mysql.php, line 136
  Cake\Database\Connection::prepare() - CORE/src/Database/Connection.php, line 258
  Cake\Database\Connection::run() - CORE/src/Database/Connection.php, line 311
  Cake\Database\Query::execute() - CORE/src/Database/Query.php, line 213
  Cake\ORM\Query::_execute() - CORE/src/ORM/Query.php, line 1011
  Cake\ORM\Query::_all() - CORE/src/Datasource/QueryTrait.php, line 276
  Cake\ORM\Query::all() - CORE/src/ORM/Query.php, line 960
  Cake\Controller\Component\PaginatorComponent::paginate() - CORE/src/Controller/Component/PaginatorComponent.php, line 190
  Cake\Controller\Controller::paginate() - CORE/src/Controller/Controller.php, line 717
  App\Controller\BooksController::index() - APP/Controller/BooksController.php, line 99
  Cake\Controller\Controller::invokeAction() - CORE/src/Controller/Controller.php, line 440
  Cake\Http\ActionDispatcher::_invoke() - CORE/src/Http/ActionDispatcher.php, line 119
  Cake\Http\ActionDispatcher::dispatch() - CORE/src/Http/ActionDispatcher.php, line 93
  Cake\Http\BaseApplication::__invoke() - CORE/src/Http/BaseApplication.php, line 78
  Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65
  Cake\Routing\Middleware\RoutingMiddleware::__invoke() - CORE/src/Routing/Middleware/RoutingMiddleware.php, line 59
  Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65
  Cake\Routing\Middleware\AssetMiddleware::__invoke() - CORE/src/Routing/Middleware/AssetMiddleware.php, line 88
  Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65
  Cake\Error\Middleware\ErrorHandlerMiddleware::__invoke() - CORE/src/Error/Middleware/ErrorHandlerMiddleware.php, line 92
  Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65
  DebugKit\Middleware\DebugKitMiddleware::__invoke() - ROOT/vendor/cakephp/debug_kit/src/Middleware/DebugKitMiddleware.php, line 52
  Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65
  Cake\Http\Runner::run() - CORE/src/Http/Runner.php, line 51
  Cake\Http\Server::run() - CORE/src/Http/Server.php, line 80
  [main] - ROOT/webroot/index.php, line 37
  </code></pre>