/** * Report that the $method doesn't exist. * * @param string $method * @param array $arguments */ public function __call($method, $arguments) { $rObject = new ReflectionObject($this); $methods = []; foreach ($rObject->getMethods() as $rMethod) { if (in_array($rMethod->name, array('__get', '__set', '__call', '__toString'))) { continue; } if ($rMethod->isPublic()) { $scope = 'public'; } elseif ($rMethod->isProtected()) { $scope = 'protected'; } elseif ($rMethod->isPrivate()) { $scope = 'private'; } $parameters = []; foreach ($rMethod->getParameters() as $rParam) { $param = '$' . $rParam->name; if ($rParam->isDefaultValueAvailable()) { $param .= ' = ' . \Sledgehammer\syntax_highlight($rParam->getDefaultValue()); } $parameters[] = $param; } $methods[$scope][] = \Sledgehammer\syntax_highlight($rMethod->name, 'method') . '(' . implode(', ', $parameters) . ')'; } $methodsText = ''; $glue = '<br /> '; foreach ($methods as $scope => $mds) { $methodsText .= '<b>' . $scope . ' methods</b>' . $glue . implode($glue, $mds) . '<br /><br />'; } throw new InfoException('Method: "' . $method . '" doesn\'t exist in a "' . get_class($this) . '" object.', $methodsText); }
/** * Een array printen met syntax highlighting. * * @param array $array */ private function renderArray($array) { foreach ($array as $key => $value) { if (is_array($value) && count($value) != 0) { echo '<b>' . $key . ':</b> array(' . "<br />\n"; if (\Sledgehammer\is_indexed($value)) { foreach ($value as $value2) { echo ' ', \Sledgehammer\syntax_highlight($value2), "<br />\n"; } } else { foreach ($value as $key2 => $value2) { echo ' ' . \Sledgehammer\syntax_highlight($key2) . ' => ', \Sledgehammer\syntax_highlight($value2, null, 2048), "<br />\n"; } } echo ")<br />\n"; } else { echo '<b>' . $key . ':</b> ', \Sledgehammer\syntax_highlight($value, null, 2048), "<br />\n"; } } }
/** * Report the offending token. * * @param string|array $token */ private function unexpectedToken($token) { if (is_string($token)) { \Sledgehammer\notice('Unexpected token: ' . \Sledgehammer\syntax_highlight($token)); } else { \Sledgehammer\notice('Unexpected token: ' . token_name($token[0]) . ': ' . \Sledgehammer\syntax_highlight($token[1]) . ' on line ' . $token[2]); } }