<?php
class Counter implements Countable
{
public function count()
{
var_dump(func_get_arg(0));
return count($this->data);
}
}
$counter = new Counter;
$counter->count(COUNT_RECURSIVE);
Deprecated: Return type of Counter::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/Pg3G7 on line 4
int(1)
Warning: Undefined property: Counter::$data in /in/Pg3G7 on line 7
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /in/Pg3G7:7
Stack trace:
#0 /in/Pg3G7(12): Counter->count(1)
#1 {main}
thrown in /in/Pg3G7 on line 7
Process exited with code 255.
Output for 8.0.10 - 8.0.30
int(1)
Warning: Undefined property: Counter::$data in /in/Pg3G7 on line 7
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /in/Pg3G7:7
Stack trace:
#0 /in/Pg3G7(12): Counter->count(1)
#1 {main}
thrown in /in/Pg3G7 on line 7
Process exited with code 255.
Output for 8.0.0 - 8.0.9
int(1)
Warning: Undefined property: Counter::$data in /in/Pg3G7 on line 7
Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in /in/Pg3G7:7
Stack trace:
#0 /in/Pg3G7(12): Counter->count(1)
#1 {main}
thrown in /in/Pg3G7 on line 7
Process exited with code 255.
int(1)
Notice: Undefined property: Counter::$data in /in/Pg3G7 on line 7
Warning: count(): Parameter must be an array or an object that implements Countable in /in/Pg3G7 on line 7
Output for 7.3.32 - 7.3.33
int(1)
Warning: count(): Parameter must be an array or an object that implements Countable in /in/Pg3G7 on line 7