- var_dump: documentation ( source)
<?php
class Matcher
{
private $patterns;
public $callbacks;
public function __construct()
{
$this->patterns = new SplQueue();
$this->callbacks = [];
}
public function with(array $pattern, callable $callback)
{
$this->patterns->enqueue($pattern);
$this->callbacks[$this->patterns->key()] = $callback;
}
}
$a = new Matcher();
$cb = function() {
};
$a->with(['foo', 'bar'], $cb);
$a->with(['foo2', 'bar2'], $cb);
$a->with(['foo3', 'bar3'], $cb);
var_dump($a->callbacks);