本文整理汇总了PHP中raise函数的典型用法代码示例。如果您正苦于以下问题:PHP raise函数的具体用法?PHP raise怎么用?PHP raise使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了raise函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run($routes)
{
if (isset(self::$setUp)) {
call_user_func(self::$setUp);
}
global $request;
$controller_name = '';
$matches = array();
foreach ($routes as $pattern => $controller) {
if (preg_match('#^/?' . $pattern . '/?$#', $request->uri, $match)) {
$controller_name = $controller;
$matches = array_slice($match, 1);
break;
}
}
if (is_array($controller_name)) {
// By default GET
$methods = array('GET');
if (isset($controller_name['controller'])) {
if (isset($controller_name['methods'])) {
$methods = $controller_name['methods'];
}
$controller_name = $controller_name['controller'];
} else {
if (isset($controller_name[1]) && is_array($controller_name[1])) {
$methods = $controller_name[1];
}
$controller_name = $controller_name[0];
}
if (in_array(strtoupper($request->verb), $methods)) {
call_user_func_array($controller_name, $matches);
} else {
raise('405');
}
} elseif (class_exists($controller_name)) {
$controller = new $controller_name($matches);
call_user_func_if_exists(array($controller, 'setUp'));
$method = strtolower($request->verb);
if ($request->is_ajax && method_exists($controller, $method . '_ajax')) {
// Headers inspired by and taken from ToroPHP's code.
// ToroPHP on Github: https://github.com/anandkunal/ToroPHP/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
call_user_func_array(array($controller, $method . '_ajax'), $matches);
} elseif (method_exists($controller, $method)) {
call_user_func_array(array($controller, $method), $matches);
}
call_user_func_if_exists(array($controller, 'tearDown'));
} elseif (function_exists($controller_name)) {
call_user_func_array($controller_name, $matches);
} else {
raise('404');
}
if (isset(self::$tearDown)) {
call_user_func(self::$tearDown);
}
}
示例2: getResource
/**
* Fetches a resource
*
* @param string name
* @return string
*/
protected function getResource($name)
{
foreach ($this->cl as $loader) {
if ($loader->providesResource($name)) {
return $loader->getResource($name);
}
}
raise('lang.ElementNotFoundException', $name);
}
示例3: methodNamed
/**
* Returns a method for a class by a given name
*
* @param text.doclet.ClassDoc self
* @param string name
* @return text.doclet.MethodDoc
* @throws lang.ElementNotFoundException
*/
public static function methodNamed(ClassDoc $self, $name)
{
foreach ($self->methods as $method) {
if ($name === $method->name()) {
return $method;
}
}
raise('lang.ElementNotFoundException', 'No such method ' . $name . ' in ' . $self->name());
}
示例4: invoke
/**
* Invoke method on a registered instance.
*
* @param string instancename
* @param string methodname
* @param var* method arguments
* @return var
* @throws lang.IllegalArgumentException if the instance is not known
* @throws lang.ElementNotFoundException if the given method does not exist or is not xsl-accessible
*/
public static function invoke($name, $method)
{
if (!isset(self::$instance->instances[$name])) {
throw new IllegalArgumentException('No such registered XSL callback instance: "' . $name . '"');
}
$instance = self::$instance->instances[$name];
if (!$instance->getClass()->getMethod($method)->hasAnnotation('xslmethod')) {
raise('lang.ElementNotFoundException', 'Instance "' . $name . '" does not have method "' . $method . '"');
}
$va = func_get_args();
// Decode arguments [2..*]
for ($i = 2, $args = array(), $s = sizeof($va); $i < $s; $i++) {
$args[] = is_string($va[$i]) ? iconv('utf-8', xp::ENCODING, $va[$i]) : $va[$i];
}
// Call callback method
$r = call_user_func_array(array($instance, $method), $args);
// Encode result if necessary
return is_string($r) ? iconv(xp::ENCODING, 'utf-8', $r) : $r;
}
示例5: acquire
static function acquire($archive)
{
static $archives = array();
static $unpack = array(1 => 'a80id/a80*filename/a80*path/V1size/V1offset/a*reserved', 2 => 'a240id/V1size/V1offset/a*reserved');
if ('/' === $archive[0] && ':' === $archive[2]) {
$archive = substr($archive, 1);
// Handle xar:///f:/archive.xar => f:/archive.xar
}
if (!isset($archives[$archive])) {
$current = array('handle' => fopen($archive, 'rb'), 'dev' => crc32($archive));
$header = unpack('a3id/c1version/V1indexsize/a*reserved', fread($current['handle'], 0x100));
if ('CCA' != $header['id']) {
\raise('lang.FormatException', 'Malformed archive ' . $archive);
}
for ($current['index'] = array(), $i = 0; $i < $header['indexsize']; $i++) {
$entry = unpack($unpack[$header['version']], fread($current['handle'], 0x100));
$current['index'][rtrim($entry['id'], "")] = array($entry['size'], $entry['offset'], $i);
}
$current['offset'] = 0x100 + $i * 0x100;
$archives[$archive] = $current;
}
return $archives[$archive];
}
示例6: getHeader
/**
* Returns a header specified by its name
*
* @param string name
* @return string value
* @throws lang.ElementNotFoundException
*/
public function getHeader($name)
{
if ('Content-Type' === $name) {
return $this->contentType;
} else {
if ('Accept' === $name) {
return $this->accept;
} else {
foreach ($this->headers as $header) {
if ($name === $header->getName()) {
return $header->getValue();
}
}
}
}
raise('lang.ElementNotFoundException', 'No such header "' . $name . '"');
}
示例7: fopen
earthli Projects is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with earthli Projects; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For more information about the earthli Projects, visit:
http://www.earthli.com/software/webcore/projects
****************************************************************************/
require_once 'projects/init.php';
// retrieve the tree of folders to guarantee that each folder
// is written before its children
$fn = $App->export_options->kind_file_name;
$fhandle = fopen($fn, 'w+');
if (!$fhandle) {
raise("Could not open file [{$fn}] for kind export.");
}
fwrite($fhandle, "<?xml version=\"1.0\"?>\n");
fwrite($fhandle, "<OpusVCS>\n");
$indexed_kinds = $App->entry_kinds();
foreach ($indexed_kinds as $kind) {
fwrite($fhandle, "<kind name=\"{$kind->title}\">\n");
echo "Exported [{$kind->title}]<br>";
}
fwrite($fhandle, "</OpusVCS>\n");
示例8: getResourceAsStream
/**
* Retrieve a stream to the resource
*
* @param string filename name of resource
* @return io.File
* @throws lang.ElementNotFoundException in case the resource cannot be found
*/
public function getResourceAsStream($filename)
{
if (!is_file($fn = $this->path . strtr($filename, '/', DIRECTORY_SEPARATOR))) {
return raise('lang.ElementNotFoundException', 'Could not load resource ' . $filename);
}
return new File($fn);
}
示例9: baseImpl
/**
* Creates underlying base for class loader, e.g. a directory or a .XAR file
*
* @return net.xp_framework.unittest.reflection.ClassFromUriBase
*/
protected static function baseImpl()
{
raise('lang.MethodNotImplementedException', 'Implement in subclass!', __FUNCTION__);
}
示例10: getProperties
/**
* Return properties by name
*
* @param string name
* @return util.PropertyAccess
* throws lang.ElementNotFoundException
*/
public function getProperties($name)
{
$found = array();
foreach ($this->provider as $source) {
if ($source->provides($name)) {
$found[] = $source->fetch($name);
}
}
switch (sizeof($found)) {
case 1:
return $found[0];
case 0:
raise('lang.ElementNotFoundException', sprintf('Cannot find properties "%s" in any of %s', $name, xp::stringOf(array_values($this->provider))));
default:
return new CompositeProperties($found);
}
}
示例11: initialize
/**
* Initialize this parser.
*/
protected function initialize()
{
// Sections
$this->withHandler('#', true, function ($tag, $state, $parse) {
$parsed = $parse->options(trim(substr($tag, 1)));
$state->parents[] = $state->target;
$block = $state->target->add(BlockHelpers::newInstance(array_shift($parsed), $parsed, null, null, $state->start, $state->end));
$state->target = $block->fn();
$state->parents[] = $block;
});
$this->withHandler('/', true, function ($tag, $state) {
$name = trim(substr($tag, 1));
$block = array_pop($state->parents);
if ($name !== $block->name()) {
throw new TemplateFormatException('Illegal nesting, expected {{/' . $block->name() . '}}, have {{/' . $name . '}}');
}
$state->target = array_pop($state->parents);
});
// > partial
$this->withHandler('>', true, function ($tag, $state, $parse) {
$options = $parse->options(trim($tag));
array_shift($options);
$template = array_shift($options);
if ($template instanceof Lookup) {
$template = new Constant((string) $template);
}
$state->target->add(new PartialNode($template, $options, $state->padding));
});
// ! ... for comments
$this->withHandler('!', true, function ($tag, $state) {
$state->target->add(new CommentNode(trim(substr($tag, 1), ' ')));
});
// Change start and end
$this->withHandler('=', true, function ($tag, $state) {
list($state->start, $state->end) = explode(' ', trim(substr($tag, 1, -1)));
});
// & for unescaped
$this->withHandler('&', false, function ($tag, $state, $parse) {
$parsed = $parse->options(trim(substr($tag, 1)));
$state->target->add('.' === $parsed[0] ? new IteratorNode(false) : new VariableNode($parsed[0], false, array_slice($parsed, 1)));
});
// triple mustache for unescaped
$this->withHandler('{', false, function ($tag, $state, $parse) {
$parsed = $parse->options(trim(substr($tag, 1)));
$state->target->add('.' === $parsed[0] ? new IteratorNode(false) : new VariableNode($parsed[0], false, array_slice($parsed, 1)));
return +1;
// Skip "}"
});
// ^ is either an else by its own, or a negated block
$this->withHandler('^', true, function ($tag, $state) {
if ('^' === trim($tag)) {
$block = cast($state->parents[sizeof($state->parents) - 1], 'com.handlebarsjs.BlockNode');
$state->target = $block->inverse();
return;
}
raise('lang.MethodNotImplementedException', '^blocks not yet implemented');
});
// Default
$this->withHandler(null, false, function ($tag, $state, $parse) {
$parsed = $parse->options(trim($tag));
if ('.' === $parsed[0]) {
$state->target->add(new IteratorNode(true));
return;
} else {
if ('else' === $parsed[0] && $state->parents) {
$context = $state->parents[sizeof($state->parents) - 1];
if ($context instanceof BlockNode) {
$state->target = $context->inverse();
return;
}
// Fall through, "else" has no special meaning here.
}
}
$state->target->add(new VariableNode($parsed[0], true, array_slice($parsed, 1)));
});
}
示例12: parseAnnotations
//.........这里部分代码省略.........
$i++;
return -1 * $valueOf($tokens, $i);
} else {
if ('+' === $tokens[$i][0]) {
$i++;
return +1 * $valueOf($tokens, $i);
} else {
if (T_CONSTANT_ENCAPSED_STRING === $tokens[$i][0]) {
return eval('return ' . $tokens[$i][1] . ';');
} else {
if (T_LNUMBER === $tokens[$i][0]) {
return (int) $tokens[$i][1];
} else {
if (T_DNUMBER === $tokens[$i][0]) {
return (double) $tokens[$i][1];
} else {
if ('[' === $tokens[$i] || T_ARRAY === $tokens[$i][0]) {
$value = array();
$element = NULL;
$key = 0;
$end = '[' === $tokens[$i] ? ']' : ')';
for ($i++, $s = sizeof($tokens);; $i++) {
if ($i >= $s) {
throw new IllegalStateException('Parse error: Unterminated array');
} else {
if ($end === $tokens[$i]) {
$element && ($value[$key] = $element[0]);
break;
} else {
if ('(' === $tokens[$i]) {
// Skip
} else {
if (',' === $tokens[$i]) {
$element || raise('lang.IllegalStateException', 'Parse error: Malformed array - no value before comma');
$value[$key] = $element[0];
$element = NULL;
$key = sizeof($value);
} else {
if (T_DOUBLE_ARROW === $tokens[$i][0]) {
$key = $element[0];
$element = NULL;
} else {
if (T_WHITESPACE === $tokens[$i][0]) {
continue;
} else {
$element && raise('lang.IllegalStateException', 'Parse error: Malformed array - missing comma');
$element = array($valueOf($tokens, $i));
}
}
}
}
}
}
}
return $value;
} else {
if ('"' === $tokens[$i] || T_ENCAPSED_AND_WHITESPACE === $tokens[$i][0]) {
throw new IllegalStateException('Parse error: Unterminated string');
} else {
if (T_NS_SEPARATOR === $tokens[$i][0]) {
$type = '';
while (T_NS_SEPARATOR === $tokens[$i++][0]) {
$type .= '.' . $tokens[$i++][1];
}
return $memberOf($tokens, $i, XPClass::forName(substr($type, 1)));
} else {
示例13: findPackageBy
/**
* Derive package from a given file
*
* @param io.Folder folder
* @return string
* @throws lang.ElementNotFoundException
*/
protected static function findPackageBy($folder)
{
$q = $folder->getURI();
foreach (\lang\ClassLoader::getLoaders() as $loader) {
if (0 === strncmp($q, $loader->path, $l = strlen($loader->path)) && $loader->providesPackage($package = strtr(substr($q, $l), DIRECTORY_SEPARATOR, '.'))) {
return $package;
}
}
raise('lang.ElementNotFoundException', 'Cannot derive package name from ' . $q);
}
示例14: readCentralDirectory
/**
* Read central directory; not supported in this abstract
* implementation.
*
* @return void
*/
protected function readCentralDirectory()
{
raise('lang.MethodNotImplementedException', 'Seeking central directory is only supported by RandomAccessZipReaderImpl.');
}
示例15: getAnnotation
/**
* Retrieve annotation by name
*
* @param string name
* @param string key default NULL
* @return var
* @throws lang.ElementNotFoundException
*/
public function getAnnotation($name, $key = NULL)
{
$n = '$' . $this->_reflect->getName();
if (!($details = XPClass::detailsForMethod($this->_details[0], $this->_details[1])) || !isset($details[DETAIL_TARGET_ANNO][$n]) || !($key ? array_key_exists($key, (array) @$details[DETAIL_TARGET_ANNO][$n][$name]) : array_key_exists($name, (array) @$details[DETAIL_TARGET_ANNO][$n]))) {
return raise('lang.ElementNotFoundException', 'Annotation "' . $name . ($key ? '.' . $key : '') . '" does not exist');
}
return $key ? $details[DETAIL_TARGET_ANNO][$n][$name][$key] : $details[DETAIL_TARGET_ANNO][$n][$name];
}