Generate the anonymous class with the structure to use for each item

@param mixed $context The context to add to the notify
@param callable|null $callback The callback to call when
the task is runned

@return object
437248
public static function generateStepItem($context = null, $callback = null)
    {
        return new class ($context, $callback) {
            public $context;
            public $callback;
            
            public function __construct($context, $callback)
            {
                $this->context  = $context;
                $this->callback = $callback;
            }
        };
    }
571875
public function setCallback(callable $callback): EventObserver
    {
        $this->callback = $callback;
        $this->id = $this->getId($callback);

        return $this;
    }
487213
public function filter(callable $callback = null)
    {
        if (is_null($callback)) {
            return new static($this->classname, array_filter($this->items));
        }

        return new static($this->classname, array_filter($this->items, $callback));
    }
660900
private function generateCallback(Closure $callback): Closure
    {
        return function ($match) use ($callback) {
            if ($match[1] == '[' && $match[6] == ']') {
                return substr($match[0], 1, -1);
            }

            $content = isset($match[5]) ? $match[5] : null;
            $atts = isset($match[3]) ? $this->parseAttributes($match[3]) : [];

            return $callback($match[2], $content, $atts);
        };
    }
473766
protected function setCallback($callback) {
		if (!is_callable($callback)) {
			throw new InvalidCallbackException('Invalid callback');
		}

		$this->reflection_parameter =  $this
			     ->getCallbackReflection($callback)
			     ->getParameters()
		;
		$this->callback = $callback;

		return $this;
	}
422861
public function setEditableCallback($callback)
    {
        $this->isEditable() ?: $this->setEditable();
        $this->editableCallback = $callback;

        return $this;
    }
360062
public static function spy(callable $callback = null): SpyVerifier
    {
        $container = self::$globals::$container;

        return $container->spyVerifierFactory->createFromCallback($callback);
    }
503934
protected function getCallback($callback, array $parameters)
    {
        if ($callback instanceof Closure) {
            return $this->createCallableCallback($callback, $parameters);
        } elseif (is_string($callback)) {
            return $this->createStringCallback($callback, $parameters);
        } else {
            return;
        }
    }
726560
private function makeCallbackHumanReadable( Callable $callback )
    {
        if( is_string($callback) ) {
            return $callback;
        } elseif( is_array($callback) ) {
            return sprintf(
                "%s::%s",
                is_object( $callback[0] ) ? get_class($callback[0]) : $callback[0],
                $callback[1]
            );
        } elseif( !($callback instanceof \Closure) ) {
            return "<closure>";
        }
        throw new \Exception("Wow. I didn't know php could define a callable of this type. Pete __definately__ wants to know all about this.");
    }
1300606
protected function callStringCallback($callback, $args = [])
    {
        if (strpos($callback, '@')) {
            list($klass, $method) = explode('@', $callback);
        } else {
            $klass  = $callback;
            $method = 'render';
        }

        $klass = isset($this->instantiatedWidgets[$klass]) ? $this->instantiatedWidgets[$klass] : new $klass;

        return call_user_func_array([$klass, $method], $args);
    }
603275
public function setCallback($callback)
    {
        if (!is_callable($callback)) {
            throw new Exception\InvalidArgumentException('Invalid callback provided');
        }

        $this->options['callback'] = $callback;
        return $this;
    }
605928
protected function commandCallback($callback)
    {
        return (
            function ($output) use ($callback) {
                $this->output .= $output;
                if (is_callable($callback)) {
                    return call_user_func($callback, $output);
                }
            }
        );
    }
1188185
public function setCallback($callback)
    {
        if (is_array($callback)) {
            require_once 'Zend/Server/Method/Callback.php';
            $callback = new Zend_Server_Method_Callback($callback);
        } elseif (!$callback instanceof Zend_Server_Method_Callback) {
            require_once 'Zend/Server/Exception.php';
            throw new Zend_Server_Exception('Invalid method callback provided');
        }
        $this->_callback = $callback;
        return $this;
    }
673179
protected function appendIterator(\Closure $callback = null)
    {
        $iterator = new \AppendIterator();

        $paths = (array) parent::getArrayCopy();

        $clousre = function ($path) use ($callback, $iterator) {
            $iterator->append($callback($path));
        };

        foreach ($this as $path) {
            if ($this->isSubdir($path)) {
                continue;
            }

            $clousre($path);
        }

        return $iterator;
    }
601294
public static function make($properties, Closure $callback = null)
    {
        $item = new self($properties);

        if (is_callable($callback)) {
            call_user_func($callback, $item);
        }

        return $item;
    }
1115302
public static function make(\Closure $callback = null)
    {
        self::$instance = new static();

        if ($callback instanceof \Closure) {
            return $callback(self::$instance);
        }

        return self::$instance;
    }
728590
private function createResource(callable $callback)
    {
        $errors = null;
        set_error_handler(function ($_, $msg, $file, $line) use (&$errors) {
            $errors[] = [
                'message' => $msg,
                'file'    => $file,
                'line'    => $line
            ];
            return true;
        });

        $resource = $callback();
        restore_error_handler();

        if (!$resource) {
            $message = 'Error creating resource: ';
            foreach ($errors as $err) {
                foreach ($err as $key => $value) {
                    $message .= "[$key] $value" . PHP_EOL;
                }
            }
            throw new \RuntimeException(trim($message));
        }

        return $resource;
    }