-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Description
Error:
Access to an undefined property Some\Class\With\CallbackStackProcessing::$counter
Sample abstract code:
/**
* Storage.php
*/
class Storage
{
private $data;
public function __get($key)
{
return $this->data[$key] ?? null;
}
public function __set($key, $value)
{
$this->data[$key] = $value;
}
}
/**
* Inside Some\Class\With\CallbackStackProcessing::process()
*/
$storage = new Storage;
$result = $this->data;
foreach ($this->processors as $processor)
{
$result = Closure::bind($processor, $storage)($result);
}
return $result;
/**
* Callbacks in Some\Class\With\CallbackStackProcessing::$processors
*/
[
function ($data) {
$this->counter = count($data);
return $data;
},
function ($data) {
return array_map($data, function ($item) {
return (int) $data;
});
},
function ($data) {
if ($data[0] < 100) return false;
return $data;
},
function ($data) {
return [
'before' => $this->counter,
'items' => $data,
'after' => count($data),
];
},
]Is there any way to tell analyzer to skip this particular error or typehint via annotations?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels