Skip to content
Permalink
Browse files

Stop warnings when using count in QueryCompiler in PHP 7.2

- PHP 7.2 has changed the count function to emit warnings when the object
  being "counted" is not an array or does not implement the Countable
  interface.  The QueryCompiler was using count for objects that did not
  fall into those two categories.  This fixes that problem while
  maintaining the same logic (returning early when $parts is not set, is
  null, or has a count of 0).
  • Loading branch information...
Mike Fellows Mike Fellows
Mike Fellows authored and Mike Fellows committed Jul 5, 2017
1 parent 4bc6a54 commit 2c958f6243f6673eea7517467b3cb888cd0e33b1
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/Database/QueryCompiler.php
@@ -125,7 +125,9 @@ public function compile(Query $query, ValueBinder $generator)
protected function _sqlCompiler(&$sql, $query, $generator)
{
return function ($parts, $name) use (&$sql, $query, $generator) {
if (!count($parts)) {
if (!isset($parts) ||
((is_array($parts) || $parts instanceof \Countable) && !count($parts))
) {
return;
}
if ($parts instanceof ExpressionInterface) {

0 comments on commit 2c958f6

Please sign in to comment.
You can’t perform that action at this time.