Unexpected empty array when using array_filter with custom callback in PHP 8.1
I'm stuck trying to I'm stuck on something that should probably be simple. I'm learning this framework and I'm working with an scenario with `array_filter` where my custom callback seems to be returning an empty array, and I'm not sure why... I'm using PHP 8.1 and tried filtering an array of objects based on a certain property. Hereβs a simplified version of what I'm doing: ```php class Item { public $quantity; public function __construct($quantity) { $this->quantity = $quantity; } } $items = [ new Item(5), new Item(0), new Item(3), new Item(0) ]; $filteredItems = array_filter($items, function($item) { return $item->quantity > 0; }); var_dump($filteredItems); ``` I expect this to give me an array with the first and third items, but it returns an empty array. I also tried debugging by adding `var_dump($item->quantity);` inside the callback, and it outputs the quantities as expected, so it seems like the callback is executing correctly. However, the result of `array_filter` is still empty. I also checked if the `Item` class is properly defined and the `quantity` property is accessible. I've attempted to run the code in different environments, but the question continues. I even tried using a simple comparison like `return $item->quantity == 0;` to see if it was a type scenario, but I got the same result. Is there something unusual about how `array_filter` works with objects in PHP 8.1 that I might be missing? Any help would be appreciated! For context: I'm using Php on macOS. I'd really appreciate any guidance on this. My development environment is Windows. Am I missing something obvious? This is my first time working with Php 3.10. What's the correct way to implement this? Has anyone else encountered this? My team is using Php for this mobile app.