]> granicus.if.org Git - php/commitdiff
Add warnings when counting invalid parameters
authorCraig Duncan <git@duncanc.co.uk>
Tue, 4 Oct 2016 12:27:02 +0000 (13:27 +0100)
committerJoe Watkins <krakjoe@php.net>
Thu, 17 Nov 2016 09:33:04 +0000 (09:33 +0000)
ext/standard/array.c

index f3a7f4de84cd959097f1f42747a10968d7d2278c..2c511498810ce3b235bfe8a617888402fc1b1ccd 100644 (file)
@@ -790,6 +790,7 @@ PHP_FUNCTION(count)
 
        switch (Z_TYPE_P(array)) {
                case IS_NULL:
+                       php_error_docref(NULL, E_WARNING, "Parameter must be an array or an object that implements Countable");
                        RETURN_LONG(0);
                        break;
                case IS_ARRAY:
@@ -820,8 +821,14 @@ PHP_FUNCTION(count)
                                }
                                return;
                        }
+
+                       /* If There's no handler and it doesn't implement Countable then add a warning */
+                       php_error_docref(NULL, E_WARNING, "Parameter must be an array or an object that implements Countable");
+                       RETURN_LONG(1);
+                       break;
                }
                default:
+                       php_error_docref(NULL, E_WARNING, "Parameter must be an array or an object that implements Countable");
                        RETURN_LONG(1);
                        break;
        }