count_invalid.phpt 1011 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Only arrays and countable objects can be counted
  3. --FILE--
  4. <?php
  5. $result = count(null);
  6. var_dump($result);
  7. $result = count("string");
  8. var_dump($result);
  9. $result = count(123);
  10. var_dump($result);
  11. $result = count(true);
  12. var_dump($result);
  13. $result = count(false);
  14. var_dump($result);
  15. $result = count((object) []);
  16. var_dump($result);
  17. ?>
  18. --EXPECTF--
  19. Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
  20. int(0)
  21. Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
  22. int(1)
  23. Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
  24. int(1)
  25. Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
  26. int(1)
  27. Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
  28. int(1)
  29. Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
  30. int(1)