本文整理汇总了PHP中xp::errorAt方法的典型用法代码示例。如果您正苦于以下问题:PHP xp::errorAt方法的具体用法?PHP xp::errorAt怎么用?PHP xp::errorAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xp
的用法示例。
在下文中一共展示了xp::errorAt方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: finalize
/**
* Finalizes the processor.
*
* @return string
*/
public function finalize()
{
static $classes = array(T_VARIABLE => 'variable', T_CLASS => 'keyword', T_INTERFACE => 'keyword', T_EXTENDS => 'keyword', T_IMPLEMENTS => 'keyword', T_CATCH => 'keyword', T_THROW => 'keyword', T_TRY => 'keyword', T_NEW => 'keyword', T_FUNCTION => 'keyword', T_FOR => 'keyword', T_IF => 'keyword', T_ELSE => 'keyword', T_SWITCH => 'keyword', T_WHILE => 'keyword', T_FOREACH => 'keyword', T_RETURN => 'keyword', T_STATIC => 'modifier', T_ABSTRACT => 'modifier', T_PUBLIC => 'modifier', T_PRIVATE => 'modifier', T_PROTECTED => 'modifier', T_FINAL => 'modifier', T_DNUMBER => 'number', T_LNUMBER => 'number', T_CONSTANT_ENCAPSED_STRING => 'string', T_COMMENT => 'comment', '{' => 'bracket', '}' => 'bracket', '(' => 'bracket', ')' => 'bracket');
// Tokenize buffer
$tokens = token_get_all('<?php ' . trim($this->buffer, "\r\n") . '?>');
if (!is_array($tokens) || xp::errorAt(__FILE__, __LINE__ - 1)) {
$e = new FormatException('Cannot parse "' . $this->buffer . '"');
xp::gc(__FILE__);
throw $e;
}
// Create HTML
$current = NULL;
$out = '';
for ($i = 1, $s = sizeof($tokens) - 1; $i < $s; $i++) {
$token = $tokens[$i];
$class = isset($classes[$token[0]]) ? $classes[$token[0]] : 'default';
// Handle annotations
if (is_array($token) && T_COMMENT === $token[0] && '#' === $token[1][0]) {
$class = 'annotation';
}
if ($current != $class) {
$out .= '</span><span class="' . $class . '">';
$current = $class;
}
$out .= strtr(htmlspecialchars(is_array($token) ? $token[1] : $token), array("\n" => '<br/>', "\r" => ''));
}
// Skip leading "</span>" (7)
return '</p><code>' . substr($out, 7) . ($current ? '</span>' : '') . '</code><p>';
}
示例2: __construct
/**
* Constructor
*
* @param var arg either a string or an int
* @param string charset default NULL
*/
public function __construct($arg, $charset = NULL)
{
if (is_int($arg)) {
$this->buffer = iconv('UCS-4BE', 'utf-8', pack('N', $arg));
return;
}
$charset = strtoupper($charset ? $charset : iconv_get_encoding('input_encoding'));
// Convert the input to internal encoding
$this->buffer = iconv($charset, 'utf-8', $arg);
if (xp::errorAt(__FILE__, __LINE__ - 1)) {
$message = key(xp::$errors[__FILE__][__LINE__ - 2]);
xp::gc(__FILE__);
throw new FormatException($message . ($charset == 'utf-8' ? ' with charset ' . $charset : $message . ' while converting input from ' . $charset . ' to ' . 'utf-8'));
}
if (1 != ($l = iconv_strlen($this->buffer, 'utf-8'))) {
throw new IllegalArgumentException('Given argument is too long (' . $l . ')');
}
}
示例3: __construct
/**
* Constructor. Creates a new date object through either a
* <ul>
* <li>integer - interpreted as timestamp</li>
* <li>string - parsed into a date</li>
* <li>php.DateTime object - will be used as is</li>
* <li>NULL - creates a date representing the current instance</li>
* </ul>
*
* Timezone assignment works through these rules:
* . If the time is given as string and contains a parseable timezone identifier
* that one is used.
* . If no timezone could be determined, the timezone given by the
* second parameter is used
* . If no timezone has been given as second parameter, the system's default
* timezone is used.
*
* @param var in default NULL either a string or a Unix timestamp or DateTime object, defaulting to now
* @param string timezone default NULL string of timezone
* @throws lang.IllegalArgumentException in case the date is unparseable
*/
public function __construct($in = NULL, TimeZone $timezone = NULL)
{
if ($in instanceof DateTime) {
$this->date = $in;
} else {
if ((string) (int) $in === (string) $in) {
// Specially mark timestamps for parsing (we assume here that strings
// containing only digits are timestamps)
$this->date = date_create('@' . $in, timezone_open('UTC'));
date_timezone_set($this->date, $timezone ? $timezone->getHandle() : timezone_open(date_default_timezone_get()));
} else {
$this->date = $timezone ? date_create($in, $timezone->getHandle()) : date_create($in);
if (FALSE === $this->date || xp::errorAt(__FILE__, __LINE__ - 1)) {
$e = new IllegalArgumentException('Given argument is neither a timestamp nor a well-formed timestring: ' . xp::stringOf($in));
xp::gc(__FILE__);
throw $e;
}
}
}
}
示例4: eof
/**
* Returns whether the file pointer is at the end of the file
*
* Hint:
* Use isOpen() to check if the file is open
*
* @see php://feof
* @return bool TRUE when the end of the file is reached
* @throws io.IOException in case of an error (e.g., the file's not been opened)
*/
public function eof()
{
$result = feof($this->_fd);
if (xp::errorAt(__FILE__, __LINE__ - 1)) {
$e = new IOException('Cannot determine eof of ' . $this->uri);
xp::gc(__FILE__);
throw $e;
}
return $result;
}
示例5: flip
/**
* Flip keys and values. Note that the values may only consists
* of scalar values, else the operation will fail (and no key/value
* pair in question will *not* be flipped. If a value has several
* occurrences, the latest key will be used as its value
*
* Example:
* <pre>
* before after
* ------ -----
* a => b b => b
* b => b 1 => c
* c => 1
* </pre>
*
* @return bool all keys/values have been flipped
* @throws lang.FormatException in case this hash contains non-scalar values
*/
public function flip()
{
$h = array_flip($this->_hash);
if (\xp::errorAt(__FILE__, __LINE__ - 1)) {
$e = new \lang\FormatException('hash contains values which are not scalar');
\xp::gc(__FILE__);
throw $e;
}
$this->_hash = $h;
return true;
}
示例6: tell
/**
* Retrieve file pointer position
*
* @throws io.IOException in case of an error
* @return int position
*/
public function tell($position = 0, $mode = SEEK_SET)
{
$result = gztell($this->_fd);
if (FALSE === $result && xp::errorAt(__FILE__, __LINE__ - 1)) {
throw new IOException('retrieve file pointer\'s position ' . $this->uri);
}
return $result;
}
示例7: triggered_error_at_file_and_line
public function triggered_error_at_file_and_line()
{
trigger_error('Test');
$this->assertEquals(array('Test' => array('class' => NULL, 'method' => 'trigger_error', 'cnt' => 1)), xp::errorAt(__FILE__, __LINE__ - 3));
xp::gc();
}
示例8: decodeName
/**
* Decode a name from a list of given character sets
*
* @param string name
* @param string[] charsets
* @return string
*/
protected function decodeName($name, $charsets)
{
xp::gc(__FILE__);
foreach ($charsets as $charset) {
$decoded = iconv($charset, xp::ENCODING, $name);
if (!xp::errorAt(__FILE__, __LINE__ - 1)) {
return $decoded;
}
xp::gc(__FILE__);
// Clean up and try next charset
}
return $name;
}
示例9: yyparse
/**
* Parser main method. Maintains a state and a value stack,
* currently with fixed maximum size.
*
* @param text.parser.generic.AbstractLexer lexer
. * @return mixed result of the last reduction, if any.
*/
public function yyparse($yyLex)
{
$yyVal = null;
$yyStates = $yyVals = [];
$yyToken = -1;
$yyState = $yyErrorFlag = 0;
while (1) {
for ($yyTop = 0;; $yyTop++) {
$yyStates[$yyTop] = $yyState;
$yyVals[$yyTop] = $yyVal;
for (;;) {
if (($yyN = self::$yyDefRed[$yyState]) == 0) {
// Check whether it's necessary to fetch the next token
$yyToken < 0 && ($yyToken = $yyLex->advance() ? $yyLex->token : 0);
if (($yyN = self::$yySindex[$yyState]) != 0 && ($yyN += $yyToken) >= 0 && $yyN < self::$yyTableCount && self::$yyCheck[$yyN] == $yyToken) {
$yyState = self::$yyTable[$yyN];
// shift to yyN
$yyVal = $yyLex->value;
$yyToken = -1;
$yyErrorFlag > 0 && $yyErrorFlag--;
continue 2;
}
if (($yyN = self::$yyRindex[$yyState]) != 0 && ($yyN += $yyToken) >= 0 && $yyN < self::$yyTableCount && self::$yyCheck[$yyN] == $yyToken) {
$yyN = self::$yyTable[$yyN];
// reduce (yyN)
} else {
switch ($yyErrorFlag) {
case 0:
return $this->error(E_PARSE, sprintf('Syntax error at %s, line %d (offset %d): Unexpected %s', $yyLex->fileName, $yyLex->position[0], $yyLex->position[1], $this->yyName($yyToken)), $this->yyExpecting($yyState));
case 1:
case 2:
$yyErrorFlag = 3;
do {
if (($yyN = @self::$yySindex[$yyStates[$yyTop]]) != 0 && ($yyN += TOKEN_YY_ERRORCODE) >= 0 && $yyN < self::$yyTableCount && self::$yyCheck[$yyN] == TOKEN_YY_ERRORCODE) {
$yyState = self::$yyTable[$yyN];
$yyVal = $yyLex->value;
break 3;
}
} while ($yyTop-- >= 0);
throw new ParseException(sprintf('Irrecoverable syntax error at %s, line %d (offset %d)', $yyLex->fileName, $yyLex->position[0], $yyLex->position[1]));
case 3:
if (0 == $yyToken) {
throw new ParseException(sprintf('Irrecoverable syntax error at end-of-file at %s, line %d (offset %d)', $yyLex->fileName, $yyLex->position[0], $yyLex->position[1]));
}
$yyToken = -1;
break 1;
}
}
}
$yyV = $yyTop + 1 - self::$yyLen[$yyN];
$yyVal = $yyV > $yyTop ? null : $yyVals[$yyV];
// Actions
switch ($yyN) {
case 5:
$yyVal = $yyVals[-1 + $yyTop];
break;
case 6:
$yyVal = [];
break;
case 8:
$yyVal = $yyVals[-2 + $yyTop] + $yyVals[0 + $yyTop];
break;
case 9:
$yyVal = [$yyVals[-2 + $yyTop] => $yyVals[0 + $yyTop]];
break;
case 10:
$yyVal = iconv($this->targetEncoding, \xp::ENCODING, $yyVals[-1 + $yyTop]);
break;
case 11:
$yyVal = '';
break;
case 12:
$yyVal = $yyVals[-1 + $yyTop];
break;
case 13:
$yyVal = [];
break;
case 14:
$yyVal = [$yyVals[0 + $yyTop]];
break;
case 15:
$yyVal = array_merge($yyVals[-2 + $yyTop], [$yyVals[0 + $yyTop]]);
break;
case 16:
if (\xp::errorAt(__FILE__)) {
$e = new \lang\FormatException('Cannot decode string ' . (new \lang\types\Bytes($yyVals[-2 + $yyTop]))->toString() . ' to ' . $this->targetEncoding);
\xp::gc(__FILE__);
throw $e;
}
$yyVal = $yyVals[-1 + $yyTop];
break;
case 17:
$yyVal = '';
//.........这里部分代码省略.........
示例10: errorAtFileAndLine
public function errorAtFileAndLine()
{
$a .= '';
// E_NOTICE: Undefined variable: a
$this->assertTrue((bool) xp::errorAt(__FILE__, __LINE__ - 1));
}
示例11: errorAt_given_a_file_and_line_with_error
public function errorAt_given_a_file_and_line_with_error()
{
trigger_error('Test error');
$this->assertTrue((bool) \xp::errorAt(__FILE__, __LINE__ - 1));
}
示例12: decodeName
/**
* Decode a name from a list of given character sets
*
* @param string name
* @param string[] charsets
* @return string
*/
protected function decodeName($name, $charsets)
{
\xp::gc(__FILE__);
foreach ($charsets as $charset => $target) {
$decoded = iconv($charset, $target, $name);
if (!\xp::errorAt(__FILE__, __LINE__ - 1)) {
return $target === \xp::ENCODING ? $decoded : iconv($target, \xp::ENCODING, $decoded);
}
\xp::gc(__FILE__);
// Clean up and try next charset
}
return $name;
}
示例13: read
/**
* Read a number of characters
*
* @param int size default 8192
* @return string NULL when end of data is reached
*/
public function read($size = 8192)
{
if (0 === $size) {
return '';
}
while (strlen($this->buf) < $size) {
$c = fread($this->in, $size - strlen($this->buf));
if ('' === $c) {
if (xp::errorAt(__FILE__, __LINE__ - 2)) {
$message = key(xp::$errors[__FILE__][__LINE__ - 3]);
xp::gc(__FILE__);
throw new FormatException($message);
}
break;
}
$this->buf .= $c;
}
if ('' === $this->buf) {
return NULL;
}
$chunk = $this->buf;
$this->buf = '';
return $chunk;
}