filter = new FilterOptions(); $this->presenter = $presenter; } /** * Return a list of categorized things with the given input options and target. * * @param InputInterface $input * @param \Reflector|null $reflector * @param mixed $target * * @return array */ public function enumerate(InputInterface $input, ?\Reflector $reflector = null, $target = null): array { $this->filter->bind($input); return $this->listItems($input, $reflector, $target); } /** * Enumerate specific items with the given input options and target. * * Implementing classes should return an array of arrays: * * [ * 'Constants' => [ * 'FOO' => [ * 'name' => 'FOO', * 'style' => 'public', * 'value' => '123', * ], * ], * ] * * @param InputInterface $input * @param \Reflector|null $reflector * @param mixed $target * * @return array */ abstract protected function listItems(InputInterface $input, ?\Reflector $reflector = null, $target = null): array; protected function showItem($name) { return $this->filter->match($name); } protected function presentRef($value) { // Symfony VarDumper 5.4 trips over NAN/INF on PHP 8.5 in PHAR builds, // so format non-finite floats directly instead of cloning them. if (\is_float($value) && !\is_finite($value)) { return OutputFormatter::escape(\sprintf('%s', \var_export($value, true))); } return $this->presenter->presentRef($value); } protected function presentSignature($target) { // This might get weird if the signature is actually for a reflector. Hrm. if (!$target instanceof \Reflector) { $target = Mirror::get($target); } return SignatureFormatter::format($target); } }