7b6d06074c
I'm not expecting a user to do anything actionable (other than open an issue) on this error so a regular Exception should be ok.
7846 linhas
227 KiB
PHP
7846 linhas
227 KiB
PHP
<?hh
|
|
// @generated
|
|
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.traversable.php )
|
|
*
|
|
* Interface to detect if a class is traversable using foreach.
|
|
*
|
|
* Abstract base interface that cannot be implemented alone. Instead it
|
|
* must be implemented by either IteratorAggregate or Iterator.
|
|
*
|
|
* Internal (built-in) classes that implement this interface can be used
|
|
* in a foreach construct and do not need to implement IteratorAggregate or
|
|
* Iterator.
|
|
*
|
|
* This is an internal engine interface which cannot be implemented in PHP
|
|
* scripts. Either IteratorAggregate or Iterator must be used instead. When
|
|
* implementing an interface which extends Traversable, make sure to list
|
|
* IteratorAggregate or Iterator before its name in the implements clause.
|
|
*
|
|
*/
|
|
interface Traversable {
|
|
}
|
|
|
|
interface KeyedTraversable extends Traversable {
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.iterator.php )
|
|
*
|
|
* Interface for external iterators or objects that can be iterated
|
|
* themselves internally.
|
|
*
|
|
*/
|
|
interface Iterator extends Traversable {
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/iterator.current.php )
|
|
*
|
|
* Returns the current element.
|
|
*
|
|
* @return mixed Can return any type.
|
|
*/
|
|
public function current();
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/iterator.key.php )
|
|
*
|
|
* Returns the key of the current element.
|
|
*
|
|
* @return mixed Returns scalar on success, or NULL on failure.
|
|
*/
|
|
public function key();
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/iterator.next.php )
|
|
*
|
|
* Moves the current position to the next element.
|
|
*
|
|
* This method is called after each foreach loop.
|
|
*
|
|
* @return mixed Any returned value is ignored.
|
|
*/
|
|
public function next();
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/iterator.rewind.php )
|
|
*
|
|
* Rewinds back to the first element of the Iterator.
|
|
*
|
|
* This is the first method called when starting a foreach loop. It will
|
|
* not be executed after foreach loops.
|
|
*
|
|
* @return mixed Any returned value is ignored.
|
|
*/
|
|
public function rewind();
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/iterator.valid.php )
|
|
*
|
|
* This method is called after Iterator::rewind() and Iterator::next() to
|
|
* check if the current position is valid.
|
|
*
|
|
* @return mixed The return value will be casted to boolean and then
|
|
* evaluated. Returns TRUE on success or FALSE on
|
|
* failure.
|
|
*/
|
|
public function valid();
|
|
}
|
|
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.iteratoraggregate.php )
|
|
*
|
|
* Interface to create an external Iterator.
|
|
*
|
|
*/
|
|
interface IteratorAggregate extends Traversable {
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/iteratoraggregate.getiterator.php )
|
|
*
|
|
* Returns an external iterator.
|
|
*
|
|
* @return mixed An instance of an object implementing Iterator or
|
|
* Traversable
|
|
*/
|
|
public function getIterator();
|
|
}
|
|
|
|
interface Iterable extends IteratorAggregate {
|
|
}
|
|
|
|
interface KeyedIterator extends Iterator, KeyedTraversable {
|
|
}
|
|
|
|
interface KeyedIterable extends Iterable, KeyedTraversable {
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.exception.php )
|
|
*
|
|
* Exception is the base class for all Exceptions.
|
|
*
|
|
*/
|
|
class Exception {
|
|
protected $message = ''; // exception message
|
|
protected $code = 0; // user defined exception code
|
|
protected $previous = null;
|
|
protected $file; // source filename of exception
|
|
protected $line; // source line of exception
|
|
protected $trace; // full stacktrace
|
|
private $inited = false;
|
|
|
|
private static $traceOpts = false;
|
|
|
|
/**
|
|
* This cannot be implemented in __construct, because a derived class may
|
|
* implement its own __construct, losing the stacktrace. The runtime has
|
|
* special logic to call the __init__ method on instances of Exception before
|
|
* calling __construct just to make sure $this->trace is always populated.
|
|
*/
|
|
final function __init__() {
|
|
if ($this->inited) {
|
|
return;
|
|
}
|
|
$this->initTrace();
|
|
$this->inited = true;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/exception.construct.php )
|
|
*
|
|
* Constructs the Exception.
|
|
*
|
|
* @message mixed The Exception message to throw.
|
|
* @code mixed The Exception code.
|
|
* @previous mixed The previous exception used for the exception
|
|
* chaining.
|
|
*/
|
|
function __construct($message = '', $code = 0, Exception $previous = null) {
|
|
$this->message = $message;
|
|
$this->code = $code;
|
|
$this->previous = $previous;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/exception.getmessage.php )
|
|
*
|
|
* Returns the Exception message.
|
|
*
|
|
* @return mixed Returns the Exception message as a string.
|
|
*/
|
|
function getMessage() {
|
|
return $this->message;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/exception.getprevious.php )
|
|
*
|
|
* Returns previous Exception (the third parameter of
|
|
* Exception::__construct()).
|
|
*
|
|
* @return mixed Returns the previous Exception if available or NULL
|
|
* otherwise.
|
|
*/
|
|
final function getPrevious() {
|
|
return $this->previous;
|
|
}
|
|
|
|
final function setPrevious(Exception $previous) {
|
|
$this->previous = $previous;
|
|
}
|
|
|
|
final function setPreviousChain(Exception $previous) {
|
|
$cur = $this;
|
|
$next = $cur->getPrevious();
|
|
while ($next instanceof Exception) {
|
|
$cur = $next;
|
|
$next = $cur->getPrevious;
|
|
}
|
|
$cur->setPrevious($previous);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/exception.getcode.php )
|
|
*
|
|
* Returns the Exception code.
|
|
*
|
|
* @return mixed Returns the exception code as integer in Exception
|
|
* but possibly as other type in Exception descendants
|
|
* (for example as string in PDOException).
|
|
*/
|
|
function getCode() {
|
|
return $this->code;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/exception.getfile.php )
|
|
*
|
|
* Get the name of the file the exception was created.
|
|
*
|
|
* @return mixed Returns the filename in which the exception was
|
|
* created.
|
|
*/
|
|
final function getFile() {
|
|
return $this->file;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/exception.getline.php )
|
|
*
|
|
* Get line number where the exception was created.
|
|
*
|
|
* @return mixed Returns the line number where the exception was
|
|
* created.
|
|
*/
|
|
final function getLine() {
|
|
return $this->line;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/exception.gettrace.php )
|
|
*
|
|
* Returns the Exception stack trace.
|
|
*
|
|
* @return mixed Returns the Exception stack trace as an array.
|
|
*/
|
|
final function getTrace() {
|
|
return $this->trace;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/exception.gettraceasstring.php )
|
|
*
|
|
* Returns the Exception stack trace as a string.
|
|
*
|
|
* @return mixed Returns the Exception stack trace as a string.
|
|
*/
|
|
final function getTraceAsString() {
|
|
$i = 0;
|
|
$s = "";
|
|
foreach ($this->getTrace() as $frame) {
|
|
if (!is_array($frame)) continue;
|
|
$s .= "#$i " .
|
|
(isset($frame['file']) ? $frame['file'] : "") . "(" .
|
|
(isset($frame['line']) ? $frame['line'] : "") . "): " .
|
|
(isset($frame['class']) ? $frame['class'] . $frame['type'] : "") .
|
|
$frame['function'] . "()\n";
|
|
$i++;
|
|
}
|
|
$s .= "#$i {main}";
|
|
return $s;
|
|
}
|
|
|
|
/* Overrideable */
|
|
// formated string for display
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/exception.tostring.php )
|
|
*
|
|
* Returns the string representation of the exception.
|
|
*
|
|
* @return mixed Returns the string representation of the exception.
|
|
*/
|
|
function __toString() {
|
|
return "exception '" . get_class($this) . "' with message '" .
|
|
$this->getMessage() . "' in " . $this->getFile() . ":" .
|
|
$this->getLine() . "\nStack trace:\n" . $this->getTraceAsString();
|
|
}
|
|
|
|
/**
|
|
* Derived classes may override the methods below if different behavior
|
|
* for initializing the trace is desired
|
|
*/
|
|
protected function initTrace() {
|
|
$this->trace = debug_backtrace(static::getTraceOptions());
|
|
// Remove top stack frames up to and including Exception::__init__,
|
|
// set the 'file' and 'line' properties appropriately
|
|
while (!empty($this->trace)) {
|
|
$top = array_shift($this->trace);
|
|
if (isset($top['class']) && isset($top['function']) &&
|
|
strcasecmp($top['class'], 'exception') === 0 &&
|
|
strcasecmp($top['function'], '__init__') === 0) {
|
|
if (isset($top['file'])) $this->file = $top['file'];
|
|
if (isset($top['line'])) $this->line = $top['line'];
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static function getTraceOptions() {
|
|
return self::$traceOpts;
|
|
}
|
|
|
|
public static function setTraceOptions($opts) {
|
|
self::$traceOpts = $opts;
|
|
}
|
|
}
|
|
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.logicexception.php )
|
|
*
|
|
* Exception that represents error in the program logic. This kind of
|
|
* exceptions should directly lead to a fix in your code.
|
|
*
|
|
*/
|
|
class LogicException extends Exception {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/class.badfunctioncallexception.php )
|
|
*
|
|
* Exception thrown if a callback refers to an undefined function or if
|
|
* some arguments are missing.
|
|
*
|
|
*/
|
|
class BadFunctionCallException extends LogicException {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.badmethodcallexception.php
|
|
* )
|
|
*
|
|
* Exception thrown if a callback refers to an undefined method or if some
|
|
* arguments are missing.
|
|
*
|
|
*/
|
|
class BadMethodCallException extends BadFunctionCallException {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.domainexception.php )
|
|
*
|
|
* Exception thrown if a value does not adhere to a defined valid data
|
|
* domain.
|
|
*
|
|
*/
|
|
class DomainException extends LogicException {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/class.invalidargumentexception.php )
|
|
*
|
|
* Exception thrown if an argument does not match with the expected value.
|
|
*
|
|
*/
|
|
class InvalidArgumentException extends LogicException {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.lengthexception.php )
|
|
*
|
|
* Exception thrown if a length is invalid.
|
|
*
|
|
*/
|
|
class LengthException extends LogicException {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.outofrangeexception.php )
|
|
*
|
|
* Exception thrown when an illegal index was requested. This represents
|
|
* errors that should be detected at compile time.
|
|
*
|
|
*/
|
|
class OutOfRangeException extends LogicException {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.runtimeexception.php )
|
|
*
|
|
* Exception thrown if an error which can only be found on runtime occurs.
|
|
*
|
|
*/
|
|
class RuntimeException extends Exception {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.outofboundsexception.php )
|
|
*
|
|
* Exception thrown if a value is not a valid key. This represents errors
|
|
* that cannot be detected at compile time.
|
|
*
|
|
*/
|
|
class OutOfBoundsException extends RuntimeException {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.overflowexception.php )
|
|
*
|
|
* Exception thrown when adding an element to a full container.
|
|
*
|
|
*/
|
|
class OverflowException extends RuntimeException {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.rangeexception.php )
|
|
*
|
|
* exception thrown to indicate range errors during program execution.
|
|
* Normally this means there was an arithmetic error other than
|
|
* under/overflow. This is the runtime version of DomainException.
|
|
*
|
|
*/
|
|
class RangeException extends RuntimeException {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.underflowexception.php )
|
|
*
|
|
* exception thrown when performing an invalid operation on an empty
|
|
* container, such as removing an element.
|
|
*
|
|
*/
|
|
class UnderflowException extends RuntimeException {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/class.unexpectedvalueexception.php )
|
|
*
|
|
* exception thrown if a value does not match with a set of values.
|
|
* Typically this happens when a function calls another function and
|
|
* expects the return value to be of a certain type or value not including
|
|
* arithmetic or buffer related errors.
|
|
*
|
|
*/
|
|
class UnexpectedValueException extends RuntimeException {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.countable.php )
|
|
*
|
|
* Classes implementing Countable can be used with the count() function.
|
|
*
|
|
*/
|
|
interface Countable {
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/countable.count.php )
|
|
*
|
|
* This method is executed when using the count() function on an object
|
|
* implementing Countable.
|
|
*
|
|
* @return mixed The custom count as an integer.
|
|
*
|
|
* The return value is cast to an integer.
|
|
*/
|
|
public function count();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.recursiveiterator.php )
|
|
*
|
|
* Classes implementing RecursiveIterator can be used to iterate over
|
|
* iterators recursively.
|
|
*
|
|
*/
|
|
interface RecursiveIterator extends Iterator {
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursiveiterator.getchildren.php )
|
|
*
|
|
* Returns an iterator for the current iterator entry.
|
|
*
|
|
* @return mixed An iterator for the current entry.
|
|
*/
|
|
public function getChildren();
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursiveiterator.haschildren.php )
|
|
*
|
|
* Returns if an iterator can be created for the current entry.
|
|
* RecursiveIterator::getChildren().
|
|
*
|
|
* @return mixed Returns TRUE if the current entry can be iterated
|
|
* over, otherwise returns FALSE.
|
|
*/
|
|
public function hasChildren();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.splheap.php )
|
|
*
|
|
* The SplHeap class provides the main functionalities of a Heap.
|
|
*
|
|
*/
|
|
abstract class SplHeap implements Iterator, Countable {
|
|
|
|
// Only here to be var_dump compatible with zend
|
|
private $flags = 0;
|
|
|
|
private $isCorrupted = false;
|
|
private $heap = array();
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splheap.construct.php )
|
|
*
|
|
* This constructs a new empty heap.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function __construct() {}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splheap.compare.php )
|
|
*
|
|
* Compare value1 with value2. Warning
|
|
*
|
|
* Throwing exceptions in SplHeap::compare() can corrupt the Heap and
|
|
* place it in a blocked state. You can unblock it by calling
|
|
* SplHeap::recoverFromCorruption(). However, some elements might not be
|
|
* placed correctly and it may hence break the heap-property.
|
|
*
|
|
* @value1 mixed The value of the first node being compared.
|
|
* @value2 mixed The value of the second node being compared.
|
|
*
|
|
* @return mixed Result of the comparison, positive integer if value1
|
|
* is greater than value2, 0 if they are equal,
|
|
* negative integer otherwise.
|
|
*
|
|
* Having multiple elements with the same value in a
|
|
* Heap is not recommended. They will end up in an
|
|
* arbitrary relative position.
|
|
*/
|
|
abstract public function compare($value1, $value2);
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splheap.extract.php )
|
|
*
|
|
*
|
|
* @return mixed The value of the extracted node.
|
|
*/
|
|
public function extract() {
|
|
$this->checkNotCorrupted();
|
|
if ($this->isEmpty()) {
|
|
throw new RuntimeException(
|
|
'Can\'t extract from an empty heap'
|
|
);
|
|
}
|
|
|
|
$result = $this->top();
|
|
$end = $this->highestUsedIndex();
|
|
$this->swapElements(0, $end);
|
|
unset($this->heap[$end]);
|
|
|
|
try {
|
|
$this->heapifyDown(0);
|
|
} catch (Exception $e) {
|
|
$this->isCorrupted = true;
|
|
throw $e;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splheap.insert.php )
|
|
*
|
|
* Insert value in the heap.
|
|
*
|
|
* @value mixed The value to insert.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function insert($value) {
|
|
$this->checkNotCorrupted();
|
|
$index = $this->lowestFreeIndex();
|
|
$this->heap[$index] = $value;
|
|
|
|
try {
|
|
$this->heapifyUp($index);
|
|
} catch (Exception $e) {
|
|
$this->isCorrupted = true;
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splheap.isempty.php )
|
|
*
|
|
*
|
|
* @return mixed Returns whether the heap is empty.
|
|
*/
|
|
public function isEmpty() {
|
|
return $this->count() == 0;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/splheap.recoverfromcorruption.php )
|
|
*
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function recoverFromCorruption() {
|
|
$this->isCorrupted = false;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splheap.count.php )
|
|
*
|
|
*
|
|
* @return mixed Returns the number of elements in the heap.
|
|
*/
|
|
public function count() {
|
|
return count($this->heap);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splheap.current.php )
|
|
*
|
|
* Get the current datastructure node.
|
|
*
|
|
* @return mixed The current node value.
|
|
*/
|
|
public function current() {
|
|
return $this->isEmpty() ? null : $this->top();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splheap.key.php )
|
|
*
|
|
* This function returns the current node index
|
|
*
|
|
* @return mixed The current node index.
|
|
*/
|
|
public function key() {
|
|
return $this->highestUsedIndex();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splheap.next.php )
|
|
*
|
|
* Move to the next node.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function next() {
|
|
if ($this->isEmpty()) {
|
|
// don't error, just silently stop
|
|
return;
|
|
}
|
|
$this->extract();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splheap.rewind.php )
|
|
*
|
|
* This rewinds the iterator to the beginning. This is a no-op for heaps
|
|
* as the iterator is virtual and in fact never moves from the top of the
|
|
* heap.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function rewind() {
|
|
// Do nothing, the iterator always points to the top element
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splheap.top.php )
|
|
*
|
|
*
|
|
* @return mixed The value of the node on the top.
|
|
*/
|
|
public function top() {
|
|
$this->checkNotCorrupted();
|
|
if ($this->isEmpty()) {
|
|
throw new RuntimeException(
|
|
'Can\'t peak at an empty heap'
|
|
);
|
|
}
|
|
|
|
return $this->heap[0];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splheap.valid.php )
|
|
*
|
|
* Checks if the heap contains any more nodes.
|
|
*
|
|
* @return mixed Returns TRUE if the heap contains any more nodes,
|
|
* FALSE otherwise.
|
|
*/
|
|
public function valid() {
|
|
return !$this->isEmpty();
|
|
}
|
|
|
|
private function heapifyUp($index) {
|
|
if ($index != 0) {
|
|
$parentIndex = self::parentIndex($index);
|
|
if ($this->compare($this->heap[$index],
|
|
$this->heap[$parentIndex]) > 0) {
|
|
$this->swapElements($parentIndex, $index);
|
|
$this->heapifyUp($parentIndex);
|
|
}
|
|
}
|
|
}
|
|
|
|
private function heapifyDown($index) {
|
|
$highestChildIndex = $this->getHighestChildIndex($index);
|
|
if ($highestChildIndex !== null &&
|
|
$this->compare($this->heap[$highestChildIndex],
|
|
$this->heap[$index]) > 0) {
|
|
$this->swapElements($index, $highestChildIndex);
|
|
$this->heapifyDown($highestChildIndex);
|
|
}
|
|
}
|
|
|
|
private function getHighestChildIndex($index) {
|
|
if (isset($this->heap[self::leftChildIndex($index)])) {
|
|
if (isset($this->heap[self::rightChildIndex($index)])) {
|
|
if ($this->compare($this->heap[self::rightChildIndex($index)],
|
|
$this->heap[self::leftChildIndex($index)]) > 0) {
|
|
return self::rightChildIndex($index);
|
|
} else {
|
|
return self::leftChildIndex($index);
|
|
}
|
|
} else {
|
|
return self::leftChildIndex($index);
|
|
}
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private function swapElements($firstIndex, $secondIndex) {
|
|
$temporary = $this->heap[$firstIndex];
|
|
$this->heap[$firstIndex] = $this->heap[$secondIndex];
|
|
$this->heap[$secondIndex] = $temporary;
|
|
}
|
|
|
|
private function lowestFreeIndex() {
|
|
return $this->count();
|
|
}
|
|
|
|
private function highestUsedIndex() {
|
|
return $this->count() - 1;
|
|
}
|
|
|
|
private function checkNotCorrupted() {
|
|
if ($this->isCorrupted) {
|
|
throw new RuntimeException(
|
|
'Heap is corrupted, heap properties are no longer ensured.'
|
|
);
|
|
}
|
|
}
|
|
|
|
private static function leftChildIndex($rootIndex) {
|
|
return 2 * $rootIndex + 1;
|
|
}
|
|
|
|
private static function rightChildIndex($rootIndex) {
|
|
return 2 * $rootIndex + 2;
|
|
}
|
|
|
|
private static function parentIndex($childIndex) {
|
|
return floor(($childIndex - 1) / 2);
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.splmaxheap.php )
|
|
*
|
|
* The SplMaxHeap class provides the main functionalities of a heap,
|
|
* keeping the maximum on the top.
|
|
*
|
|
*/
|
|
class SplMaxHeap extends SplHeap implements Iterator, Countable {
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splmaxheap.compare.php )
|
|
*
|
|
* Compare value1 with value2.
|
|
*
|
|
* @value1 mixed The value of the first node being compared.
|
|
* @value2 mixed The value of the second node being compared.
|
|
*
|
|
* @return mixed Result of the comparison, positive integer if value1
|
|
* is greater than value2, 0 if they are equal,
|
|
* negative integer otherwise.
|
|
*
|
|
* Having multiple elements with the same value in a
|
|
* Heap is not recommended. They will end up in an
|
|
* arbitrary relative position.
|
|
*/
|
|
function compare($value1, $value2) {
|
|
return $value1 - $value2;
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.splminheap.php )
|
|
*
|
|
* The SplMinHeap class provides the main functionalities of a heap,
|
|
* keeping the minimum on the top.
|
|
*
|
|
*/
|
|
class SplMinHeap extends SplHeap implements Iterator, Countable {
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splminheap.compare.php )
|
|
*
|
|
* Compare value1 with value2.
|
|
*
|
|
* @value1 mixed The value of the first node being compared.
|
|
* @value2 mixed The value of the second node being compared.
|
|
*
|
|
* @return mixed Result of the comparison, positive integer if value1
|
|
* is lower than value2, 0 if they are equal, negative
|
|
* integer otherwise.
|
|
*
|
|
* Having multiple elements with the same value in a
|
|
* Heap is not recommended. They will end up in an
|
|
* arbitrary relative position.
|
|
*/
|
|
function compare($value1, $value2) {
|
|
return $value2 - $value1;
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.splfileinfo.php )
|
|
*
|
|
* The SplFileInfo class offers a high-level object oriented interface to
|
|
* information for an individual file.
|
|
*
|
|
*/
|
|
class SplFileInfo {
|
|
|
|
private $fileName;
|
|
private $fileClass = "SplFileObject";
|
|
private $infoClass;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.construct.php )
|
|
*
|
|
* Creates a new SplFileInfo object for the file_name specified. The file
|
|
* does not need to exist, or be readable.
|
|
*
|
|
* @file_name mixed Path to the file.
|
|
*/
|
|
public function __construct($file_name) {
|
|
$this->setPathname($file_name);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getpath.php )
|
|
*
|
|
* Returns the path to the file, omitting the filename and any trailing
|
|
* slash.
|
|
*
|
|
* @return mixed Returns the path to the file.
|
|
*/
|
|
public function getPath() {
|
|
return dirname($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getfilename.php )
|
|
*
|
|
* Gets the filename without any path information.
|
|
*
|
|
* @return mixed The filename.
|
|
*/
|
|
public function getFilename() {
|
|
return $this->getBasename();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getfileinfo.php )
|
|
*
|
|
* This method gets an SplFileInfo object for the referenced file.
|
|
*
|
|
* @class_name mixed Name of an SplFileInfo derived class to use.
|
|
*
|
|
* @return mixed An SplFileInfo object created for the file.
|
|
*/
|
|
public function getFileInfo($class_name = null) {
|
|
if (!$class_name) {
|
|
$class_name = $this->fileClass;
|
|
}
|
|
return new $class_name($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getbasename.php )
|
|
*
|
|
* This method returns the base name of the file, directory, or link
|
|
* without path info.
|
|
*
|
|
* @suffix mixed Optional suffix to omit from the base name returned.
|
|
*
|
|
* @return mixed Returns the base name without path information.
|
|
*/
|
|
public function getBasename($suffix = "") {
|
|
return basename($this->getPathname(), $suffix);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getpathname.php )
|
|
*
|
|
* Returns the path to the file.
|
|
*
|
|
* @return mixed The path to the file.
|
|
*/
|
|
public function getPathname() {
|
|
return $this->fileName;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getpathinfo.php )
|
|
*
|
|
* Gets an SplFileInfo object for the parent of the current file.
|
|
*
|
|
* @class_name mixed Name of an SplFileInfo derived class to use.
|
|
*
|
|
* @return mixed Returns an SplFileInfo object for the parent path of
|
|
* the file.
|
|
*/
|
|
public function getPathInfo($class_name = null) {
|
|
if (!$class_name) {
|
|
$class_name = $this->fileClass;
|
|
}
|
|
return new $class_name($this->getPath());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getperms.php )
|
|
*
|
|
* Gets the file permissions for the file.
|
|
*
|
|
* @return mixed Returns the file permissions.
|
|
*/
|
|
public function getPerms() {
|
|
return fileperms($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getinode.php )
|
|
*
|
|
* Gets the inode number for the filesystem object.
|
|
*
|
|
* @return mixed Returns the inode number for the filesystem object.
|
|
*/
|
|
public function getInode() {
|
|
return fileinode($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getsize.php )
|
|
*
|
|
* Returns the filesize in bytes for the file referenced.
|
|
*
|
|
* @return mixed The filesize in bytes.
|
|
*/
|
|
public function getSize() {
|
|
return filesize($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getowner.php )
|
|
*
|
|
* Gets the file owner. The owner ID is returned in numerical format.
|
|
*
|
|
* @return mixed The owner id in numerical format.
|
|
*/
|
|
public function getOwner() {
|
|
return fileowner($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getgroup.php )
|
|
*
|
|
* Gets the file group. The group ID is returned in numerical format.
|
|
*
|
|
* @return mixed The group id in numerical format.
|
|
*/
|
|
public function getGroup() {
|
|
return filegroup($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getatime.php )
|
|
*
|
|
* Gets the last access time for the file.
|
|
*
|
|
* @return mixed Returns the time the file was last accessed.
|
|
*/
|
|
public function getATime() {
|
|
return fileatime($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getmtime.php )
|
|
*
|
|
* Returns the time when the contents of the file were changed. The time
|
|
* returned is a Unix timestamp.
|
|
*
|
|
* @return mixed Returns the last modified time for the file, in a
|
|
* Unix timestamp.
|
|
*/
|
|
public function getMTime() {
|
|
return filemtime($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getctime.php )
|
|
*
|
|
* Returns the inode change time for the file. The time returned is a Unix
|
|
* timestamp.
|
|
*
|
|
* @return mixed The last change time, in a Unix timestamp.
|
|
*/
|
|
public function getCTime() {
|
|
return filectime($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.gettype.php )
|
|
*
|
|
* Returns the type of the file referenced.
|
|
*
|
|
* @return mixed A string representing the type of the entry. May be
|
|
* one of file, link, or dir
|
|
*/
|
|
public function getType() {
|
|
return filetype($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getextension.php )
|
|
*
|
|
* Retrieves the file extension.
|
|
*
|
|
* @return mixed Returns a string containing the file extension, or
|
|
* an empty string if the file has no extension.
|
|
*/
|
|
public function getExtension() {
|
|
return pathinfo($this->getPathname(), PATHINFO_EXTENSION);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.iswritable.php )
|
|
*
|
|
* Checks if the current entry is writable.
|
|
*
|
|
* @return mixed Returns TRUE if writable, FALSE otherwise;
|
|
*/
|
|
public function isWritable() {
|
|
return is_writable($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.isreadable.php )
|
|
*
|
|
* Check if the file is readable.
|
|
*
|
|
* @return mixed Returns TRUE if readable, FALSE otherwise.
|
|
*/
|
|
public function isReadable() {
|
|
return is_readable($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.isexecutable.php )
|
|
*
|
|
* Checks if the file is executable.
|
|
*
|
|
* @return mixed Returns TRUE if executable, FALSE otherwise.
|
|
*/
|
|
public function isExecutable() {
|
|
return is_executable($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.isfile.php )
|
|
*
|
|
* Checks if the file referenced by this SplFileInfo object exists and is
|
|
* a regular file.
|
|
*
|
|
* @return mixed Returns TRUE if the file exists and is a regular
|
|
* file (not a link), FALSE otherwise.
|
|
*/
|
|
public function isFile() {
|
|
return is_file($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.isdir.php )
|
|
*
|
|
* This method can be used to determine if the file is a directory.
|
|
*
|
|
* @return mixed Returns TRUE if a directory, FALSE otherwise.
|
|
*/
|
|
public function isDir() {
|
|
return is_dir($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.islink.php )
|
|
*
|
|
* Use this method to check if the file referenced by the SplFileInfo
|
|
* object is a link.
|
|
*
|
|
* @return mixed Returns TRUE if the file is a link, FALSE otherwise.
|
|
*/
|
|
public function isLink() {
|
|
return is_link($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getlinktarget.php )
|
|
*
|
|
* Gets the target of a filesystem link.
|
|
*
|
|
* The target may not be the real path on the filesystem. Use
|
|
* SplFileInfo::getRealPath() to determine the true path on the filesystem.
|
|
*
|
|
* @return mixed Returns the target of the filesystem link.
|
|
*/
|
|
public function getLinkTarget() {
|
|
$link = @readlink($this->getPathname());
|
|
if ($link === false) {
|
|
throw new Exception(
|
|
'Unable to read link '.$this->getPathname()
|
|
);
|
|
}
|
|
return $link;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.getrealpath.php )
|
|
*
|
|
* This method expands all symbolic links, resolves relative references
|
|
* and returns the real path to the file.
|
|
*
|
|
* @return mixed Returns the path to the file.
|
|
*/
|
|
public function getRealPath() {
|
|
return realpath($this->getPathname());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.tostring.php )
|
|
*
|
|
* This method will return the file name of the referenced file.
|
|
*
|
|
* @return mixed Returns the path to the file.
|
|
*/
|
|
public function __toString() {
|
|
return $this->getPathname();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.openfile.php )
|
|
*
|
|
* Creates an SplFileObject object of the file. This is useful because
|
|
* SplFileObject contains additional methods for manipulating the file
|
|
* whereas SplFileInfo is only useful for gaining information, like whether
|
|
* the file is writable.
|
|
*
|
|
* @mode mixed The mode for opening the file. See the fopen()
|
|
* documentation for descriptions of possible modes.
|
|
* The default is read only.
|
|
* @use_include_path
|
|
* mixed When set to TRUE, the filename is also searched for
|
|
* within the include_path
|
|
* @context mixed Refer to the context section of the manual for a
|
|
* description of contexts.
|
|
*
|
|
* @return mixed The opened file as an SplFileObject object.
|
|
*/
|
|
public function openFile($mode = 'r', $use_include_path = false,
|
|
$context = null) {
|
|
$class_name = $this->fileClass;
|
|
return new $class_name(
|
|
$this->getPathname(),
|
|
$mode,
|
|
$use_include_path,
|
|
$context
|
|
);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.setfileclass.php )
|
|
*
|
|
* Set the class name which SplFileInfo will use to open files with when
|
|
* openFile() is called. The class name passed to this method must be
|
|
* derived from SplFileObject.
|
|
*
|
|
* @class_name mixed The class name to use when openFile() is called.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function setFileClass($class_name = "SplFileObject") {
|
|
$this->fileClass = $class_name;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileinfo.setinfoclass.php )
|
|
*
|
|
* Use this method to set a custom class which will be used when
|
|
* getFileInfo and getPathInfo are called. The class name passed to this
|
|
* method must be derived from SplFileInfo.
|
|
*
|
|
* @class_name mixed The class name to use.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function setInfoClass($class_name = "SplFileInfo") {
|
|
$this->infoClass = $class_name;
|
|
}
|
|
|
|
protected function setPathname($file_name) {
|
|
if ($file_name !== false) {
|
|
$file_name = rtrim($file_name, '/');
|
|
}
|
|
$this->fileName = $file_name;
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.seekableiterator.php )
|
|
*
|
|
* The Seekable iterator.
|
|
*
|
|
*/
|
|
interface SeekableIterator extends Iterator {
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/seekableiterator.seek.php )
|
|
*
|
|
* Seeks to a given position in the iterator.
|
|
*
|
|
* @position mixed The position to seek to.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function seek($position);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.directoryiterator.php )
|
|
*
|
|
* The DirectoryIterator class provides a simple interface for viewing the
|
|
* contents of filesystem directories.
|
|
*
|
|
*/
|
|
class DirectoryIterator extends SplFileInfo
|
|
implements Traversable, SeekableIterator {
|
|
|
|
private $dir;
|
|
private $dirName;
|
|
private $index;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/directoryiterator.construct.php
|
|
* )
|
|
*
|
|
* Constructs a new directory iterator from a path.
|
|
*
|
|
* @path mixed The path of the directory to traverse.
|
|
*/
|
|
public function __construct($path) {
|
|
// next() will fill in the correct filename
|
|
parent::__construct(null);
|
|
|
|
if (!is_dir($path)) {
|
|
throw new UnexpectedValueException(
|
|
"DirectoryIterator::__construct($path): failed to open dir"
|
|
);
|
|
}
|
|
|
|
$this->dirName = rtrim($path, DIRECTORY_SEPARATOR);
|
|
$this->dir = opendir($path);
|
|
$this->rewind();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/directoryiterator.current.php )
|
|
*
|
|
* Get the current DirectoryIterator item.
|
|
*
|
|
* @return mixed The current DirectoryIterator item.
|
|
*/
|
|
public function current() {
|
|
return clone $this;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/directoryiterator.key.php )
|
|
*
|
|
* Get the key for the current DirectoryIterator item.
|
|
*
|
|
* @return mixed The key for the current DirectoryIterator item.
|
|
*/
|
|
public function key() {
|
|
return $this->index;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/directoryiterator.next.php )
|
|
*
|
|
* Move forward to the next DirectoryIterator item.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function next() {
|
|
$file_name = readdir($this->dir);
|
|
if ($file_name === false) {
|
|
$this->setPathname(false);
|
|
} else {
|
|
$this->setPathname($this->dirName.DIRECTORY_SEPARATOR.$file_name);
|
|
}
|
|
$this->index++;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/directoryiterator.rewind.php )
|
|
*
|
|
* Rewind the DirectoryIterator back to the start.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function rewind() {
|
|
rewinddir($this->dir);
|
|
$this->index = -1;
|
|
$this->next();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/directoryiterator.seek.php )
|
|
*
|
|
* Seek to a given position in the DirectoryIterator.
|
|
*
|
|
* @position mixed The zero-based numeric position to seek to.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function seek($position) {
|
|
for ($i = $this->index; $i < $position; $i++) {
|
|
$this->next();
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/directoryiterator.tostring.php )
|
|
*
|
|
* Get the file name of the current DirectoryIterator item.
|
|
*
|
|
* @return mixed Returns the file name of the current
|
|
* DirectoryIterator item.
|
|
*/
|
|
public function __toString() {
|
|
return $this->getFilename();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/directoryiterator.valid.php )
|
|
*
|
|
* Check whether current DirectoryIterator position is a valid file.
|
|
*
|
|
* @return mixed Returns TRUE if the position is valid, otherwise
|
|
* FALSE
|
|
*/
|
|
public function valid() {
|
|
return $this->getPathname() !== false;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/directoryiterator.isdot.php )
|
|
*
|
|
* Determines if the current DirectoryIterator item is a directory and
|
|
* either . or ...
|
|
*
|
|
* @return mixed TRUE if the entry is . or .., otherwise FALSE
|
|
*/
|
|
public function isDot() {
|
|
return $this->getFilename() == '.' || $this->getFilename() == '..';
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.filesystemiterator.php )
|
|
*
|
|
* The Filesystem iterator
|
|
*
|
|
*/
|
|
class FilesystemIterator extends DirectoryIterator
|
|
implements SeekableIterator, Traversable, Iterator {
|
|
|
|
const CURRENT_AS_PATHNAME = 32;
|
|
const CURRENT_AS_FILEINFO = 0;
|
|
const CURRENT_AS_SELF = 16;
|
|
const CURRENT_MODE_MASK = 240;
|
|
const KEY_AS_PATHNAME = 0;
|
|
const KEY_AS_FILENAME = 256;
|
|
const FOLLOW_SYMLINKS = 512;
|
|
const KEY_MODE_MASK = 3840;
|
|
const NEW_CURRENT_AND_KEY = 256;
|
|
const SKIP_DOTS = 4096;
|
|
const UNIX_PATHS = 8192;
|
|
|
|
protected $flags;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filesystemiterator.construct.php
|
|
* )
|
|
*
|
|
* Constructs a new filesystem iterator from the path.
|
|
*
|
|
* @path mixed The path of the filesystem item to be iterated over.
|
|
* @flags mixed Flags may be provided which will affect the behavior
|
|
* of some methods. A list of the flags can found under
|
|
* FilesystemIterator predefined constants. They can
|
|
* also be set later with
|
|
* FilesystemIterator::setFlags()
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function __construct(string $path, int $flags = null) {
|
|
parent::__construct($path);
|
|
if ($flags === null) {
|
|
$flags = FilesystemIterator::KEY_AS_PATHNAME |
|
|
FilesystemIterator::CURRENT_AS_FILEINFO |
|
|
FilesystemIterator::SKIP_DOTS;
|
|
}
|
|
$this->flags = $flags;
|
|
$this->goPastDotsIfNeeded();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filesystemiterator.current.php )
|
|
*
|
|
* Get file information of the current element.
|
|
*
|
|
* @return mixed The filename, file information, or $this depending
|
|
* on the set flags. See the FilesystemIterator
|
|
* constants.
|
|
*/
|
|
public function current() {
|
|
$f = parent::current();
|
|
if ($this->flags & FilesystemIterator::CURRENT_AS_PATHNAME) {
|
|
return $f->getPathname();
|
|
} else if ($this->flags & FilesystemIterator::CURRENT_AS_SELF) {
|
|
return $this;
|
|
}
|
|
// FilesystemIterator::CURRENT_AS_FILEINFO == 0
|
|
return $f;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filesystemiterator.getflags.php
|
|
* )
|
|
*
|
|
* Gets the handling flags, as set in FilesystemIterator::__construct() or
|
|
* FilesystemIterator::setFlags().
|
|
*
|
|
* @return mixed The integer value of the set flags.
|
|
*/
|
|
public function getFlags() {
|
|
return $this->flags;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filesystemiterator.key.php )
|
|
*
|
|
*
|
|
* @return mixed Returns the pathname or filename depending on the
|
|
* set flags. See the FilesystemIterator constants.
|
|
*/
|
|
public function key() {
|
|
if ($this->flags & FilesystemIterator::KEY_AS_FILENAME) {
|
|
return parent::current()->getFileName();
|
|
}
|
|
// FilesystemIterator::KEY_AS_PATHNAME == 0
|
|
return parent::current()->getPathName();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filesystemiterator.next.php )
|
|
*
|
|
* Move to the next file.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function next() {
|
|
parent::next();
|
|
$this->goPastDotsIfNeeded();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filesystemiterator.rewind.php )
|
|
*
|
|
* Rewinds the directory back to the start.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function rewind() {
|
|
parent::rewind();
|
|
$this->goPastDotsIfNeeded();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filesystemiterator.setflags.php
|
|
* )
|
|
*
|
|
* Sets handling flags.
|
|
*
|
|
* @flags mixed The handling flags to set. See the
|
|
* FilesystemIterator constants.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function setFlags(int $flags) {
|
|
$this->flags = $flags;
|
|
}
|
|
|
|
private function goPastDotsIfNeeded() {
|
|
if ($this->flags & FilesystemIterator::SKIP_DOTS) {
|
|
$f = parent::current();
|
|
while ($f && $f->isDot()) {
|
|
parent::next();
|
|
$f = parent::current();
|
|
}
|
|
}
|
|
}
|
|
|
|
public function __toString() {
|
|
return $this->getPathname();
|
|
}
|
|
}
|
|
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/class.recursivedirectoryiterator.php )
|
|
*
|
|
* The RecursiveDirectoryIterator provides an interface for iterating
|
|
* recursively over filesystem directories.
|
|
*
|
|
*/
|
|
class RecursiveDirectoryIterator extends FilesystemIterator
|
|
implements RecursiveIterator {
|
|
|
|
const FOLLOW_SYMLINKS = 512;
|
|
|
|
private $subPath;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursivedirectoryiterator.construct.php )
|
|
*
|
|
* Constructs a RecursiveDirectoryIterator() for the provided path.
|
|
*
|
|
* @path mixed The path of the directory to be iterated over.
|
|
* @flags mixed Flags may be provided which will affect the behavior
|
|
* of some methods. A list of the flags can found under
|
|
* FilesystemIterator predefined constants. They can
|
|
* also be set later with
|
|
* FilesystemIterator::setFlags().
|
|
*
|
|
* @return mixed Returns the newly created
|
|
* RecursiveDirectoryIterator.
|
|
*/
|
|
public function __construct($path, $flags = null) {
|
|
if ($flags === null) {
|
|
$flags = FilesystemIterator::KEY_AS_PATHNAME |
|
|
FilesystemIterator::CURRENT_AS_FILEINFO;
|
|
}
|
|
parent::__construct($path, $flags);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursivedirectoryiterator.haschildren.php )
|
|
*
|
|
*
|
|
* @return mixed Returns whether the current entry is a directory,
|
|
* but not '.' or '..'
|
|
*/
|
|
public function hasChildren() {
|
|
if ($this->isDot()) {
|
|
return false;
|
|
}
|
|
if (is_link($this->getFilename()) &&
|
|
!($this->flags & self::FOLLOW_SYMLINKS)) {
|
|
return false;
|
|
}
|
|
return $this->isDir();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursivedirectoryiterator.getchildren.php )
|
|
*
|
|
*
|
|
* @return mixed The filename, file information, or $this depending
|
|
* on the set flags. See the FilesystemIterator
|
|
* constants.
|
|
*/
|
|
public function getChildren() {
|
|
if ($this->getFlags() & FilesystemIterator::CURRENT_AS_PATHNAME) {
|
|
return $this->current();
|
|
}
|
|
$child = new self($this->getPathname(), $this->getFlags());
|
|
$child->subPath = $this->subPath;
|
|
if ($child->subPath) {
|
|
$child->subPath .= DIRECTORY_SEPARATOR;
|
|
}
|
|
$child->subPath .= $this->getPathname();
|
|
return $child;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursivedirectoryiterator.getsubpath.php )
|
|
*
|
|
* Gets the sub path. WarningThis function is currently not documented;
|
|
* only its argument list is available.
|
|
*
|
|
* @return mixed The sub path (sub directory).
|
|
*/
|
|
public function getSubPath() {
|
|
return $this->subPath;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursivedirectoryiterator.getsubpathname.php )
|
|
*
|
|
* Gets the sub path and filename. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed The sub path (sub directory) and filename.
|
|
*/
|
|
public function getSubPathname() {
|
|
return ($this->subPath ? $this->subPath . DIRECTORY_SEPARATOR : '') .
|
|
$this->getPathname();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursivedirectoryiterator.rewind.php )
|
|
*
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function rewind() {
|
|
parent::rewind();
|
|
if ($this->isDot()) {
|
|
$this->next();
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursivedirectoryiterator.next.php )
|
|
*
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function next() {
|
|
do {
|
|
parent::next();
|
|
} while ($this->valid() && $this->isDot());
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.splfileobject.php )
|
|
*
|
|
* The SplFileObject class offers an object oriented interface for a file.
|
|
*
|
|
*/
|
|
class SplFileObject extends SplFileInfo
|
|
implements RecursiveIterator, SeekableIterator {
|
|
|
|
const DROP_NEW_LINE = 1;
|
|
const READ_AHEAD = 2;
|
|
const SKIP_EMPTY = 4;
|
|
const READ_CSV = 8;
|
|
|
|
private $delimiter = ',';
|
|
private $enclosure = '"';
|
|
private $escape = '\\';
|
|
private $flags;
|
|
private $maxLineLen = 0;
|
|
private $currentLineNum = 0;
|
|
private $rsrc;
|
|
private $currentLine = false;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.construct.php )
|
|
*
|
|
* Construct a new file object.
|
|
*
|
|
* @filename mixed The file to read. TipA URL can be used as a filename
|
|
* with this function if the fopen wrappers have been
|
|
* enabled. See fopen() for more details on how to
|
|
* specify the filename. See the Supported Protocols
|
|
* and Wrappers for links to information about what
|
|
* abilities the various wrappers have, notes on their
|
|
* usage, and information on any predefined variables
|
|
* they may provide.
|
|
* @open_mode mixed The mode in which to open the file. See fopen() for
|
|
* a list of allowed modes.
|
|
* @use_include_path
|
|
* mixed Whether to search in the include_path for filename.
|
|
* @context mixed A valid context resource created with
|
|
* stream_context_create().
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function __construct($filename, $open_mode = 'r',
|
|
$use_include_path = false,
|
|
$context = null) {
|
|
parent::__construct($filename);
|
|
if (!is_string($open_mode)) {
|
|
throw new Exception(
|
|
'SplFileObject::__construct() expects parameter 2 to be string, '.
|
|
gettype($open_mode).' given'
|
|
);
|
|
}
|
|
$this->rsrc = fopen($filename, $open_mode, $use_include_path, $context);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.eof.php )
|
|
*
|
|
* Determine whether the end of file has been reached
|
|
*
|
|
* @return mixed Returns TRUE if file is at EOF, FALSE otherwise.
|
|
*/
|
|
public function eof() {
|
|
return feof($this->rsrc);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.fflush.php )
|
|
*
|
|
* Forces a write of all buffered output to the file.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function fflush() {
|
|
return fflush($this->rsrc);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.fgetc.php )
|
|
*
|
|
* Gets a character from the file.
|
|
*
|
|
* @return mixed Returns a string containing a single character read
|
|
* from the file or FALSE on EOF. WarningThis function
|
|
* may return Boolean FALSE, but may also return a
|
|
* non-Boolean value which evaluates to FALSE. Please
|
|
* read the section on Booleans for more information.
|
|
* Use the === operator for testing the return value of
|
|
* this function.
|
|
*/
|
|
public function fgetc() {
|
|
return fgetc($this->rsrc);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.fgetcsv.php )
|
|
*
|
|
* Gets a line from the file which is in CSV format and returns an array
|
|
* containing the fields read.
|
|
*
|
|
* @delimiter mixed The field delimiter (one character only). Defaults
|
|
* as a comma or the value set using
|
|
* SplFileObject::setCsvControl().
|
|
* @enclosure mixed The field enclosure character (one character only).
|
|
* Defaults as a double quotation mark or the value set
|
|
* using SplFileObject::setCsvControl().
|
|
* @escape mixed The escape character (one character only). Defaults
|
|
* as a backslash (\) or the value set using
|
|
* SplFileObject::setCsvControl().
|
|
*
|
|
* @return mixed Returns an indexed array containing the fields read,
|
|
* or FALSE on error.
|
|
*
|
|
* A blank line in a CSV file will be returned as an
|
|
* array comprising a single NULL field unless using
|
|
* SplFileObject::SKIP_EMPTY |
|
|
* SplFileObject::DROP_NEW_LINE, in which case empty
|
|
* lines are skipped.
|
|
*/
|
|
public function fgetcsv(
|
|
$delimiter = null,
|
|
$enclosure = null,
|
|
$escape = null) {
|
|
|
|
if (!$delimiter) {
|
|
$delimiter = $this->delimiter;
|
|
}
|
|
if (!$enclosure) {
|
|
$enclosure = $this->enclosure;
|
|
}
|
|
if (!$escape) {
|
|
$escape = $this->escape;
|
|
}
|
|
|
|
return fgetcsv(
|
|
$this->rsrc,
|
|
$this->maxLineLen,
|
|
$delimiter,
|
|
$enclosure,
|
|
$escape
|
|
);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.fgets.php )
|
|
*
|
|
* Gets a line from the file.
|
|
*
|
|
* @return mixed Returns a string containing the next line from the
|
|
* file, or FALSE on error.
|
|
*/
|
|
public function fgets() {
|
|
$line = fgets($this->rsrc);
|
|
if ($this->flags & self::DROP_NEW_LINE) {
|
|
$line = rtrim($line);
|
|
}
|
|
return $line;
|
|
}
|
|
|
|
public function getCurrentLine() {
|
|
return $this->fgets();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.fgetss.php )
|
|
*
|
|
* Identical to SplFileObject::fgets(), except that
|
|
* SplFileObject::fgetss() attempts to strip any HTML and PHP tags from the
|
|
* text it reads.
|
|
*
|
|
* @allowable_tags
|
|
* mixed Optional parameter to specify tags which should not
|
|
* be stripped.
|
|
*
|
|
* @return mixed Returns a string containing the next line of the
|
|
* file with HTML and PHP code stripped, or FALSE on
|
|
* error.
|
|
*/
|
|
public function fgetss($allowable_tags = null) {
|
|
return fgetss($this->rsrc, $this->maxLineLen, $allowable_tags);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.flock.php )
|
|
*
|
|
* Locks or unlocks the file in the same portable way as flock().
|
|
*
|
|
* @operation mixed operation is one of the following: LOCK_SH to
|
|
* acquire a shared lock (reader). LOCK_EX to acquire
|
|
* an exclusive lock (writer). LOCK_UN to release a
|
|
* lock (shared or exclusive). LOCK_NB to not block
|
|
* while locking (not supported on Windows).
|
|
* @wouldblock mixed Set to TRUE if the lock would block (EWOULDBLOCK
|
|
* errno condition).
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function flock($operation, &$wouldblock) {
|
|
return flock($this->rsrc, $operation, $wouldblock);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.fpassthru.php )
|
|
*
|
|
* Reads to EOF on the given file pointer from the current position and
|
|
* writes the results to the output buffer.
|
|
*
|
|
* You may need to call SplFileObject::rewind() to reset the file pointer
|
|
* to the beginning of the file if you have already written data to the
|
|
* file.
|
|
*
|
|
* @return mixed Returns the number of characters read from handle
|
|
* and passed through to the output.
|
|
*/
|
|
public function fpassthru() {
|
|
return fpassthru($this->rsrc);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.fputcsv.php )
|
|
*
|
|
* Writes the fields array to the file as a CSV line.
|
|
*
|
|
* @fields mixed An array of values.
|
|
* @delimiter mixed The optional delimiter parameter sets the field
|
|
* delimiter (one character only).
|
|
* @enclosure mixed The optional enclosure parameter sets the field
|
|
* enclosure (one character only).
|
|
*
|
|
* @return mixed Returns the length of the written string or FALSE on
|
|
* failure.
|
|
*
|
|
* Returns FALSE, and does not write the CSV line to
|
|
* the file, if the delimiter or enclosure parameter is
|
|
* not a single character.
|
|
*/
|
|
public function fputcsv($fields, $delimiter = null, $enclosure = null) {
|
|
if (!$delimiter) {
|
|
$delimiter = $this->delimiter;
|
|
}
|
|
if (!$enclosure) {
|
|
$enclosure = $this->enclosure;
|
|
}
|
|
|
|
return fputcsv(
|
|
$this->rsrc,
|
|
$fields,
|
|
$delimiter,
|
|
$enclosure
|
|
);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.fscanf.php )
|
|
*
|
|
* Reads a line from the file and interprets it according to the specified
|
|
* format, which is described in the documentation for sprintf().
|
|
*
|
|
* Any whitespace in the format string matches any whitespace in the line
|
|
* from the file. This means that even a tab \t in the format string can
|
|
* match a single space character in the input stream.
|
|
*
|
|
* @format mixed The specified format as described in the sprintf()
|
|
* documentation.
|
|
*
|
|
* @return mixed If only one parameter is passed to this method, the
|
|
* values parsed will be returned as an array.
|
|
* Otherwise, if optional parameters are passed, the
|
|
* function will return the number of assigned values.
|
|
* The optional parameters must be passed by reference.
|
|
*/
|
|
public function fscanf($format) {
|
|
$argv = array($this->rsrc);
|
|
for ($i = 0; $i < func_num_args(); $i++) {
|
|
$argv[] = func_get_arg($i);
|
|
}
|
|
return call_user_func_array('fscanf', $argv);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.fseek.php )
|
|
*
|
|
* Seek to a position in the file measured in bytes from the beginning of
|
|
* the file, obtained by adding offset to the position specified by whence.
|
|
*
|
|
* @offset mixed The offset. A negative value can be used to move
|
|
* backwards through the file which is useful when
|
|
* SEEK_END is used as the whence value.
|
|
* @whence mixed whence values are: SEEK_SET - Set position equal to
|
|
* offset bytes. SEEK_CUR - Set position to current
|
|
* location plus offset. SEEK_END - Set position to
|
|
* end-of-file plus offset.
|
|
*
|
|
* If whence is not specified, it is assumed to be
|
|
* SEEK_SET.
|
|
*
|
|
* @return mixed Returns 0 if the seek was successful, -1 otherwise.
|
|
* Note that seeking past EOF is not considered an
|
|
* error.
|
|
*/
|
|
public function fseek($offset, $whence) {
|
|
return fseek($this->rsrc, $offset, $whence);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.fstat.php )
|
|
*
|
|
* Gathers the statistics of the file. Behaves identically to fstat().
|
|
*
|
|
* @return mixed Returns an array with the statistics of the file;
|
|
* the format of the array is described in detail on
|
|
* the stat() manual page.
|
|
*/
|
|
public function fstat() {
|
|
return fstat($this->rsrc);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.ftell.php )
|
|
*
|
|
* Returns the position of the file pointer which represents the current
|
|
* offset in the file stream.
|
|
*
|
|
* @return mixed Returns the position of the file pointer as an
|
|
* integer, or FALSE on error.
|
|
*/
|
|
public function ftell() {
|
|
return ftell($this->rsrc);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.ftruncate.php )
|
|
*
|
|
* Truncates the file to size bytes.
|
|
*
|
|
* @size mixed The size to truncate to.
|
|
*
|
|
* If size is larger than the file it is extended with
|
|
* null bytes.
|
|
*
|
|
* If size is smaller than the file, the extra data
|
|
* will be lost.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function ftruncate($size) {
|
|
return ftruncate($this->rsrc, $size);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.fwrite.php )
|
|
*
|
|
* Writes the contents of string to the file
|
|
*
|
|
* @str mixed The string to be written to the file.
|
|
* @length mixed If the length argument is given, writing will stop
|
|
* after length bytes have been written or the end of
|
|
* string is reached, whichever comes first.
|
|
*
|
|
* @return mixed Returns the number of bytes written, or NULL on
|
|
* error.
|
|
*/
|
|
public function fwrite($str, $length) {
|
|
return fwrite($this->rsrc, $str, $length);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.getchildren.php )
|
|
*
|
|
* An SplFileObject does not have children so this method returns NULL.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function getChildren() {
|
|
return null; // An SplFileOjbect does not have children
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.getcsvcontrol.php
|
|
* )
|
|
*
|
|
* Gets the delimiter and enclosure character used for parsing CSV fields.
|
|
*
|
|
* @return mixed Returns an indexed array containing the delimiter
|
|
* and enclosure character.
|
|
*/
|
|
public function getCsvControl() {
|
|
return array($this->delimiter, $this->enclosure);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.getflags.php )
|
|
*
|
|
* Gets the flags set for an instance of SplFileObject as an integer.
|
|
*
|
|
* @return mixed Returns an integer representing the flags.
|
|
*/
|
|
public function getFlags() {
|
|
return $this->flags;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.getmaxlinelen.php
|
|
* )
|
|
*
|
|
* Gets the maximum line length as set by SplFileObject::setMaxLineLen().
|
|
*
|
|
* @return mixed Returns the maximum line length if one has been set
|
|
* with SplFileObject::setMaxLineLen(), default is 0.
|
|
*/
|
|
public function getMaxLineLen() {
|
|
return $this->maxLineLen;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.haschildren.php )
|
|
*
|
|
* An SplFileObject does not have children so this method always return
|
|
* FALSE.
|
|
*
|
|
* @return mixed Returns FALSE
|
|
*/
|
|
public function hasChildren() {
|
|
return false; // An SplFileOjbect does not have children
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.setcsvcontrol.php
|
|
* )
|
|
*
|
|
* Sets the delimiter and enclosure character for parsing CSV fields.
|
|
*
|
|
* @delimiter mixed The field delimiter (one character only).
|
|
* @enclosure mixed The field enclosure character (one character only).
|
|
* @escape mixed The field escape character (one character only).
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function setCsvControl(
|
|
$delimiter = ",",
|
|
$enclosure = "\"",
|
|
$escape = "\\") {
|
|
|
|
$this->delimiter = $delimiter;
|
|
$this->enclosure = $enclosure;
|
|
$this->escape = $escape;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.setflags.php )
|
|
*
|
|
* Sets the flags to be used by the SplFileObject.
|
|
*
|
|
* @flags mixed Bit mask of the flags to set. See SplFileObject
|
|
* constants for the available flags.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function setFlags($flags) {
|
|
$this->flags = $flags;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.setmaxlinelen.php
|
|
* )
|
|
*
|
|
* Sets the maximum length of a line to be read.
|
|
*
|
|
* @max_len mixed The maximum length of a line.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function setMaxLineLen($max_len) {
|
|
if ($max_len < 0) {
|
|
throw new DomainException(
|
|
'Maximum line length must be greater than or equal zero'
|
|
);
|
|
}
|
|
$this->maxLineLen = $max_len;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.current.php )
|
|
*
|
|
* Retrieves the current line of the file.
|
|
*
|
|
* @return mixed Retrieves the current line of the file. If the
|
|
* SplFileObject::READ_CSV flag is set, this method
|
|
* returns an array containing the current line parsed
|
|
* as CSV data.
|
|
*/
|
|
public function current() {
|
|
if ($this->currentLine === false) {
|
|
$this->currentLine = $this->fgets();
|
|
}
|
|
return $this->currentLine;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.key.php )
|
|
*
|
|
* Gets the current line number.
|
|
*
|
|
* This number may not reflect the actual line number in the file if
|
|
* SplFileObject::setMaxLineLen() is used to read fixed lengths of the
|
|
* file.
|
|
*
|
|
* @return mixed Returns the current line number.
|
|
*/
|
|
public function key() {
|
|
return $this->currentLineNum;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.next.php )
|
|
*
|
|
* Moves ahead to the next line in the file.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function next() {
|
|
$this->currentLine = false;
|
|
$this->currentLineNum++;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.rewind.php )
|
|
*
|
|
* Rewinds the file back to the first line.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function rewind() {
|
|
rewind($this->rsrc);
|
|
$this->currentLineNum = 0;
|
|
$this->currentLine = false;
|
|
if ($this->flags & self::READ_AHEAD) {
|
|
$this->current();
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.seek.php )
|
|
*
|
|
* Seek to specified line in the file.
|
|
*
|
|
* @line_pos mixed The zero-based line number to seek to.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function seek($line_pos) {
|
|
$this->rewind();
|
|
for ($i = 0; $i < $line_pos; $i++) {
|
|
$this->current();
|
|
$this->next();
|
|
}
|
|
$this->current();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splfileobject.valid.php )
|
|
*
|
|
* Check whether EOF has been reached.
|
|
*
|
|
* @return mixed Returns TRUE if not reached EOF, FALSE otherwise.
|
|
*/
|
|
public function valid() {
|
|
if ($this->flags & self::READ_AHEAD) {
|
|
return $this->current() !== false;
|
|
}
|
|
return !$this->eof();
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.outeriterator.php )
|
|
*
|
|
* Classes implementing OuterIterator can be used to iterate over
|
|
* iterators.
|
|
*
|
|
*/
|
|
interface OuterIterator extends Iterator {
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/outeriterator.getinneriterator.php )
|
|
*
|
|
* Returns the inner iterator for the current iterator entry.
|
|
*
|
|
* @return mixed The inner iterator for the current entry.
|
|
*/
|
|
public function getInnerIterator();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.iteratoriterator.php )
|
|
*
|
|
* This iterator wrapper allows the conversion of anything that is
|
|
* Traversable into an Iterator. It is important to understand that most
|
|
* classes that do not implement Iterators have reasons as most likely they
|
|
* do not allow the full Iterator feature set. If so, techniques should be
|
|
* provided to prevent misuse, otherwise expect exceptions or fatal errors.
|
|
*
|
|
*/
|
|
class IteratorIterator implements OuterIterator {
|
|
private $iterator;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/iteratoriterator.construct.php )
|
|
*
|
|
* Creates an iterator from anything that is traversable.
|
|
*
|
|
* @iterator mixed The traversable iterator.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function __construct(Traversable $iterator) {
|
|
if ($iterator instanceof IteratorAggregate) {
|
|
$iterator = $iterator->getIterator();
|
|
}
|
|
if ($iterator instanceof Iterator) {
|
|
$this->iterator = $iterator;
|
|
} else {
|
|
throw new Exception(
|
|
"Need to pass a Traversable that is convertable to an iterator");
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/iteratoriterator.getinneriterator.php )
|
|
*
|
|
* Get the inner iterator.
|
|
*
|
|
* @return mixed The inner iterator as passed to
|
|
* IteratorIterator::__construct().
|
|
*/
|
|
public function getInnerIterator() {
|
|
return $this->iterator;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/iteratoriterator.valid.php )
|
|
*
|
|
* Checks if the iterator is valid.
|
|
*
|
|
* @return mixed Returns TRUE if the iterator is valid, otherwise
|
|
* FALSE
|
|
*/
|
|
public function valid() {
|
|
return $this->iterator->valid();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/iteratoriterator.key.php )
|
|
*
|
|
* Get the key of the current element.
|
|
*
|
|
* @return mixed The key of the current element.
|
|
*/
|
|
public function key() {
|
|
return $this->iterator->key();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/iteratoriterator.current.php )
|
|
*
|
|
* Get the value of the current element.
|
|
*
|
|
* @return mixed The value of the current element.
|
|
*/
|
|
public function current() {
|
|
return $this->iterator->current();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/iteratoriterator.next.php )
|
|
*
|
|
* Forward to the next element.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function next() {
|
|
return $this->iterator->next();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/iteratoriterator.rewind.php )
|
|
*
|
|
* Rewinds to the first element.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function rewind() {
|
|
return $this->iterator->rewind();
|
|
}
|
|
|
|
public function __call($func, $params) {
|
|
return call_user_func_array(array($this->iterator, $func), $params);
|
|
}
|
|
}
|
|
|
|
interface DebuggerCommand {
|
|
/**
|
|
* Called when DebuggerClient needs to auto-complete. Inside this function,
|
|
* one can call $client->addCompletion() with a list of strings or one of
|
|
* those DebuggerClient::AUTO_COMPLETE_ constants.
|
|
*/
|
|
public function onAutoComplete($client);
|
|
|
|
/**
|
|
* Called when DebuggerClient needs to displays help on the command. Inside
|
|
* this function, one can call $client->help() and its different forms.
|
|
*
|
|
* @return TRUE if helped, FALSE if any error
|
|
*/
|
|
public function help($client);
|
|
|
|
/**
|
|
* How to process the command on client side.
|
|
*
|
|
* @return TRUE for success, FALSE for failure
|
|
*/
|
|
public function onClient($client);
|
|
|
|
/**
|
|
* How to process the command on server side.
|
|
*
|
|
* @return TRUE for success, FALSE for failure
|
|
*/
|
|
public function onServer($proxy);
|
|
}
|
|
|
|
/**
|
|
* Helps application inserting an artificial frame in xhprof's reporting.
|
|
*/
|
|
class XhprofFrame {
|
|
public function __construct($name) {
|
|
xhprof_frame_begin($name);
|
|
}
|
|
public function __destruct() {
|
|
xhprof_frame_end();
|
|
}
|
|
}
|
|
|
|
interface Awaitable {
|
|
public function getWaitHandle();
|
|
}
|
|
|
|
class InvalidOperationException extends RuntimeException {}
|
|
|
|
trait IterableTrait {
|
|
public function view() {
|
|
return $this;
|
|
}
|
|
public function map($callback) {
|
|
return new MappedIterable($this, $callback);
|
|
}
|
|
public function filter($callback) {
|
|
return new FilteredIterable($this, $callback);
|
|
}
|
|
public function zip($iterable) {
|
|
return new ZippedIterable($this, $iterable);
|
|
}
|
|
}
|
|
|
|
trait KeyedIterableTrait {
|
|
public function view() {
|
|
return $this;
|
|
}
|
|
public function map($callback) {
|
|
return new MappedKeyedIterable($this, $callback);
|
|
}
|
|
public function filter($callback) {
|
|
return new FilteredKeyedIterable($this, $callback);
|
|
}
|
|
public function zip($iterable) {
|
|
return new ZippedKeyedIterable($this, $iterable);
|
|
}
|
|
public function keys() {
|
|
return new KeysIterable($this);
|
|
}
|
|
public function kvzip() {
|
|
return new KVZippedIterable($this);
|
|
}
|
|
}
|
|
|
|
class MappedIterator implements Iterator {
|
|
private $it;
|
|
private $fn;
|
|
|
|
public function __construct($it, $fn) {
|
|
$this->it = $it;
|
|
$this->fn = $fn;
|
|
}
|
|
public function __clone() {
|
|
$this->it = clone $this->it;
|
|
}
|
|
public function rewind() {
|
|
$this->it->rewind();
|
|
}
|
|
public function valid() {
|
|
return $this->it->valid();
|
|
}
|
|
public function next() {
|
|
$this->it->next();
|
|
}
|
|
public function key() {
|
|
return null;
|
|
}
|
|
public function current() {
|
|
return ($this->fn)($this->it->current());
|
|
}
|
|
}
|
|
|
|
class MappedIterable implements Iterable {
|
|
use IterableTrait;
|
|
|
|
private $iterable;
|
|
private $fn;
|
|
|
|
public function __construct($iterable, $fn) {
|
|
$this->iterable = $iterable;
|
|
$this->fn = $fn;
|
|
}
|
|
public function getIterator() {
|
|
return new MappedIterator($this->iterable->getIterator(), $this->fn);
|
|
}
|
|
}
|
|
|
|
class MappedKeyedIterator implements KeyedIterator {
|
|
private $it;
|
|
private $fn;
|
|
|
|
public function __construct($it, $fn) {
|
|
$this->it = $it;
|
|
$this->fn = $fn;
|
|
}
|
|
public function __clone() {
|
|
$this->it = clone $this->it;
|
|
}
|
|
public function rewind() {
|
|
$this->it->rewind();
|
|
}
|
|
public function valid() {
|
|
return $this->it->valid();
|
|
}
|
|
public function next() {
|
|
$this->it->next();
|
|
}
|
|
public function key() {
|
|
return $this->it->key();
|
|
}
|
|
public function current() {
|
|
return ($this->fn)($this->it->current());
|
|
}
|
|
}
|
|
|
|
class MappedKeyedIterable implements KeyedIterable {
|
|
use KeyedIterableTrait;
|
|
|
|
private $iterable;
|
|
private $fn;
|
|
|
|
public function __construct($iterable, $fn) {
|
|
$this->iterable = $iterable;
|
|
$this->fn = $fn;
|
|
}
|
|
public function getIterator() {
|
|
return new MappedKeyedIterator($this->iterable->getIterator(), $this->fn);
|
|
}
|
|
}
|
|
|
|
class FilteredIterator implements Iterator {
|
|
private $it;
|
|
private $fn;
|
|
|
|
public function __construct($it, $fn) {
|
|
$this->it = $it;
|
|
$this->fn = $fn;
|
|
}
|
|
public function __clone() {
|
|
$this->it = clone $this->it;
|
|
}
|
|
public function rewind() {
|
|
$it = $this->it;
|
|
$fn = $this->fn;
|
|
$it->rewind();
|
|
while ($it->valid() && !$fn($it->current())) {
|
|
$it->next();
|
|
}
|
|
}
|
|
public function valid() {
|
|
return $this->it->valid();
|
|
}
|
|
public function next() {
|
|
$it = $this->it;
|
|
$fn = $this->fn;
|
|
$it->next();
|
|
while ($it->valid() && !$fn($it->current())) {
|
|
$it->next();
|
|
}
|
|
}
|
|
public function key() {
|
|
return null;
|
|
}
|
|
public function current() {
|
|
return $this->it->current();
|
|
}
|
|
}
|
|
|
|
class FilteredIterable implements Iterable {
|
|
use IterableTrait;
|
|
|
|
private $iterable;
|
|
private $fn;
|
|
|
|
public function __construct($iterable, $fn) {
|
|
$this->iterable = $iterable;
|
|
$this->fn = $fn;
|
|
}
|
|
public function getIterator() {
|
|
return new FilteredIterator($this->iterable->getIterator(), $this->fn);
|
|
}
|
|
}
|
|
|
|
class FilteredKeyedIterator implements KeyedIterator {
|
|
private $it;
|
|
private $fn;
|
|
|
|
public function __construct($it, $fn) {
|
|
$this->it = $it;
|
|
$this->fn = $fn;
|
|
}
|
|
public function __clone() {
|
|
$this->it = clone $this->it;
|
|
}
|
|
public function rewind() {
|
|
$it = $this->it;
|
|
$fn = $this->fn;
|
|
$it->rewind();
|
|
while ($it->valid() && !$fn($it->current())) {
|
|
$it->next();
|
|
}
|
|
}
|
|
public function valid() {
|
|
return $this->it->valid();
|
|
}
|
|
public function next() {
|
|
$it = $this->it;
|
|
$fn = $this->fn;
|
|
$it->next();
|
|
while ($it->valid() && !$fn($it->current())) {
|
|
$it->next();
|
|
}
|
|
}
|
|
public function key() {
|
|
return $this->it->key();
|
|
}
|
|
public function current() {
|
|
return $this->it->current();
|
|
}
|
|
}
|
|
|
|
class FilteredKeyedIterable implements KeyedIterable {
|
|
use KeyedIterableTrait;
|
|
|
|
private $iterable;
|
|
private $fn;
|
|
|
|
public function __construct($iterable, $fn) {
|
|
$this->iterable = $iterable;
|
|
$this->fn = $fn;
|
|
}
|
|
public function getIterator() {
|
|
return new FilteredKeyedIterator($this->iterable->getIterator(), $this->fn);
|
|
}
|
|
}
|
|
|
|
class ZippedIterator implements Iterator {
|
|
private $it1;
|
|
private $it2;
|
|
|
|
public function __construct($it1, $it2) {
|
|
$this->it1 = $it1;
|
|
$this->it2 = $it2;
|
|
}
|
|
public function __clone() {
|
|
$this->it1 = clone $this->it1;
|
|
$this->it2 = clone $this->it2;
|
|
}
|
|
public function rewind() {
|
|
$this->it1->rewind();
|
|
$this->it2->rewind();
|
|
}
|
|
public function valid() {
|
|
return ($this->it1->valid() && $this->it2->valid());
|
|
}
|
|
public function next() {
|
|
$this->it1->next();
|
|
$this->it2->next();
|
|
}
|
|
public function key() {
|
|
return null;
|
|
}
|
|
public function current() {
|
|
return Pair {$this->it1->current(), $this->it2->current()};
|
|
}
|
|
}
|
|
|
|
class ZippedIterable implements Iterable {
|
|
use IterableTrait;
|
|
|
|
private $iterable1;
|
|
private $iterable2;
|
|
|
|
public function __construct($iterable1, $iterable2) {
|
|
$this->iterable1 = $iterable1;
|
|
$this->iterable2 = $iterable2;
|
|
}
|
|
public function getIterator() {
|
|
return new ZippedIterator($this->iterable1->getIterator(),
|
|
$this->iterable2->getIterator());
|
|
}
|
|
}
|
|
|
|
class ZippedKeyedIterator implements KeyedIterator {
|
|
private $it1;
|
|
private $it2;
|
|
|
|
public function __construct($it1, $it2) {
|
|
$this->it1 = $it1;
|
|
$this->it2 = $it2;
|
|
}
|
|
public function __clone() {
|
|
$this->it1 = clone $this->it1;
|
|
$this->it2 = clone $this->it2;
|
|
}
|
|
public function rewind() {
|
|
$this->it1->rewind();
|
|
$this->it2->rewind();
|
|
}
|
|
public function valid() {
|
|
return ($this->it1->valid() && $this->it2->valid());
|
|
}
|
|
public function next() {
|
|
$this->it1->next();
|
|
$this->it2->next();
|
|
}
|
|
public function key() {
|
|
return $this->it1->key();
|
|
}
|
|
public function current() {
|
|
return Pair {$this->it1->current(), $this->it2->current()};
|
|
}
|
|
}
|
|
|
|
class ZippedKeyedIterable implements KeyedIterable {
|
|
use KeyedIterableTrait;
|
|
|
|
private $iterable1;
|
|
private $iterable2;
|
|
|
|
public function __construct($iterable1, $iterable2) {
|
|
$this->iterable1 = $iterable1;
|
|
$this->iterable2 = $iterable2;
|
|
}
|
|
public function getIterator() {
|
|
return new ZippedKeyedIterator($this->iterable1->getIterator(),
|
|
$this->iterable2->getIterator());
|
|
}
|
|
}
|
|
|
|
class KeysIterator implements Iterator {
|
|
private $it;
|
|
|
|
public function __construct($it) {
|
|
$this->it = $it;
|
|
}
|
|
public function __clone() {
|
|
$this->it = clone $this->it;
|
|
}
|
|
public function rewind() {
|
|
$this->it->rewind();
|
|
}
|
|
public function valid() {
|
|
return $this->it->valid();
|
|
}
|
|
public function next() {
|
|
$this->it->next();
|
|
}
|
|
public function key() {
|
|
return null;
|
|
}
|
|
public function current() {
|
|
return $this->it->key();
|
|
}
|
|
}
|
|
|
|
class KeysIterable implements Iterable {
|
|
use IterableTrait;
|
|
|
|
private $iterable;
|
|
|
|
public function __construct($iterable) {
|
|
$this->iterable = $iterable;
|
|
}
|
|
public function getIterator() {
|
|
return new KeysIterator($this->iterable->getIterator());
|
|
}
|
|
}
|
|
|
|
class KVZippedIterator implements Iterator {
|
|
private $it;
|
|
|
|
public function __construct($it) {
|
|
$this->it = $it;
|
|
}
|
|
public function __clone() {
|
|
$this->it = clone $this->it;
|
|
}
|
|
public function rewind() {
|
|
$this->it->rewind();
|
|
}
|
|
public function valid() {
|
|
return $this->it->valid();
|
|
}
|
|
public function next() {
|
|
$this->it->next();
|
|
}
|
|
public function key() {
|
|
return null;
|
|
}
|
|
public function current() {
|
|
return Pair {$this->it->key(), $this->it->current()};
|
|
}
|
|
}
|
|
|
|
class KVZippedIterable implements Iterable {
|
|
use IterableTrait;
|
|
|
|
private $iterable;
|
|
|
|
public function __construct($iterable) {
|
|
$this->iterable = $iterable;
|
|
}
|
|
public function getIterator() {
|
|
return new KVZippedIterator($this->iterable->getIterator());
|
|
}
|
|
}
|
|
|
|
interface ConstCollection extends Countable {
|
|
public function isEmpty();
|
|
public function count();
|
|
public function items();
|
|
}
|
|
|
|
interface OutputCollection {
|
|
public function add($e);
|
|
public function addAll($iterable);
|
|
}
|
|
|
|
interface Collection extends ConstCollection,
|
|
OutputCollection {
|
|
public function clear();
|
|
}
|
|
|
|
interface ConstSetAccess {
|
|
public function contains($m);
|
|
}
|
|
|
|
interface SetAccess extends ConstSetAccess {
|
|
public function remove($m);
|
|
}
|
|
|
|
interface ConstIndexAccess {
|
|
public function at($k);
|
|
public function get($k);
|
|
public function containsKey($k);
|
|
}
|
|
|
|
interface IndexAccess extends ConstIndexAccess {
|
|
public function set($k,$v);
|
|
public function setAll($iterable);
|
|
public function removeKey($k);
|
|
}
|
|
|
|
interface ConstMapAccess extends ConstSetAccess,
|
|
ConstIndexAccess {
|
|
}
|
|
|
|
interface MapAccess extends ConstMapAccess,
|
|
SetAccess,
|
|
IndexAccess {
|
|
}
|
|
|
|
interface Indexish extends KeyedTraversable {
|
|
}
|
|
|
|
interface ConstVector extends ConstCollection,
|
|
ConstIndexAccess,
|
|
KeyedIterable {
|
|
}
|
|
|
|
interface MutableVector extends ConstVector,
|
|
Collection,
|
|
IndexAccess {
|
|
}
|
|
|
|
interface ConstMap extends ConstCollection,
|
|
ConstMapAccess,
|
|
KeyedIterable {
|
|
}
|
|
|
|
interface MutableMap extends ConstMap,
|
|
Collection,
|
|
MapAccess {
|
|
}
|
|
|
|
interface ConstSet extends ConstCollection,
|
|
ConstSetAccess,
|
|
Iterable {
|
|
}
|
|
|
|
interface MutableSet extends ConstSet,
|
|
Collection,
|
|
SetAccess {
|
|
}
|
|
|
|
class IterableView implements Iterable {
|
|
public $iterable;
|
|
|
|
public function __construct($iterable) { $this->iterable = $iterable; }
|
|
public function getIterator() { return $this->iterable->getIterator(); }
|
|
public function view() {
|
|
return $this;
|
|
}
|
|
public function map($callback) {
|
|
return new MappedIterable($this->iterable, $callback);
|
|
}
|
|
public function filter($callback) {
|
|
return new FilteredIterable($this->iterable, $callback);
|
|
}
|
|
public function zip($iterable) {
|
|
return new ZippedIterable($this->iterable, $iterable);
|
|
}
|
|
}
|
|
|
|
class KeyedIterableView implements KeyedIterable {
|
|
public $iterable;
|
|
|
|
public function __construct($iterable) { $this->iterable = $iterable; }
|
|
public function getIterator() { return $this->iterable->getIterator(); }
|
|
public function view() {
|
|
return $this;
|
|
}
|
|
public function map($callback) {
|
|
return new MappedKeyedIterable($this->iterable, $callback);
|
|
}
|
|
public function filter($callback) {
|
|
return new FilteredKeyedIterable($this->iterable, $callback);
|
|
}
|
|
public function zip($iterable) {
|
|
return new ZippedKeyedIterable($this->iterable, $iterable);
|
|
}
|
|
public function keys() {
|
|
return new KeysIterable($this->iterable);
|
|
}
|
|
public function kvzip() {
|
|
return new KVZippedIterable($this->iterable);
|
|
}
|
|
}
|
|
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.domexception.php )
|
|
*
|
|
* DOM operations raise exceptions under particular circumstances, i.e.,
|
|
* when an operation is impossible to perform for logical reasons.
|
|
*
|
|
* See also Exceptions.
|
|
*
|
|
*/
|
|
class DOMException extends Exception {
|
|
public function __construct($message, $code) {
|
|
parent::__construct($message, $code);
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.directory.php )
|
|
*
|
|
* Instances of Directory are created by calling the dir() function, not
|
|
* by the new operator.
|
|
*
|
|
*/
|
|
class Directory {
|
|
public $path;
|
|
public $handle;
|
|
|
|
public function __construct($path) {
|
|
$this->path = $path;
|
|
$this->handle = opendir($path);
|
|
}
|
|
|
|
public function read() {
|
|
return readdir($this->handle);
|
|
}
|
|
|
|
public function rewind() {
|
|
rewinddir($this->handle);
|
|
}
|
|
|
|
public function close() {
|
|
closedir($this->handle);
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.jsonserializable.php )
|
|
*
|
|
* Objects implementing JsonSerializable can customize their JSON
|
|
* representation when encoded with json_encode().
|
|
*
|
|
*/
|
|
interface JsonSerializable {
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/jsonserializable.jsonserialize.php )
|
|
*
|
|
* Serializes the object to a value that can be serialized natively by
|
|
* json_encode().
|
|
*
|
|
* @return mixed Returns data which can be serialized by
|
|
* json_encode(), which is a value of any type other
|
|
* than a resource.
|
|
*/
|
|
public function jsonSerialize();
|
|
}
|
|
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.arrayaccess.php )
|
|
*
|
|
* Interface to provide accessing objects as arrays.
|
|
*
|
|
*/
|
|
interface ArrayAccess {
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayaccess.offsetexists.php )
|
|
*
|
|
* Whether or not an offset exists.
|
|
*
|
|
* This method is executed when using isset() or empty() on objects
|
|
* implementing ArrayAccess.
|
|
*
|
|
* When using empty() ArrayAccess::offsetGet() will be called and checked
|
|
* if empty only if ArrayAccess::offsetExists() returns TRUE.
|
|
*
|
|
* @index mixed An offset to check for.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*
|
|
* The return value will be casted to boolean if
|
|
* non-boolean was returned.
|
|
*/
|
|
public function offsetExists($index);
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayaccess.offsetget.php )
|
|
*
|
|
* Returns the value at specified offset.
|
|
*
|
|
* This method is executed when checking if offset is empty().
|
|
*
|
|
* @index mixed The offset to retrieve.
|
|
*
|
|
* @return mixed Can return all value types.
|
|
*/
|
|
public function offsetGet($index);
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayaccess.offsetset.php )
|
|
*
|
|
* Assigns a value to the specified offset.
|
|
*
|
|
* @index mixed The offset to assign the value to.
|
|
* @newvalue mixed The value to set.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function offsetSet($index, $newvalue);
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayaccess.offsetunset.php )
|
|
*
|
|
* Unsets an offset.
|
|
*
|
|
* This method will not be called when type-casting to (unset)
|
|
*
|
|
* @index mixed The offset to unset.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function offsetUnset($index);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.errorexception.php )
|
|
*
|
|
* An Error Exception.
|
|
*
|
|
*/
|
|
class ErrorException extends Exception {
|
|
protected $severity;
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/errorexception.construct.php )
|
|
*
|
|
* Constructs the Exception.
|
|
*
|
|
* @message mixed The Exception message to throw.
|
|
* @code mixed The Exception code.
|
|
* @severity mixed The severity level of the exception.
|
|
* @filename mixed The filename where the exception is thrown.
|
|
* @lineno mixed The line number where the exception is thrown.
|
|
*/
|
|
public function __construct($message = "", $code = 0, $severity = 0,
|
|
$filename = null, $lineno = null) {
|
|
parent::__construct($message, $code);
|
|
$this->severity = $severity;
|
|
if ($filename !== null) {
|
|
$this->file = $filename;
|
|
}
|
|
if ($lineno !== null) {
|
|
$this->line = $lineno;
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/errorexception.getseverity.php )
|
|
*
|
|
* Returns the severity of the exception.
|
|
*
|
|
* @return mixed Returns the severity level of the exception.
|
|
*/
|
|
final public function getSeverity() { return $this->severity; }
|
|
}
|
|
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.serializable.php )
|
|
*
|
|
* Interface for customized serializing.
|
|
*
|
|
* Classes that implement this interface no longer support __sleep() and
|
|
* __wakeup(). The method serialize is called whenever an instance needs to
|
|
* be serialized. This does not invoke __destruct() or has any other side
|
|
* effect unless programmed inside the method. When the data is
|
|
* unserialized the class is known and the appropriate unserialize() method
|
|
* is called as a constructor instead of calling __construct(). If you need
|
|
* to execute the standard constructor you may do so in the method.
|
|
*
|
|
*/
|
|
interface Serializable {
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/serializable.serialize.php )
|
|
*
|
|
* Should return the string representation of the object.
|
|
*
|
|
* This method acts as the destructor of the object. The __destruct()
|
|
* method will not be called after this method.
|
|
*
|
|
* @return mixed Returns the string representation of the object or
|
|
* NULL
|
|
*/
|
|
public function serialize();
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/serializable.unserialize.php )
|
|
*
|
|
* Called during unserialization of the object.
|
|
*
|
|
* This method acts as the constructor of the object. The __construct()
|
|
* method will not be called after this method.
|
|
*
|
|
* @serialized mixed The string representation of the object.
|
|
*
|
|
* @return mixed The return value from this method is ignored.
|
|
*/
|
|
public function unserialize($serialized);
|
|
}
|
|
|
|
// default base
|
|
class stdClass {
|
|
}
|
|
|
|
// used in unserialize() for unknown classes
|
|
class __PHP_Incomplete_Class {
|
|
public $__PHP_Incomplete_Class_Name;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.pdoexception.php )
|
|
*
|
|
* Represents an error raised by PDO. You should not throw a PDOException
|
|
* from your own code. See Exceptions for more information about Exceptions
|
|
* in PHP.
|
|
*
|
|
*/
|
|
class PDOException extends Exception {
|
|
public function __construct() {
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// helpers
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.reflector.php )
|
|
*
|
|
* Reflector is an interface implemented by all exportable Reflection
|
|
* classes.
|
|
*
|
|
*/
|
|
interface Reflector {
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflector.tostring.php )
|
|
*
|
|
* To string. WarningThis function is currently not documented; only its
|
|
* argument list is available.
|
|
*
|
|
*/
|
|
public function __toString();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.reflectionexception.php )
|
|
*
|
|
* The ReflectionException class.
|
|
*
|
|
*/
|
|
class ReflectionException extends Exception {
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// parameter
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.reflectionparameter.php )
|
|
*
|
|
* The ReflectionParameter class retrieves information about function's or
|
|
* method's parameters.
|
|
*
|
|
* To introspect function parameters, first create an instance of the
|
|
* ReflectionFunction or ReflectionMethod classes and then use their
|
|
* ReflectionFunctionAbstract::getParameters() method to retrieve an array
|
|
* of parameters.
|
|
*
|
|
*/
|
|
class ReflectionParameter implements Reflector {
|
|
public $info;
|
|
public $name;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionparameter.construct.php )
|
|
*
|
|
* Constructs a ReflectionParameter class. WarningThis function is
|
|
* currently not documented; only its argument list is available.
|
|
*
|
|
* @func mixed The function to reflect parameters from.
|
|
* @param mixed The parameter.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function __construct($func, $param) {
|
|
if ($func && $param) {
|
|
$params = $func->getParameters();
|
|
$this->info = $params[$param]->info;
|
|
$this->name = $this->info['name'];
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionparameter.tostring.php
|
|
* )
|
|
*
|
|
* To string. WarningThis function is currently not documented; only its
|
|
* argument list is available.
|
|
*
|
|
*/
|
|
public function __toString() {
|
|
// TODO
|
|
return "";
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionparameter.export.php )
|
|
*
|
|
* Exports. WarningThis function is currently not documented; only its
|
|
* argument list is available.
|
|
*
|
|
* @func mixed The function name.
|
|
* @param mixed The parameter name.
|
|
* @ret mixed Setting to TRUE will return the export, as opposed
|
|
* to emitting it. Setting to FALSE (the default) will
|
|
* do the opposite.
|
|
*
|
|
* @return mixed The exported reflection.
|
|
*/
|
|
public static function export($func, $param, $ret=false) {
|
|
$obj = new ReflectionParameter($func, $param);
|
|
$str = (string)$obj;
|
|
if ($ret) {
|
|
return $str;
|
|
}
|
|
print $str;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionparameter.getname.php
|
|
* )
|
|
*
|
|
* Gets the name of the parameter.
|
|
*
|
|
* @return mixed The name of the reflected parameter.
|
|
*/
|
|
public function getName() {
|
|
return $this->info['name'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionparameter.ispassedbyreference.php )
|
|
*
|
|
* Checks if the parameter is passed in by reference. WarningThis function
|
|
* is currently not documented; only its argument list is available.
|
|
*
|
|
* @return mixed TRUE if the parameter is passed in by reference,
|
|
* otherwise FALSE
|
|
*/
|
|
public function isPassedByReference() {
|
|
return isset($this->info['ref']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionparameter.getdeclaringclass.php )
|
|
*
|
|
* Gets the declaring class. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed A ReflectionClass object.
|
|
*/
|
|
public function getDeclaringClass() {
|
|
if (empty($this->info['class'])) {
|
|
return null;
|
|
}
|
|
return new ReflectionClass($this->info['class']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionparameter.getdeclaringfunction.php )
|
|
*
|
|
* Gets the declaring function. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed A ReflectionFunction object.
|
|
*/
|
|
public function getDeclaringFunction() {
|
|
if (empty($this->info['class'])) {
|
|
return new ReflectionFunction($this->info['function']);
|
|
}
|
|
return new ReflectionMethod($this->info['class'], $this->info['function']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionparameter.getclass.php
|
|
* )
|
|
*
|
|
* Gets a class. WarningThis function is currently not documented; only
|
|
* its argument list is available.
|
|
*
|
|
* @return mixed A ReflectionClass object.
|
|
*/
|
|
public function getClass() {
|
|
if (empty($this->info['type'])) {
|
|
return null;
|
|
}
|
|
$ltype = strtolower($this->info['type']);
|
|
if (hphp_scalar_typehints_enabled()) {
|
|
$nonClassTypehints = array(
|
|
'bool' => 1,
|
|
'boolean' => 1,
|
|
'int' => 1,
|
|
'integer' => 1,
|
|
'real' => 1,
|
|
'double' => 1,
|
|
'float' => 1,
|
|
'string' => 1,
|
|
'array' => 1
|
|
);
|
|
if (isset($nonClassTypehints[$ltype])) {
|
|
return null;
|
|
}
|
|
} else if ($ltype === 'array') {
|
|
return null;
|
|
}
|
|
return new ReflectionClass($this->info['type']);
|
|
}
|
|
|
|
public function getTypehintText() {
|
|
if (isset($this->info['type'])) {
|
|
return $this->info['type'];
|
|
}
|
|
return '';
|
|
}
|
|
|
|
public function getTypeText() {
|
|
if (isset($this->info['type_hint'])) {
|
|
return $this->info['type_hint'];
|
|
}
|
|
return '';
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionparameter.isarray.php
|
|
* )
|
|
*
|
|
* Checks if the parameter expects an array.
|
|
*
|
|
* @return mixed TRUE if an array is expected, FALSE otherwise.
|
|
*/
|
|
public function isArray() {
|
|
return $this->info['type'] == 'array';
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionparameter.allowsnull.php )
|
|
*
|
|
* Checks whether the parameter allows NULL. WarningThis function is
|
|
* currently not documented; only its argument list is available.
|
|
*
|
|
* @return mixed TRUE if NULL is allowed, otherwise FALSE
|
|
*/
|
|
public function allowsNull() {
|
|
return isset($this->info['nullable']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionparameter.isoptional.php )
|
|
*
|
|
* Checks if the parameter is optional.
|
|
*
|
|
* @return mixed TRUE if the parameter is optional, otherwise FALSE
|
|
*/
|
|
public function isOptional() {
|
|
return array_key_exists('default', $this->info);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionparameter.isdefaultvalueavailable.php
|
|
* )
|
|
*
|
|
* Checks if a default value for the parameter is available.
|
|
*
|
|
* @return mixed TRUE if a default value is available, otherwise
|
|
* FALSE
|
|
*/
|
|
public function isDefaultValueAvailable() {
|
|
return array_key_exists('default', $this->info);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionparameter.getdefaultvalue.php )
|
|
*
|
|
* Gets the default value of the parameter for a user-defined function or
|
|
* method. If the parameter is not optional a ReflectionException will be
|
|
* thrown.
|
|
*
|
|
* @return mixed The parameters default value.
|
|
*/
|
|
public function getDefaultValue() {
|
|
if (!$this->isOptional()) {
|
|
throw new ReflectionException('Parameter is not optional');
|
|
}
|
|
$defaultValue = $this->info['default'];
|
|
if ($defaultValue instanceof stdclass) {
|
|
if (isset($defaultValue->class)) {
|
|
return hphp_get_class_constant($defaultValue->class,
|
|
$defaultValue->name);
|
|
}
|
|
hphp_throw_fatal_error($defaultValue->msg);
|
|
}
|
|
return $defaultValue;
|
|
}
|
|
|
|
public function getDefaultValueText() {
|
|
if (isset($this->info['defaultText'])) {
|
|
return $this->info['defaultText'];
|
|
}
|
|
return '';
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionparameter.getposition.php )
|
|
*
|
|
* Gets the position of the parameter.
|
|
*
|
|
* @return mixed The position of the parameter, left to right,
|
|
* starting at position #0.
|
|
*/
|
|
public function getPosition() {
|
|
return $this->info['index'];
|
|
}
|
|
|
|
public function getAttribute($name) {
|
|
$attrs = $this->info['attributes'];
|
|
return isset($attrs[$name]) ? $attrs[$name] : null;
|
|
}
|
|
|
|
public function getAttributes() {
|
|
return $this->info['attributes'];
|
|
}
|
|
|
|
public function getAttributeRecursive($name) {
|
|
$attrs = $this->getAttributesRecursive();
|
|
return isset($attrs[$name]) ? $attrs[$name] : null;
|
|
}
|
|
|
|
public function getAttributesRecursive() {
|
|
if (!isset($this->info['class'])) {
|
|
return $this->getAttributes();
|
|
}
|
|
|
|
$attrs = array();
|
|
$class = $this->getDeclaringClass();
|
|
$function_name = $this->info['function'];
|
|
$index = $this->info['index'];
|
|
self::collectAttributes(&$attrs, $class, $function_name, $index);
|
|
return $attrs;
|
|
}
|
|
|
|
private static function collectAttributes(&$attrs, $class, $function_name,
|
|
$index) {
|
|
if ($class->hasMethod($function_name)) {
|
|
$method = $class->getMethod($function_name);
|
|
$params = $method->getParameters();
|
|
if (count($params) >= $index) {
|
|
$attrs += $params[$index]->getAttributes();
|
|
}
|
|
}
|
|
|
|
$parent = $class->getParentClass();
|
|
if ($parent) {
|
|
self::collectAttributes(
|
|
&$attrs,
|
|
$parent,
|
|
$function_name,
|
|
$index);
|
|
}
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/class.reflectionfunctionabstract.php )
|
|
*
|
|
* A parent class to ReflectionFunction, read its description for details.
|
|
*
|
|
*/
|
|
class ReflectionFunctionAbstract {
|
|
public $info;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.getname.php )
|
|
*
|
|
* Get the name of the function. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed The name of the function.
|
|
*/
|
|
public function getName() {
|
|
return $this->info['name'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.isinternal.php )
|
|
*
|
|
* Checks whether the function is internal, as opposed to user-defined.
|
|
* WarningThis function is currently not documented; only its argument list
|
|
* is available.
|
|
*
|
|
* @return mixed TRUE if it's internal, otherwise FALSE
|
|
*/
|
|
public function isInternal() {
|
|
return isset($this->info['internal']);
|
|
}
|
|
|
|
public function getClosure() {
|
|
return $this->info['closure'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.isclosure.php )
|
|
*
|
|
* Checks whether it's a closure. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed TRUE if it's a closure, otherwise FALSE
|
|
*/
|
|
public function isClosure() {
|
|
return !empty($this->info['is_closure']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.isgenerator.php )
|
|
*
|
|
* WarningThis function is currently not documented; only its argument
|
|
* list is available.
|
|
*
|
|
* @return mixed Returns TRUE if the function is generator, FALSE if
|
|
* it is not or NULL on failure.
|
|
*/
|
|
public function isGenerator() {
|
|
return !empty($this->info['is_generator']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.isuserdefined.php )
|
|
*
|
|
* Checks whether the function is user-defined, as opposed to internal.
|
|
* WarningThis function is currently not documented; only its argument list
|
|
* is available.
|
|
*
|
|
* @return mixed TRUE if it's user-defined, otherwise false;
|
|
*/
|
|
public function isUserDefined() {
|
|
return !isset($this->info['internal']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.getfilename.php )
|
|
*
|
|
* Gets the file name from a user-defined function. WarningThis function
|
|
* is currently not documented; only its argument list is available.
|
|
*
|
|
* @return mixed The file name.
|
|
*/
|
|
public function getFileName() {
|
|
return $this->info['file'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.getstartline.php )
|
|
*
|
|
* Gets the starting line number of the function. WarningThis function is
|
|
* currently not documented; only its argument list is available.
|
|
*
|
|
* @return mixed The starting line number.
|
|
*/
|
|
public function getStartLine() {
|
|
return $this->info['line1'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.getendline.php )
|
|
*
|
|
* Get the ending line number. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed The ending line number of the user defined function,
|
|
* or FALSE if unknown.
|
|
*/
|
|
public function getEndLine() {
|
|
return $this->info['line2'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.getdoccomment.php )
|
|
*
|
|
* Get a Doc comment from a function. WarningThis function is currently
|
|
* not documented; only its argument list is available.
|
|
*
|
|
* @return mixed The doc comment if it exists, otherwise FALSE
|
|
*/
|
|
public function getDocComment() {
|
|
return $this->info['doc'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.getstaticvariables.php
|
|
* )
|
|
*
|
|
* Get the static variables. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed An array of static variables.
|
|
*/
|
|
public function getStaticVariables() {
|
|
return $this->info['static_variables'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.returnsreference.php
|
|
* )
|
|
*
|
|
* Checks whether the function returns a reference. WarningThis function
|
|
* is currently not documented; only its argument list is available.
|
|
*
|
|
* @return mixed TRUE if it returns a reference, otherwise FALSE
|
|
*/
|
|
public function returnsReference() {
|
|
return isset($this->info['ref']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.getparameters.php )
|
|
*
|
|
* Get the parameters as an array of ReflectionParameter. WarningThis
|
|
* function is currently not documented; only its argument list is
|
|
* available.
|
|
*
|
|
* @return mixed The parameters, as a ReflectionParameter object.
|
|
*/
|
|
public function getParameters() {
|
|
$ret = array();
|
|
foreach ($this->info['params'] as $name => $info) {
|
|
$param = new ReflectionParameter(null, null);
|
|
$param->info = $info;
|
|
$param->name = $info['name'];
|
|
$ret[] = $param;
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.getnumberofparameters.php
|
|
* )
|
|
*
|
|
* Get the number of parameters that a function defines, both optional and
|
|
* required. WarningThis function is currently not documented; only its
|
|
* argument list is available.
|
|
*
|
|
* @return mixed The number of parameters.
|
|
*/
|
|
public function getNumberOfParameters() {
|
|
return count($this->info['params']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunctionabstract.getnumberofrequiredparameters.php
|
|
* )
|
|
*
|
|
* Get the number of required parameters that a function defines.
|
|
* WarningThis function is currently not documented; only its argument list
|
|
* is available.
|
|
*
|
|
* @return mixed The number of required parameters.
|
|
*/
|
|
public function getNumberOfRequiredParameters() {
|
|
$count = 0;
|
|
$params = $this->getParameters();
|
|
foreach ($params as $name => $param) {
|
|
if ($param->isOptional()) {
|
|
break;
|
|
}
|
|
$count++;
|
|
}
|
|
return $count;
|
|
}
|
|
|
|
public function getReturnTypeText() {
|
|
if (isset($this->info['return_type'])) {
|
|
return $this->info['return_type'];
|
|
}
|
|
return '';
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// function
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.reflectionfunction.php )
|
|
*
|
|
* The ReflectionFunction class reports information about a function.
|
|
*
|
|
*/
|
|
class ReflectionFunction extends ReflectionFunctionAbstract
|
|
implements Reflector {
|
|
const IS_DEPRECATED = 262144;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionfunction.construct.php
|
|
* )
|
|
*
|
|
* Constructs a ReflectionFunction object.
|
|
*
|
|
* @name mixed The name of the function to reflect or a closure.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function __construct($name) {
|
|
if ($name instanceof Closure) {
|
|
$this->info = hphp_get_closure_info($name);
|
|
} else {
|
|
$this->info = hphp_get_function_info($name);
|
|
if (empty($this->info)) {
|
|
throw new ReflectionException("Function $name does not exist");
|
|
}
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionfunction.tostring.php
|
|
* )
|
|
*
|
|
* To string.
|
|
*
|
|
* @return mixed Returns ReflectionFunction::export()-like output for
|
|
* the function.
|
|
*/
|
|
public function __toString() {
|
|
//TODO
|
|
return "";
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionfunction.export.php )
|
|
*
|
|
* Exports a Reflected function.
|
|
*
|
|
* @name mixed The reflection to export.
|
|
* @ret mixed Setting to TRUE will return the export, as opposed
|
|
* to emitting it. Setting to FALSE (the default) will
|
|
* do the opposite.
|
|
*
|
|
* @return mixed If the return parameter is set to TRUE, then the
|
|
* export is returned as a string, otherwise NULL is
|
|
* returned.
|
|
*/
|
|
public static function export($name, $ret=false) {
|
|
$obj = new ReflectionFunction($name);
|
|
$str = (string)$obj;
|
|
if ($ret) {
|
|
return $str;
|
|
}
|
|
print $str;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionfunction.invoke.php )
|
|
*
|
|
* Invokes a reflected function.
|
|
*
|
|
* @return mixed Returns the result of the invoked function call.
|
|
*/
|
|
public function invoke() {
|
|
$args = func_get_args();
|
|
if (isset($this->info['closureobj'])) {
|
|
$closure = $this->info['closureobj'];
|
|
return hphp_invoke_method($closure, get_class($closure),
|
|
'__invoke', $args);
|
|
}
|
|
return hphp_invoke($this->info['name'], $args);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionfunction.invokeargs.php )
|
|
*
|
|
* Invokes the function and pass its arguments as array.
|
|
*
|
|
* @args mixed The passed arguments to the function as an array,
|
|
* much like call_user_func_array() works.
|
|
*
|
|
* @return mixed Returns the result of the invoked function
|
|
*/
|
|
public function invokeArgs($args) {
|
|
if (isset($this->info['closureobj'])) {
|
|
$closure = $this->info['closureobj'];
|
|
return hphp_invoke_method($closure, get_class($closure),
|
|
'__invoke', array_values($args));
|
|
}
|
|
return hphp_invoke($this->info['name'], array_values($args));
|
|
}
|
|
|
|
public function getAttribute($name) {
|
|
$attrs = $this->info['attributes'];
|
|
return isset($attrs[$name]) ? $attrs[$name] : null;
|
|
}
|
|
|
|
public function getAttributes() {
|
|
return $this->info['attributes'];
|
|
}
|
|
|
|
public function getAttributeRecursive($name) {
|
|
$attrs = $this->info['attributes'];
|
|
return isset($attrs[$name]) ? $attrs[$name] : null;
|
|
}
|
|
|
|
public function getAttributesRecursive() {
|
|
return $this->info['attributes'];
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// class
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.reflectionclass.php )
|
|
*
|
|
* The ReflectionClass class reports information about a class.
|
|
*
|
|
*/
|
|
class ReflectionClass implements Reflector {
|
|
const IS_IMPLICIT_ABSTRACT = 16 ;
|
|
const IS_EXPLICIT_ABSTRACT = 32 ;
|
|
const IS_FINAL = 64 ;
|
|
|
|
public $name;
|
|
private $info = null;
|
|
private static $fetched = array();
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.construct.php )
|
|
*
|
|
* Constructs a new ReflectionClass object. WarningThis function is
|
|
* currently not documented; only its argument list is available.
|
|
*
|
|
* @name mixed Either a string containing the name of the class to
|
|
* reflect, or an object.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function __construct($name) {
|
|
if (is_object($name)) {
|
|
$name = get_class($name);
|
|
}
|
|
|
|
$this->name = hphp_get_original_class_name($name);
|
|
if (empty($this->name)) {
|
|
throw new ReflectionException("Class $name does not exist");
|
|
}
|
|
}
|
|
|
|
private function fetch($what) {
|
|
if (!$this->info) {
|
|
$this->info = self::fetch_recur($this->name);
|
|
$this->info['properties'] += $this->info['private_properties'];
|
|
}
|
|
return $this->info[$what];
|
|
}
|
|
|
|
private static function fetch_recur($name) {
|
|
if (isset(self::$fetched[$name])) return self::$fetched[$name];
|
|
$info = hphp_get_class_info($name);
|
|
if (empty($info)) {
|
|
throw new ReflectionException("Class $name does not exist");
|
|
}
|
|
|
|
$info['attributes_rec'] = $info['attributes'];
|
|
|
|
$abstract = isset($info['abstract']) || isset($info['interface']);
|
|
// flattening the trees, so it's easier for lookups
|
|
foreach ($info['interfaces'] as $interface => $_) {
|
|
$p = self::fetch_recur($interface);
|
|
if ($abstract) $info['methods'] += $p['methods'];
|
|
$info['constants'] += $p['constants'];
|
|
$info['interfaces'] += $p['interfaces'];
|
|
}
|
|
|
|
$parent = $info['parent'];
|
|
if (!empty($parent)) {
|
|
$p = self::fetch_recur($parent);
|
|
if (isset($p['interface'])) {
|
|
$info['interfaces'][$parent] = 1;
|
|
} else {
|
|
$info['properties'] += $p['properties'];
|
|
}
|
|
$info['methods'] += $p['methods'];
|
|
$info['constants'] += $p['constants'];
|
|
$info['interfaces'] += $p['interfaces'];
|
|
$info['attributes_rec'] += $p['attributes_rec'];
|
|
}
|
|
self::$fetched[$name] = $info;
|
|
return $info;
|
|
}
|
|
|
|
private function check($what) {
|
|
if (!$this->info) {
|
|
$this->info = self::fetch_recur($this->name);
|
|
}
|
|
return isset($this->info[$what]);
|
|
}
|
|
|
|
private function test($what, $name) {
|
|
$v = $this->fetch($what);
|
|
return $v && isset($v[$name]);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.tostring.php )
|
|
*
|
|
* Returns the string representation of the ReflectionClass object.
|
|
*
|
|
* @return mixed A string representation of this ReflectionClass
|
|
* instance.
|
|
*/
|
|
public function __toString() {
|
|
return "";
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.export.php )
|
|
*
|
|
* Exports a reflected class.
|
|
*
|
|
* @name mixed The reflection to export.
|
|
* @ret mixed Setting to TRUE will return the export, as opposed
|
|
* to emitting it. Setting to FALSE (the default) will
|
|
* do the opposite.
|
|
*
|
|
* @return mixed If the return parameter is set to TRUE, then the
|
|
* export is returned as a string, otherwise NULL is
|
|
* returned.
|
|
*/
|
|
public static function export($name, $ret=false) {
|
|
$obj = new ReflectionClass($name);
|
|
$str = (string)$obj;
|
|
if ($ret) {
|
|
return $str;
|
|
}
|
|
print $str;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.getname.php )
|
|
*
|
|
* Gets the class name. WarningThis function is currently not documented;
|
|
* only its argument list is available.
|
|
*
|
|
* @return mixed The class name.
|
|
*/
|
|
public function getName() {
|
|
return $this->name;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.isinternal.php )
|
|
*
|
|
* Checks if the class is defined internally by an extension, or the core,
|
|
* as opposed to user-defined.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function isInternal() {
|
|
return $this->check('internal');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.isuserdefined.php )
|
|
*
|
|
* Checks whether the class is user-defined, as opposed to internal.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function isUserDefined() {
|
|
return !$this->check('internal');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.isinstantiable.php )
|
|
*
|
|
* Checks if the class is instantiable.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function isInstantiable() {
|
|
return !$this->check('abstract');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.hasconstant.php
|
|
* )
|
|
*
|
|
* Checks whether the class has a specific constant defined or not.
|
|
*
|
|
* @name mixed The name of the constant being checked for.
|
|
*
|
|
* @return mixed TRUE if the constant is defined, otherwise FALSE.
|
|
*/
|
|
public function hasConstant($name) {
|
|
return $this->test('constants', $name);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.hasmethod.php )
|
|
*
|
|
* Checks whether a specific method is defined in a class.
|
|
*
|
|
* @name mixed Name of the method being checked for.
|
|
*
|
|
* @return mixed TRUE if it has the method, otherwise FALSE
|
|
*/
|
|
public function hasMethod($name) {
|
|
return $this->test('methods', strtolower($name));
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.hasproperty.php
|
|
* )
|
|
*
|
|
* Checks whether the specified property is defined.
|
|
*
|
|
* @name mixed Name of the property being checked for.
|
|
*
|
|
* @return mixed TRUE if it has the property, otherwise FALSE
|
|
*/
|
|
public function hasProperty($name) {
|
|
return $this->test('properties', $name);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.getfilename.php
|
|
* )
|
|
*
|
|
* Gets the filename of the file in which the class has been defined.
|
|
*
|
|
* @return mixed Returns the filename of the file in which the class
|
|
* has been defined. If the class is defined in the PHP
|
|
* core or in a PHP extension, FALSE is returned.
|
|
*/
|
|
public function getFileName() {
|
|
return $this->fetch('file');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.getstartline.php
|
|
* )
|
|
*
|
|
* Get the starting line number. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed The starting line number, as an integer.
|
|
*/
|
|
public function getStartLine() {
|
|
return $this->fetch('line1');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.getendline.php )
|
|
*
|
|
* Gets end line number from a user-defined class definition.
|
|
*
|
|
* @return mixed The ending line number of the user defined class, or
|
|
* FALSE if unknown.
|
|
*/
|
|
public function getEndLine() {
|
|
return $this->fetch('line2');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.getdoccomment.php )
|
|
*
|
|
* Gets doc comments from a class. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed The doc comment if it exists, otherwise FALSE
|
|
*/
|
|
public function getDocComment() {
|
|
return $this->fetch('doc');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.getconstructor.php )
|
|
*
|
|
* Gets the constructor of the reflected class.
|
|
*
|
|
* @return mixed A ReflectionMethod object reflecting the class'
|
|
* constructor, or NULL if the class has no
|
|
* constructor.
|
|
*/
|
|
public function getConstructor() {
|
|
if ($this->hasMethod('__construct')) {
|
|
return $this->getMethod('__construct');
|
|
}
|
|
if (!$this->isTrait() && $this->hasMethod($name = $this->name)) {
|
|
return $this->getMethod($name);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.getmethod.php )
|
|
*
|
|
* Gets a ReflectionMethod for a class method.
|
|
*
|
|
* @name mixed The method name to reflect.
|
|
*
|
|
* @return mixed A ReflectionMethod.
|
|
*/
|
|
public function getMethod($name) {
|
|
if (!$this->info) {
|
|
$method = hphp_get_method_info($this->name, $name);
|
|
} else {
|
|
$lname = strtolower($name);
|
|
$methods = $this->info['methods'];
|
|
if (isset($methods[$lname])) $method = $methods[$lname];
|
|
}
|
|
if (empty($method)) {
|
|
$class = $this->name;
|
|
throw new ReflectionException("Method $class::$name does not exist");
|
|
}
|
|
|
|
$ret = new ReflectionMethod(null, null);
|
|
$ret->info = $method;
|
|
$ret->name = $method['name'];
|
|
$ret->class = $method['class'];
|
|
return $ret;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.getmethods.php )
|
|
*
|
|
* Gets an array of methods for the class.
|
|
*
|
|
* @filter mixed Filter the results to include only methods with
|
|
* certain attributes. Defaults to no filtering.
|
|
*
|
|
* Any combination of ReflectionMethod::IS_STATIC,
|
|
* ReflectionMethod::IS_PUBLIC,
|
|
* ReflectionMethod::IS_PROTECTED,
|
|
* ReflectionMethod::IS_PRIVATE,
|
|
* ReflectionMethod::IS_ABSTRACT,
|
|
* ReflectionMethod::IS_FINAL.
|
|
*
|
|
* @return mixed An array of ReflectionMethod objects reflecting each
|
|
* method.
|
|
*/
|
|
public function getMethods($filter = 0xFFFF) {
|
|
$ret = array();
|
|
$methods = $this->fetch('methods');
|
|
foreach ($methods as $name => $_) {
|
|
$m = $this->getMethod($name);
|
|
if ((($filter & ReflectionMethod::IS_PUBLIC)) && $m->isPublic() ||
|
|
(($filter & ReflectionMethod::IS_PROTECTED)) && $m->isProtected() ||
|
|
(($filter & ReflectionMethod::IS_PRIVATE)) && $m->isPrivate() ||
|
|
(($filter & ReflectionMethod::IS_STATIC)) && $m->isStatic() ||
|
|
(($filter & ReflectionMethod::IS_FINAL)) && $m->isFinal() ||
|
|
(($filter & ReflectionMethod::IS_ABSTRACT && $m->isAbstract()))) {
|
|
$ret[] = $m;
|
|
}
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.getproperty.php
|
|
* )
|
|
*
|
|
* Gets a ReflectionProperty for a class's property.
|
|
*
|
|
* @name mixed The property name.
|
|
*
|
|
* @return mixed A ReflectionProperty.
|
|
*/
|
|
public function getProperty($name) {
|
|
$properties = $this->fetch('properties');
|
|
if (!isset($properties[$name])) {
|
|
$class = $this->info['name'];
|
|
throw new ReflectionException("Property $class::$name does not exist");
|
|
}
|
|
|
|
$ret = new ReflectionProperty(null, null);
|
|
$ret->info = $properties[$name];
|
|
$ret->name = $name;
|
|
$ret->class = $this->info['name'];
|
|
return $ret;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.getproperties.php )
|
|
*
|
|
* Retrieves reflected properties.
|
|
*
|
|
* @filter mixed The optional filter, for filtering desired property
|
|
* types. It's configured using the ReflectionProperty
|
|
* constants, and defaults to all property types.
|
|
*
|
|
* @return mixed An array of ReflectionProperty objects.
|
|
*/
|
|
public function getProperties($filter = 0xFFFF) {
|
|
$ret = array();
|
|
foreach ($this->fetch('properties') as $name => $_) {
|
|
$p = $this->getProperty($name);
|
|
if (($filter & ReflectionProperty::IS_PUBLIC) && $p->isPublic() ||
|
|
($filter & ReflectionProperty::IS_PROTECTED) && $p->isProtected() ||
|
|
($filter & ReflectionProperty::IS_PRIVATE) && $p->isPrivate() ||
|
|
($filter & ReflectionProperty::IS_STATIC) && $p->isStatic()) {
|
|
$ret[] = $p;
|
|
}
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.getconstants.php
|
|
* )
|
|
*
|
|
* Gets defined constants from a class. WarningThis function is currently
|
|
* not documented; only its argument list is available.
|
|
*
|
|
* @return mixed An array of constants. Constant name in key,
|
|
* constant value in value.
|
|
*/
|
|
public function getConstants() {
|
|
return $this->fetch('constants');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.getconstant.php
|
|
* )
|
|
*
|
|
* Gets the defined constant. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @name mixed Name of the constant.
|
|
*
|
|
* @return mixed Value of the constant.
|
|
*/
|
|
public function getConstant($name) {
|
|
$constants = $this->fetch('constants');
|
|
if (!isset($constants[$name])) {
|
|
$class = $this->info['name'];
|
|
throw new ReflectionException("Class constant $class::$name does not exist");
|
|
}
|
|
return $constants[$name];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.getinterfaces.php )
|
|
*
|
|
* Gets the interfaces.
|
|
*
|
|
* @return mixed An associative array of interfaces, with keys as
|
|
* interface names and the array values as
|
|
* ReflectionClass objects.
|
|
*/
|
|
public function getInterfaces() {
|
|
$ret = array();
|
|
foreach ($this->fetch('interfaces') as $name => $_) {
|
|
$cls = new ReflectionClass($name);
|
|
if ($cls->isInterface()) {
|
|
$ret[$cls->getName()] = $cls;
|
|
}
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.gettraits.php )
|
|
*
|
|
* WarningThis function is currently not documented; only its argument
|
|
* list is available.
|
|
*
|
|
* @return mixed Returns an array with trait names in keys and
|
|
* instances of trait's ReflectionClass in values.
|
|
* Returns NULL in case of an error.
|
|
*/
|
|
public function getTraits() {
|
|
$ret = array();
|
|
foreach ($this->fetch('traits') as $name => $_) {
|
|
$cls = new ReflectionClass($name);
|
|
if ($cls->isTrait()) {
|
|
$ret[$cls->getName()] = $cls;
|
|
}
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.getinterfacenames.php )
|
|
*
|
|
* Get the interface names.
|
|
*
|
|
* @return mixed A numerical array with interface names as the
|
|
* values.
|
|
*/
|
|
public function getInterfaceNames() {
|
|
$ret = array();
|
|
foreach ($this->fetch('interfaces') as $name => $_) {
|
|
$cls = new ReflectionClass($name);
|
|
if ($cls->isInterface()) {
|
|
$ret[] = $cls->getName();
|
|
}
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.gettraitnames.php )
|
|
*
|
|
* WarningThis function is currently not documented; only its argument
|
|
* list is available.
|
|
*
|
|
* @return mixed Returns an array with trait names in values. Returns
|
|
* NULL in case of an error.
|
|
*/
|
|
public function getTraitNames() {
|
|
$ret = array();
|
|
foreach ($this->fetch('traits') as $name => $_) {
|
|
$cls = new ReflectionClass($name);
|
|
if ($cls->isTrait()) {
|
|
$ret[] = $cls->getName();
|
|
}
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.gettraitaliases.php )
|
|
*
|
|
* WarningThis function is currently not documented; only its argument
|
|
* list is available.
|
|
*
|
|
* @return mixed Returns an array with new method names in keys and
|
|
* original names (in the format "TraitName::original")
|
|
* in values. Returns NULL in case of an error.
|
|
*/
|
|
public function getTraitAliases() {
|
|
$ret = array();
|
|
foreach ($this->fetch('trait_aliases') as $old_name => $new_name) {
|
|
$ret[$old_name] = $new_name;
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.isinterface.php
|
|
* )
|
|
*
|
|
* Checks whether the class is an interface.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function isInterface() {
|
|
return $this->check('interface');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.isabstract.php )
|
|
*
|
|
* Checks if the class is abstract.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function isAbstract() {
|
|
return $this->check('abstract');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.isfinal.php )
|
|
*
|
|
* Checks if a class is final.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function isFinal() {
|
|
return $this->check('final');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.istrait.php )
|
|
*
|
|
* WarningThis function is currently not documented; only its argument
|
|
* list is available.
|
|
*
|
|
* @return mixed Returns TRUE if this is a trait, FALSE otherwise.
|
|
* Returns NULL in case of an error.
|
|
*/
|
|
public function isTrait() {
|
|
return $this->check('trait');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.getmodifiers.php
|
|
* )
|
|
*
|
|
* Returns a bitfield of the access modifiers for this class.
|
|
*
|
|
* @return mixed Returns bitmask of modifier constants.
|
|
*/
|
|
public function getModifiers() {
|
|
return $this->fetch('modifiers');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.isinstance.php )
|
|
*
|
|
* Checks if an object is an instance of a class.
|
|
*
|
|
* @obj mixed The object being compared to.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function isInstance($obj) {
|
|
return hphp_instanceof($obj, $this->name);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.newinstance.php
|
|
* )
|
|
*
|
|
* Creates a new instance of the class. The given arguments are passed to
|
|
* the class constructor.
|
|
*
|
|
*/
|
|
public function newInstance() {
|
|
$args = func_get_args();
|
|
return hphp_create_object($this->name, $args);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.newinstanceargs.php )
|
|
*
|
|
* Creates a new instance of the class, the given arguments are passed to
|
|
* the class constructor.
|
|
*
|
|
* @args mixed The parameters to be passed to the class constructor
|
|
* as an array.
|
|
*
|
|
* @return mixed Returns a new instance of the class.
|
|
*/
|
|
public function newInstanceArgs($args) {
|
|
return hphp_create_object($this->name, array_values($args));
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.newinstancewithoutconstructor.php
|
|
* )
|
|
*
|
|
* Creates a new instance of the class without invoking the constructor.
|
|
*
|
|
*/
|
|
public function newInstanceWithoutConstructor() {
|
|
return hphp_create_object_without_constructor($this->name);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.getparentclass.php )
|
|
*
|
|
* WarningThis function is currently not documented; only its argument
|
|
* list is available.
|
|
*
|
|
* @return mixed A ReflectionClass.
|
|
*/
|
|
public function getParentClass() {
|
|
$parent = $this->fetch('parent');
|
|
if (empty($parent)) {
|
|
return false;
|
|
}
|
|
return new ReflectionClass($parent);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.issubclassof.php
|
|
* )
|
|
*
|
|
* Checks if the class is a subclass of a specified class or implements a
|
|
* specified interface.
|
|
*
|
|
* @cls mixed The class name being checked against.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function isSubclassOf($cls) {
|
|
if ($cls instanceof ReflectionClass) {
|
|
$cls = $cls->name;
|
|
}
|
|
foreach ($this->fetch('interfaces') as $name => $_) {
|
|
if (strcasecmp($cls, $name) == 0) {
|
|
return true;
|
|
}
|
|
}
|
|
$parent = $this->fetch('parent');
|
|
if (empty($parent)) {
|
|
return false;
|
|
}
|
|
if (strcasecmp($cls, $parent) == 0) {
|
|
return true;
|
|
}
|
|
return $this->getParentClass()->isSubclassOf($cls);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.getstaticproperties.php )
|
|
*
|
|
* Get the static properties. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed The static properties, as an array.
|
|
*/
|
|
public function getStaticProperties() {
|
|
$ret = array();
|
|
foreach ($this->getProperties() as $prop) {
|
|
if ($prop->isStatic()) {
|
|
$ret[$prop->name] = $prop;
|
|
}
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.getstaticpropertyvalue.php )
|
|
*
|
|
* Gets the value of a static property on this class.
|
|
*
|
|
* @name mixed The name of the static property for which to return
|
|
* a value.
|
|
* @default mixed
|
|
*
|
|
* @return mixed The value of the static property.
|
|
*/
|
|
public function getStaticPropertyValue($name, $default = null) {
|
|
if ($this->hasProperty($name) &&
|
|
$this->getProperty($name)->isStatic()) {
|
|
return hphp_get_static_property($this->name, $name);
|
|
}
|
|
return $default;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.setstaticpropertyvalue.php )
|
|
*
|
|
* Sets static property value. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @name mixed Property name.
|
|
* @value mixed New property value.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function setStaticPropertyValue($name, $value) {
|
|
hphp_set_static_property($this->name, $name, $value);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.getdefaultproperties.php )
|
|
*
|
|
* Gets default properties from a class (including inherited properties).
|
|
*
|
|
* This method only works for static properties when used on internal
|
|
* classes. The default value of a static class property can not be tracked
|
|
* when using this method on user defined classes.
|
|
*
|
|
* @return mixed An array of default properties, with the key being
|
|
* the name of the property and the value being the
|
|
* default value of the property or NULL if the
|
|
* property doesn't have a default value. The function
|
|
* does not distinguish between static and non static
|
|
* properties and does not take visibility modifiers
|
|
* into account.
|
|
*/
|
|
public function getDefaultProperties() {
|
|
$ret = array();
|
|
foreach ($this->getProperties() as $prop) {
|
|
if ($prop->isDefault()) {
|
|
$ret[$prop->name] = $prop;
|
|
}
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.isiterateable.php )
|
|
*
|
|
* Checks whether the class is iterateable.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function isIterateable() {
|
|
return $this->isSubclassOf('ArrayAccess');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.implementsinterface.php )
|
|
*
|
|
* Checks whether it implements an interface.
|
|
*
|
|
* @cls mixed The interface name.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function implementsInterface($cls) {
|
|
if ($cls instanceof ReflectionClass) {
|
|
$cls = $cls->name;
|
|
}
|
|
if (!interface_exists($cls)) {
|
|
throw new ReflectionException("$cls is not an Interface");
|
|
}
|
|
foreach ($this->fetch('interfaces') as $name => $_) {
|
|
if (strcasecmp($cls, $name) == 0) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.getextension.php
|
|
* )
|
|
*
|
|
* Gets a ReflectionExtension object for the extension which defined the
|
|
* class.
|
|
*
|
|
* @return mixed A ReflectionExtension object representing the
|
|
* extension which defined the class, or NULL for
|
|
* user-defined classes.
|
|
*/
|
|
public function getExtension() {
|
|
return $this->fetch('extension');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.getextensionname.php )
|
|
*
|
|
* Gets the name of the extension which defined the class.
|
|
*
|
|
* @return mixed The name of the extension which defined the class,
|
|
* or FALSE for user-defined classes.
|
|
*/
|
|
public function getExtensionName() {
|
|
return $this->fetch('extension')->getName();
|
|
}
|
|
|
|
public function getAttribute($name) {
|
|
$attrs = $this->fetch('attributes');
|
|
return isset($attrs[$name]) ? $attrs[$name] : null;
|
|
}
|
|
|
|
public function getAttributes() {
|
|
return $this->fetch('attributes');
|
|
}
|
|
|
|
public function getAttributeRecursive($name) {
|
|
$attrs = $this->fetch('attributes_rec');
|
|
return isset($attrs[$name]) ? $attrs[$name] : null;
|
|
}
|
|
|
|
public function getAttributesRecursive() {
|
|
return $this->fetch('attributes_rec');
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.innamespace.php
|
|
* )
|
|
*
|
|
* Checks if this class is defined in a namespace.
|
|
*
|
|
* @return mixed Returns TRUE on success or FALSE on failure.
|
|
*/
|
|
public function inNamespace() {
|
|
return strrpos($this->getName(), '\\') !== false;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionclass.getnamespacename.php )
|
|
*
|
|
* Gets the namespace name. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed The namespace name.
|
|
*/
|
|
public function getNamespaceName() {
|
|
$pos = strrpos($this->getName(), '\\');
|
|
if ($pos === false) {
|
|
return '';
|
|
}
|
|
return substr($this->getName(), 0, $pos);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionclass.getshortname.php
|
|
* )
|
|
*
|
|
* Gets the short name of the class, the part without the namespace.
|
|
*
|
|
* @return mixed The class short name.
|
|
*/
|
|
public function getShortName() {
|
|
$pos = strrpos($this->getName(), '\\');
|
|
if ($pos === false) {
|
|
return $this->getName();
|
|
}
|
|
return substr($this->getName(), $pos + 1);
|
|
}
|
|
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// object
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.reflectionobject.php )
|
|
*
|
|
* The ReflectionObject class reports information about an object.
|
|
*
|
|
*/
|
|
class ReflectionObject extends ReflectionClass {
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionobject.export.php )
|
|
*
|
|
* Exports a reflection. WarningThis function is currently not documented;
|
|
* only its argument list is available.
|
|
*
|
|
* @obj mixed The reflection to export.
|
|
* @ret mixed Setting to TRUE will return the export, as opposed
|
|
* to emitting it. Setting to FALSE (the default) will
|
|
* do the opposite.
|
|
*
|
|
* @return mixed If the return parameter is set to TRUE, then the
|
|
* export is returned as a string, otherwise NULL is
|
|
* returned.
|
|
*/
|
|
public static function export($obj, $ret=false) {
|
|
$obj = new ReflectionObject($obj);
|
|
$str = (string)$obj;
|
|
if ($ret) {
|
|
return $str;
|
|
}
|
|
print $str;
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// property
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.reflectionproperty.php )
|
|
*
|
|
* The ReflectionProperty class reports information about classes
|
|
* properties.
|
|
*
|
|
*/
|
|
class ReflectionProperty implements Reflector {
|
|
const IS_STATIC = 1;
|
|
const IS_PUBLIC = 256;
|
|
const IS_PROTECTED = 512;
|
|
const IS_PRIVATE = 1024;
|
|
|
|
public $info;
|
|
public $name;
|
|
public $class;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionproperty.construct.php
|
|
* )
|
|
*
|
|
* WarningThis function is currently not documented; only its argument
|
|
* list is available.
|
|
*
|
|
* @cls mixed The class name, that contains the property.
|
|
* @name mixed The name of the property being reflected.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function __construct($cls, $name) {
|
|
if ($cls && $name) {
|
|
if (!is_object($cls)) {
|
|
$cls = new ReflectionClass($cls);
|
|
} else {
|
|
$cls = new ReflectionClass(get_class($cls));
|
|
}
|
|
$prop = $cls->getProperty($name);
|
|
if ($prop) {
|
|
$this->info = $prop->info;
|
|
$this->name = $prop->name;
|
|
$this->class = $prop->class;
|
|
}
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionproperty.tostring.php
|
|
* )
|
|
*
|
|
* To string. WarningThis function is currently not documented; only its
|
|
* argument list is available.
|
|
*
|
|
*/
|
|
public function __toString() {
|
|
return "";
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionproperty.export.php )
|
|
*
|
|
* Exports a reflection. WarningThis function is currently not documented;
|
|
* only its argument list is available.
|
|
*
|
|
* @cls mixed The reflection to export.
|
|
* @name mixed The property name.
|
|
* @ret mixed Setting to TRUE will return the export, as opposed
|
|
* to emitting it. Setting to FALSE (the default) will
|
|
* do the opposite.
|
|
*/
|
|
public static function export($cls, $name, $ret=false) {
|
|
if (!is_object($cls)) {
|
|
$cls = new ReflectionClass($cls);
|
|
} else {
|
|
$cls = new ReflectionClass(get_class($cls));
|
|
}
|
|
$obj = $cls->getProperty($name);
|
|
$str = (string)$obj;
|
|
if ($ret) {
|
|
return $str;
|
|
}
|
|
print $str;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionproperty.getname.php )
|
|
*
|
|
* Gets the properties name. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed The name of the reflected property.
|
|
*/
|
|
public function getName() {
|
|
return $this->info['name'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionproperty.ispublic.php
|
|
* )
|
|
*
|
|
* Checks whether the property is public.
|
|
*
|
|
* @return mixed TRUE if the property is public, FALSE otherwise.
|
|
*/
|
|
public function isPublic() {
|
|
return $this->info['access'] == 'public';
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionproperty.isprivate.php
|
|
* )
|
|
*
|
|
* Checks whether the property is private.
|
|
*
|
|
* @return mixed TRUE if the property is private, FALSE otherwise.
|
|
*/
|
|
public function isPrivate() {
|
|
return $this->info['access'] == 'private';
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionproperty.isprotected.php )
|
|
*
|
|
* Checks whether the property is protected.
|
|
*
|
|
* @return mixed TRUE if the property is protected, FALSE otherwise.
|
|
*/
|
|
public function isProtected() {
|
|
return $this->info['access'] == 'protected';
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionproperty.isstatic.php
|
|
* )
|
|
*
|
|
* Checks whether the property is static.
|
|
*
|
|
* @return mixed TRUE if the property is static, FALSE otherwise.
|
|
*/
|
|
public function isStatic() {
|
|
return isset($this->info['static']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionproperty.isdefault.php
|
|
* )
|
|
*
|
|
* Checks whether the property is the default.
|
|
*
|
|
* @return mixed TRUE if the property was declared at compile-time,
|
|
* or FALSE if it was created at run-time.
|
|
*/
|
|
public function isDefault() {
|
|
return $this->info['default'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionproperty.setaccessible.php )
|
|
*
|
|
* Sets a property to be accessible. For example, it may allow protected
|
|
* and private properties to be accessed.
|
|
*
|
|
* @accessible mixed TRUE to allow accessibility, or FALSE.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function setAccessible($accessible) {
|
|
throw new ReflectionException(__METHOD__." is not supported");
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionproperty.getmodifiers.php )
|
|
*
|
|
* Gets the modifiers. WarningThis function is currently not documented;
|
|
* only its argument list is available.
|
|
*
|
|
* @return mixed A numeric representation of the modifiers.
|
|
*/
|
|
public function getModifiers() {
|
|
return $this->info['modifiers'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionproperty.getvalue.php
|
|
* )
|
|
*
|
|
* Gets the properties value.
|
|
*
|
|
* @obj mixed If the property is non-static an object must be
|
|
* provided to fetch the property from. If you want to
|
|
* fetch the default property without providing an
|
|
* object use ReflectionClass::getDefaultProperties()
|
|
* instead.
|
|
*
|
|
* @return mixed The current value of the property.
|
|
*/
|
|
public function getValue($obj = null) {
|
|
if ($this->isStatic()) {
|
|
return hphp_get_static_property($this->info['class'],
|
|
$this->info['name']);
|
|
}
|
|
if ($obj) {
|
|
return hphp_get_property($obj, $this->info['class'],
|
|
$this->info['name']);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionproperty.setvalue.php
|
|
* )
|
|
*
|
|
* Sets (changes) the property's value.
|
|
*
|
|
* @obj mixed If the property is non-static an object must be
|
|
* provided to change the property on. If the property
|
|
* is static this parameter is left out and only value
|
|
* needs to be provided.
|
|
* @value mixed The new value.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function setValue($obj, $value) {
|
|
if ($this->isStatic()) {
|
|
hphp_set_static_property($this->info['class'], $this->info['name'],
|
|
$value);
|
|
} else {
|
|
hphp_set_property($obj, $this->info['class'], $this->info['name'],
|
|
$value);
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionproperty.getdeclaringclass.php )
|
|
*
|
|
* Gets the declaring class. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed A ReflectionClass object.
|
|
*/
|
|
public function getDeclaringClass() {
|
|
if (empty($this->info['class'])) {
|
|
return null;
|
|
}
|
|
return new ReflectionClass($this->info['class']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionproperty.getdoccomment.php )
|
|
*
|
|
* Gets the doc comment. WarningThis function is currently not documented;
|
|
* only its argument list is available.
|
|
*
|
|
* @return mixed The doc comment.
|
|
*/
|
|
public function getDocComment() {
|
|
return $this->info['doc'];
|
|
}
|
|
|
|
public function getTypeText() {
|
|
if (isset($this->info['type'])) {
|
|
return $this->info['type'];
|
|
}
|
|
return '';
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// method
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.reflectionmethod.php )
|
|
*
|
|
* The ReflectionMethod class reports information about a method.
|
|
*
|
|
*/
|
|
class ReflectionMethod extends ReflectionFunctionAbstract
|
|
implements Reflector {
|
|
const IS_STATIC = 1;
|
|
const IS_PUBLIC = 256;
|
|
const IS_PROTECTED = 512;
|
|
const IS_PRIVATE = 1024;
|
|
const IS_ABSTRACT = 2;
|
|
const IS_FINAL = 4;
|
|
|
|
public $name;
|
|
public $class;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionmethod.construct.php )
|
|
*
|
|
* Constructs a new ReflectionMethod.
|
|
*
|
|
* @cls mixed Classname or object (instance of the class) that
|
|
* contains the method.
|
|
* @name mixed Name of the method.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function __construct($cls, $name = '') {
|
|
if (!$name && is_string($cls)) {
|
|
$arr = explode('::', $cls);
|
|
if (count($arr) == 2) {
|
|
$cls = $arr[0];
|
|
$name = $arr[1];
|
|
}
|
|
}
|
|
if ($cls && $name) {
|
|
$method = hphp_get_method_info($cls, $name);
|
|
if (!$method) {
|
|
throw new ReflectionException("Method $cls::$name does not exist");
|
|
}
|
|
|
|
$this->info = $method;
|
|
$this->name = $method['name'];
|
|
$this->class = $method['class'];
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionmethod.tostring.php )
|
|
*
|
|
* Returns the string representation of the Reflection method object.
|
|
*
|
|
* @return mixed A string representation of this ReflectionMethod
|
|
* instance.
|
|
*/
|
|
public function __toString() {
|
|
//TODO
|
|
return "";
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionmethod.export.php )
|
|
*
|
|
* Exports a ReflectionMethod. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @cls mixed The class name.
|
|
* @name mixed The name of the method.
|
|
* @ret mixed Setting to TRUE will return the export, as opposed
|
|
* to emitting it. Setting to FALSE (the default) will
|
|
* do the opposite.
|
|
*
|
|
* @return mixed If the return parameter is set to TRUE, then the
|
|
* export is returned as a string, otherwise NULL is
|
|
* returned.
|
|
*/
|
|
public static function export($cls, $name, $ret=false) {
|
|
if (!is_object($cls)) {
|
|
$cls = new ReflectionClass($cls);
|
|
} else {
|
|
$cls = new ReflectionClass(get_class($cls));
|
|
}
|
|
$obj = $cls->getMethod($name);
|
|
$str = (string)$obj;
|
|
if ($ret) {
|
|
return $str;
|
|
}
|
|
print $str;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionmethod.invoke.php )
|
|
*
|
|
* Invokes a reflected method.
|
|
*
|
|
* @obj mixed The object to invoke the method on. For static
|
|
* methods, pass null to this parameter.
|
|
*
|
|
* @return mixed Returns the method result.
|
|
*/
|
|
public function invoke($obj) {
|
|
$args = func_get_args();
|
|
array_shift($args);
|
|
return hphp_invoke_method($obj, $this->info['class'], $this->info['name'],
|
|
$args);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionmethod.invokeargs.php
|
|
* )
|
|
*
|
|
* Invokes the reflected method and pass its arguments as array.
|
|
*
|
|
* @obj mixed The object to invoke the method on. In case of
|
|
* static methods, you can pass null to this parameter.
|
|
* @args mixed The parameters to be passed to the function, as an
|
|
* array.
|
|
*
|
|
* @return mixed Returns the method result.
|
|
*/
|
|
public function invokeArgs($obj, $args) {
|
|
return hphp_invoke_method($obj, $this->info['class'], $this->info['name'],
|
|
array_values($args));
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionmethod.isfinal.php )
|
|
*
|
|
* Checks if the method is final.
|
|
*
|
|
* @return mixed TRUE if the method is final, otherwise FALSE
|
|
*/
|
|
public function isFinal() {
|
|
return isset($this->info['final']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionmethod.isabstract.php
|
|
* )
|
|
*
|
|
* Checks if the method is abstract.
|
|
*
|
|
* @return mixed TRUE if the method is abstract, otherwise FALSE
|
|
*/
|
|
public function isAbstract() {
|
|
return isset($this->info['abstract']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionmethod.ispublic.php )
|
|
*
|
|
* Checks if the method is public.
|
|
*
|
|
* @return mixed TRUE if the method is public, otherwise FALSE
|
|
*/
|
|
public function isPublic() {
|
|
return $this->info['access'] == "public";
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionmethod.isprivate.php )
|
|
*
|
|
* Checks if the method is private. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed TRUE if the method is private, otherwise FALSE
|
|
*/
|
|
public function isPrivate() {
|
|
return $this->info['access'] == "private";
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionmethod.isprotected.php
|
|
* )
|
|
*
|
|
* Checks if the method is protected.
|
|
*
|
|
* @return mixed TRUE if the method is protected, otherwise FALSE
|
|
*/
|
|
public function isProtected() {
|
|
return $this->info['access'] == "protected";
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionmethod.isstatic.php )
|
|
*
|
|
* Checks if the method is static.
|
|
*
|
|
* @return mixed TRUE if the method is static, otherwise FALSE
|
|
*/
|
|
public function isStatic() {
|
|
return isset($this->info['static']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionmethod.isconstructor.php )
|
|
*
|
|
* Checks if the method is a constructor.
|
|
*
|
|
* @return mixed TRUE if the method is a constructor, otherwise FALSE
|
|
*/
|
|
public function isConstructor() {
|
|
return isset($this->info['constructor']);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionmethod.isdestructor.php )
|
|
*
|
|
* Checks if the method is a destructor.
|
|
*
|
|
* @return mixed TRUE if the method is a destructor, otherwise FALSE
|
|
*/
|
|
public function isDestructor() {
|
|
return $this->getName() == '__destruct';
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionmethod.getmodifiers.php )
|
|
*
|
|
* Returns a bitfield of the access modifiers for this method.
|
|
*
|
|
* @return mixed A numeric representation of the modifiers. The
|
|
* modifiers are listed below. The actual meanings of
|
|
* these modifiers are described in the predefined
|
|
* constants.
|
|
*/
|
|
public function getModifiers() {
|
|
return $this->info['modifiers'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionmethod.getclosure.php
|
|
* )
|
|
*
|
|
* WarningThis function is currently not documented; only its argument
|
|
* list is available.
|
|
*
|
|
* @return mixed Returns Closure. Returns NULL in case of an error.
|
|
*/
|
|
public function getClosure() {
|
|
return $this->info['closure'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionmethod.getdeclaringclass.php )
|
|
*
|
|
* Gets the declaring class for the reflected method.
|
|
*
|
|
* @return mixed A ReflectionClass object of the class that the
|
|
* reflected method is part of.
|
|
*/
|
|
public function getDeclaringClass() {
|
|
if (empty($this->info['class'])) {
|
|
return null;
|
|
}
|
|
return new ReflectionClass($this->info['class']);
|
|
}
|
|
|
|
public function getAttribute($name) {
|
|
$attrs = $this->info['attributes'];
|
|
return isset($attrs[$name]) ? $attrs[$name] : null;
|
|
}
|
|
|
|
public function getAttributes() {
|
|
return $this->info['attributes'];
|
|
}
|
|
|
|
public function getAttributeRecursive($name) {
|
|
$attrs = $this->info['attributes'];
|
|
if (isset($attrs[$name])) {
|
|
return $attrs[$name];
|
|
}
|
|
$p = get_parent_class($this->class);
|
|
if ($p === false) {
|
|
return null;
|
|
}
|
|
$rm = new ReflectionMethod($p, $this->name);
|
|
if ($rm->isPrivate()) {
|
|
return null;
|
|
}
|
|
return $rm->getAttributeRecursive($name);
|
|
}
|
|
|
|
public function getAttributesRecursive() {
|
|
$attrs = $this->info['attributes'];
|
|
$p = get_parent_class($this->class);
|
|
if ($p !== false) {
|
|
$rm = new ReflectionMethod($p, $this->name);
|
|
if (!$rm->isPrivate()) {
|
|
$attrs += $rm->getAttributesRecursive();
|
|
}
|
|
}
|
|
return $attrs;
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// extension
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.reflectionextension.php )
|
|
*
|
|
* The ReflectionExtension class reports information about an extension.
|
|
*
|
|
*/
|
|
class ReflectionExtension implements Reflector {
|
|
private $name;
|
|
private $info;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionextension.construct.php )
|
|
*
|
|
* Construct a ReflectionExtension object.
|
|
*
|
|
* @name mixed Name of the extension.
|
|
*
|
|
* @return mixed A ReflectionExtension object.
|
|
*/
|
|
public function __construct($name) {
|
|
$this->info = hphp_get_extension_info($name);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionextension.tostring.php
|
|
* )
|
|
*
|
|
* Exports a reflected extension and returns it as a string. This is the
|
|
* same as the ReflectionExtension::export() with the return set to TRUE.
|
|
*
|
|
* @return mixed Returns the exported extension as a string, in the
|
|
* same way as the ReflectionExtension::export().
|
|
*/
|
|
public function __toString() {
|
|
return "";
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionextension.export.php )
|
|
*
|
|
* Exports a reflected extension. The output format of this function is
|
|
* the same as the CLI argument --re [extension].
|
|
*
|
|
* @name mixed The reflection to export.
|
|
* @ret mixed Setting to TRUE will return the export, as opposed
|
|
* to emitting it. Setting to FALSE (the default) will
|
|
* do the opposite.
|
|
*
|
|
* @return mixed If the return parameter is set to TRUE, then the
|
|
* export is returned as a string, otherwise NULL is
|
|
* returned.
|
|
*/
|
|
public static function export($name, $ret=false) {
|
|
$obj = new ReflectionExtension($name);
|
|
$str = (string)$obj;
|
|
if ($ret) {
|
|
return $str;
|
|
}
|
|
print $str;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionextension.getname.php
|
|
* )
|
|
*
|
|
* Gets the extensions name.
|
|
*
|
|
* @return mixed The extensions name.
|
|
*/
|
|
public function getName() {
|
|
return $this->info['name'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionextension.getversion.php )
|
|
*
|
|
* Gets the version of the extension.
|
|
*
|
|
* @return mixed The version of the extension.
|
|
*/
|
|
public function getVersion() {
|
|
return $this->info['version'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionextension.getfunctions.php )
|
|
*
|
|
* Get defined functions from an extension.
|
|
*
|
|
* @return mixed An associative array of ReflectionFunction objects,
|
|
* for each function defined in the extension with the
|
|
* keys being the function names. If no function are
|
|
* defined, an empty array is returned.
|
|
*/
|
|
public function getFunctions() {
|
|
return $this->info['functions'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionextension.getconstants.php )
|
|
*
|
|
* Get defined constants from an extension.
|
|
*
|
|
* @return mixed An associative array with constant names as keys.
|
|
*/
|
|
public function getConstants() {
|
|
return $this->info['constants'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionextension.getinientries.php )
|
|
*
|
|
* Get the ini entries for an extension.
|
|
*
|
|
* @return mixed An associative array with the ini entries as keys,
|
|
* with their defined values as values.
|
|
*/
|
|
public function getINIEntries() {
|
|
return $this->info['ini'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionextension.getclasses.php )
|
|
*
|
|
* Gets a list of classes from an extension.
|
|
*
|
|
* @return mixed An array of ReflectionClass objects, one for each
|
|
* class within the extension. If no classes are
|
|
* defined, an empty array is returned.
|
|
*/
|
|
public function getClasses() {
|
|
return $this->info['classes'];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/reflectionextension.getclassnames.php )
|
|
*
|
|
* Gets a listing of class names as defined in the extension.
|
|
*
|
|
* @return mixed An array of class names, as defined in the
|
|
* extension. If no classes are defined, an empty array
|
|
* is returned.
|
|
*/
|
|
public function getClassNames() {
|
|
$ret = array();
|
|
foreach ($this->info['classes'] as $cls) {
|
|
$ret[] = $cls->getName();
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/reflectionextension.info.php )
|
|
*
|
|
* Prints out the " phpinfo()" snippet for the given extension.
|
|
*
|
|
* @return mixed Information about the extension.
|
|
*/
|
|
public function info() {
|
|
return $this->info['info'];
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.soapfault.php )
|
|
*
|
|
* Represents a SOAP fault.
|
|
*
|
|
*/
|
|
class SoapFault extends Exception {
|
|
public $faultcode;
|
|
public $faultcodens;
|
|
public $faultstring;
|
|
public $faultactor;
|
|
public $detail;
|
|
public $_name;
|
|
public $headerfault;
|
|
|
|
public function __construct($code, $message, $actor = null, $detail = null,
|
|
$name = null, $header = null) {
|
|
$fault_ns = null;
|
|
$fault_code = null;
|
|
if (is_string($code)) {
|
|
$fault_code = $code;
|
|
} else if (is_array($code) && count($code) == 2) {
|
|
$code = array_values($code);
|
|
$fault_ns = $code[0];
|
|
$fault_code = $code[1];
|
|
if (!is_string($fault_ns) || !is_string($fault_code)) {
|
|
hphp_throw_fatal_error("Invalid fault code");
|
|
return;
|
|
}
|
|
} else {
|
|
hphp_throw_fatal_error("Invalid fault code");
|
|
return;
|
|
}
|
|
$this->faultcodens = $fault_ns;
|
|
$this->faultcode = $fault_code;
|
|
if (empty($this->faultcode)) {
|
|
hphp_throw_fatal_error("Invalid fault code");
|
|
return;
|
|
}
|
|
|
|
$this->faultstring = $this->message = $message;
|
|
$this->faultactor = $actor;
|
|
$this->detail = $detail;
|
|
$this->_name = $name;
|
|
$this->headerfault = $header;
|
|
|
|
$SOAP_1_1 = 1;
|
|
$SOAP_1_2 = 2;
|
|
$SOAP_1_1_ENV_NAMESPACE = 'http://schemas.xmlsoap.org/soap/envelope/';
|
|
$SOAP_1_2_ENV_NAMESPACE = 'http://www.w3.org/2003/05/soap-envelope';
|
|
|
|
$soap_version = _soap_active_version();
|
|
if (empty($this->faultcodens)) {
|
|
if ($soap_version == $SOAP_1_1) {
|
|
if ($this->faultcode == "Client" ||
|
|
$this->faultcode == "Server" ||
|
|
$this->faultcode == "VersionMismatch" ||
|
|
$this->faultcode == "MustUnderstand") {
|
|
$this->faultcodens = $SOAP_1_1_ENV_NAMESPACE;
|
|
}
|
|
} else if ($soap_version == $SOAP_1_2) {
|
|
if ($this->faultcode == "Client") {
|
|
$this->faultcode = "Sender";
|
|
$this->faultcodens = $SOAP_1_2_ENV_NAMESPACE;
|
|
} else if ($this->faultcode == "Server") {
|
|
$this->faultcode = "Receiver";
|
|
$this->faultcodens = $SOAP_1_2_ENV_NAMESPACE;
|
|
} else if ($this->faultcode == "VersionMismatch" ||
|
|
$this->faultcode == "MustUnderstand" ||
|
|
$this->faultcode == "DataEncodingUnknown") {
|
|
$this->faultcodens = $SOAP_1_2_ENV_NAMESPACE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/soapfault.tostring.php )
|
|
*
|
|
* Returns a string representation of the SoapFault.
|
|
*
|
|
* @return mixed A string describing the SoapFault.
|
|
*/
|
|
public function __toString() {
|
|
return "SoapFault exception: [" . $this->faultcode . "] " .
|
|
$this->faultstring;
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.splobjectstorage.php )
|
|
*
|
|
* The SplObjectStorage class provides a map from objects to data or, by
|
|
* ignoring data, an object set. This dual purpose can be useful in many
|
|
* cases involving the need to uniquely identify objects.
|
|
*
|
|
*/
|
|
class SplObjectStorage implements Iterator, Countable {
|
|
private $storage = array();
|
|
private $index = 0;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splobjectstorage.rewind.php )
|
|
*
|
|
* Rewind the iterator to the first storage element.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
function rewind() {
|
|
rewind($this->storage);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splobjectstorage.valid.php )
|
|
*
|
|
* Returns if the current iterator entry is valid.
|
|
*
|
|
* @return mixed Returns TRUE if the iterator entry is valid, FALSE
|
|
* otherwise.
|
|
*/
|
|
function valid() {
|
|
return key($this->storage) !== false;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splobjectstorage.key.php )
|
|
*
|
|
* Returns the index at which the iterator currently is.
|
|
*
|
|
* @return mixed The index corresponding to the position of the
|
|
* iterator.
|
|
*/
|
|
function key() {
|
|
return $this->index;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splobjectstorage.current.php )
|
|
*
|
|
* Returns the current storage entry.
|
|
*
|
|
* @return mixed The object at the current iterator position.
|
|
*/
|
|
function current() {
|
|
return current($this->storage);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splobjectstorage.next.php )
|
|
*
|
|
* Moves the iterator to the next object in the storage.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
function next() {
|
|
next($this->storage);
|
|
$this->index++;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splobjectstorage.count.php )
|
|
*
|
|
* Counts the number of objects in the storage.
|
|
*
|
|
* @return mixed The number of objects in the storage.
|
|
*/
|
|
function count() {
|
|
return count($this->storage);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splobjectstorage.contains.php )
|
|
*
|
|
* Checks if the storage contains the object provided.
|
|
*
|
|
* @obj mixed The object to look for.
|
|
*
|
|
* @return mixed Returns TRUE if the object is in the storage, FALSE
|
|
* otherwise.
|
|
*/
|
|
function contains($obj) {
|
|
if (is_object($obj)) {
|
|
foreach($this->storage as $object) {
|
|
if ($object === $obj) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splobjectstorage.attach.php )
|
|
*
|
|
* Adds an object inside the storage, and optionally associate it to some
|
|
* data.
|
|
*
|
|
* @obj mixed The object to add.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
function attach($obj) {
|
|
if (is_object($obj) && !$this->contains($obj)) {
|
|
$this->storage[] = $obj;
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splobjectstorage.detach.php )
|
|
*
|
|
* Removes the object from the storage.
|
|
*
|
|
* @obj mixed The object to remove.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
function detach($obj) {
|
|
if (is_object($obj)) {
|
|
foreach($this->storage as $idx => $object) {
|
|
if ($object === $obj) {
|
|
unset($this->storage[$idx]);
|
|
$this->rewind();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class _SplPriorityQueueHeap extends SplMaxHeap {
|
|
|
|
public function __construct(SplPriorityQueue $priority_queue) {
|
|
$this->priorityQueue = $priority_queue;
|
|
}
|
|
|
|
public function compare($a, $b) {
|
|
return $this->priorityQueue->compare($a['priority'], $b['priority']);
|
|
}
|
|
|
|
public function top() {
|
|
// I know that the parent routes all requests through top()
|
|
// so this is the only method I need to change.
|
|
$result = parent::top();
|
|
$flags = $this->priorityQueue->getExtractFlags();
|
|
if (($flags & SplPriorityQueue::EXTR_BOTH) == SplPriorityQueue::EXTR_BOTH) {
|
|
return $result;
|
|
} else if ($flags & SplPriorityQueue::EXTR_DATA) {
|
|
return $result['data'];
|
|
} else if ($flags & SplPriorityQueue::EXTR_PRIORITY) {
|
|
return $result['priority'];
|
|
}
|
|
// really zend? NULL?
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.splpriorityqueue.php )
|
|
*
|
|
* The SplPriorityQueue class provides the main functionalities of an
|
|
* prioritized queue, implemented using a max heap.
|
|
*
|
|
*/
|
|
class SplPriorityQueue implements Iterator, Countable {
|
|
|
|
const EXTR_DATA = 1;
|
|
const EXTR_PRIORITY = 2;
|
|
const EXTR_BOTH = 3;
|
|
|
|
private $flags = self::EXTR_DATA;
|
|
private $heap = array();
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splpriorityqueue.construct.php )
|
|
*
|
|
* This constructs a new empty queue.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function __construct() {
|
|
$this->heap = new _SplPriorityQueueHeap($this);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splpriorityqueue.compare.php )
|
|
*
|
|
* Compare priority1 with priority2.
|
|
*
|
|
* @priority1 mixed The priority of the first node being compared.
|
|
* @priority2 mixed The priority of the second node being compared.
|
|
*
|
|
* @return mixed Result of the comparison, positive integer if
|
|
* priority1 is greater than priority2, 0 if they are
|
|
* equal, negative integer otherwise.
|
|
*
|
|
* Multiple elements with the same priority will get
|
|
* dequeued in no particular order.
|
|
*/
|
|
public function compare($priority1, $priority2) {
|
|
if ($priority1 > $priority2) {
|
|
return 1;
|
|
} else if ($priority1 < $priority2) {
|
|
return -1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splpriorityqueue.extract.php )
|
|
*
|
|
*
|
|
* @return mixed The value or priority (or both) of the extracted
|
|
* node, depending on the extract flag.
|
|
*/
|
|
public function extract() {
|
|
return $this->heap->extract();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splpriorityqueue.insert.php )
|
|
*
|
|
* Insert value with the priority priority in the queue.
|
|
*
|
|
* @value mixed The value to insert.
|
|
* @priority mixed The associated priority.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function insert($value, $priority) {
|
|
$data = array('data' => $value, 'priority' => $priority);
|
|
return $this->heap->insert($data);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splpriorityqueue.isempty.php )
|
|
*
|
|
*
|
|
* @return mixed Returns whether the queue is empty.
|
|
*/
|
|
public function isEmpty() {
|
|
return $this->heap->isEmpty();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/splpriorityqueue.recoverfromcorruption.php )
|
|
*
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function recoverFromCorruption() {
|
|
return $this->heap->recoverFromCorruption();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splpriorityqueue.count.php )
|
|
*
|
|
*
|
|
* @return mixed Returns the number of elements in the queue.
|
|
*/
|
|
public function count() {
|
|
return $this->heap->count();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splpriorityqueue.current.php )
|
|
*
|
|
* Get the current datastructure node.
|
|
*
|
|
* @return mixed The value or priority (or both) of the current node,
|
|
* depending on the extract flag.
|
|
*/
|
|
public function current() {
|
|
return $this->heap->current();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splpriorityqueue.key.php )
|
|
*
|
|
* This function returns the current node index
|
|
*
|
|
* @return mixed The current node index.
|
|
*/
|
|
public function key() {
|
|
return $this->heap->key();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splpriorityqueue.next.php )
|
|
*
|
|
* Extracts the top node from the queue.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function next() {
|
|
return $this->heap->next();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splpriorityqueue.rewind.php )
|
|
*
|
|
* This rewinds the iterator to the beginning. This is a no-op for heaps
|
|
* as the iterator is virtual and in fact never moves from the top of the
|
|
* heap.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function rewind() {
|
|
return $this->heap->rewind();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splpriorityqueue.top.php )
|
|
*
|
|
*
|
|
* @return mixed The value or priority (or both) of the top node,
|
|
* depending on the extract flag.
|
|
*/
|
|
public function top() {
|
|
return $this->heap->top();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/splpriorityqueue.valid.php )
|
|
*
|
|
* Checks if the queue contains any more nodes.
|
|
*
|
|
* @return mixed Returns TRUE if the queue contains any more nodes,
|
|
* FALSE otherwise.
|
|
*/
|
|
public function valid() {
|
|
return $this->heap->valid();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/splpriorityqueue.setextractflags.php )
|
|
*
|
|
*
|
|
* @flags mixed Defines what is extracted by
|
|
* SplPriorityQueue::current(), SplPriorityQueue::top()
|
|
* and SplPriorityQueue::extract().
|
|
* SplPriorityQueue::EXTR_DATA (0x00000001): Extract
|
|
* the data SplPriorityQueue::EXTR_PRIORITY
|
|
* (0x00000002): Extract the priority
|
|
* SplPriorityQueue::EXTR_BOTH (0x00000003): Extract an
|
|
* array containing both
|
|
*
|
|
* The default mode is SplPriorityQueue::EXTR_DATA.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function setExtractFlags($flags) {
|
|
$this->flags = $flags;
|
|
}
|
|
|
|
public function getExtractFlags() {
|
|
return $this->flags;
|
|
}
|
|
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.appenditerator.php )
|
|
*
|
|
* An Iterator that iterates over several iterators one after the other.
|
|
*
|
|
*/
|
|
class AppendIterator implements OuterIterator {
|
|
private $iterators;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/appenditerator.construct.php )
|
|
*
|
|
* Constructs an AppendIterator.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
function __construct() {
|
|
$this->iterators = new ArrayIterator(array());
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/appenditerator.append.php )
|
|
*
|
|
* Appends an iterator.
|
|
*
|
|
* @it mixed The iterator to append.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
function append(Iterator $it) {
|
|
$this->iterators->append($it);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/appenditerator.getinneriterator.php )
|
|
*
|
|
* This method returns the current inner iterator.
|
|
*
|
|
* @return mixed The current inner iterator, or NULL if there is not
|
|
* one.
|
|
*/
|
|
function getInnerIterator() {
|
|
return $this->iterators->current();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/appenditerator.rewind.php )
|
|
*
|
|
* Rewind to the first element of the first inner Iterator.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
function rewind() {
|
|
$this->iterators->rewind();
|
|
if ($this->iterators->valid()) {
|
|
$this->getInnerIterator()->rewind();
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/appenditerator.valid.php )
|
|
*
|
|
* Checks validity of the current element.
|
|
*
|
|
* @return mixed Returns TRUE if the current iteration is valid,
|
|
* FALSE otherwise.
|
|
*/
|
|
function valid() {
|
|
return $this->iterators->valid() && $this->getInnerIterator()->valid();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/appenditerator.current.php )
|
|
*
|
|
* Gets the current value.
|
|
*
|
|
* @return mixed The current value if it is valid or NULL otherwise.
|
|
*/
|
|
function current() {
|
|
/* Using $this->valid() would be exactly the same; it would omit
|
|
* the access to a non valid element in the inner iterator. Since
|
|
* the user didn't respect the valid() return value false this
|
|
* must be intended hence we go on. */
|
|
return $this->iterators->valid() ?
|
|
$this->getInnerIterator()->current() : NULL;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/appenditerator.key.php )
|
|
*
|
|
* Get the current key.
|
|
*
|
|
* @return mixed The current key if it is valid or NULL otherwise.
|
|
*/
|
|
function key() {
|
|
return $this->iterators->valid() ? $this->getInnerIterator()->key() : NULL;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/appenditerator.next.php )
|
|
*
|
|
* Moves to the next element. If this means to another Iterator then it
|
|
* rewinds that Iterator.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
function next() {
|
|
if (!$this->iterators->valid()){
|
|
return; /* done all */
|
|
}
|
|
$this->getInnerIterator()->next();
|
|
if ($this->getInnerIterator()->valid()) {
|
|
return; /* found valid element in current inner iterator */
|
|
}
|
|
$this->iterators->next();
|
|
while ($this->iterators->valid()) {
|
|
$this->getInnerIterator()->rewind();
|
|
if ($this->getInnerIterator()->valid()) {
|
|
return; /* found element as first elemet in another iterator */
|
|
}
|
|
$this->iterators->next();
|
|
}
|
|
}
|
|
|
|
function __call($func, $params) {
|
|
return call_user_func_array(array($this->getInnerIterator(), $func),
|
|
$params);
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.arrayiterator.php )
|
|
*
|
|
* This iterator allows to unset and modify values and keys while
|
|
* iterating over Arrays and Objects.
|
|
*
|
|
* When you want to iterate over the same array multiple times you need to
|
|
* instantiate ArrayObject and let it create ArrayIterator instances that
|
|
* refer to it either by using foreach or by calling its getIterator()
|
|
* method manually.
|
|
*
|
|
*/
|
|
class ArrayIterator implements ArrayAccess, SeekableIterator, Countable {
|
|
protected $arr;
|
|
protected $flags;
|
|
|
|
const STD_PROP_LIST = 1;
|
|
const ARRAY_AS_PROPS = 2;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.construct.php )
|
|
*
|
|
* Constructs an ArrayIterator object. WarningThis function is currently
|
|
* not documented; only its argument list is available.
|
|
*
|
|
* @array mixed The array or object to be iterated on.
|
|
*
|
|
* @return mixed An ArrayIterator object.
|
|
*/
|
|
public function __construct($array = array(), $flags = 0) {
|
|
$this->arr = (array) $array;
|
|
$this->flags = $flags;
|
|
reset($this->arr);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.append.php )
|
|
*
|
|
* Appends value as the last element. WarningThis function is currently
|
|
* not documented; only its argument list is available.
|
|
*
|
|
* @value mixed The value to append.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function append($value) {
|
|
$this->arr[] = $value;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.asort.php )
|
|
*
|
|
* Sorts an array by values. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function asort() {
|
|
return asort($this->arr);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.count.php )
|
|
*
|
|
* Gets the number of elements in the array, or the number of public
|
|
* properties in the object. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed The number of elements or public properties in the
|
|
* associated array or object, respectively.
|
|
*/
|
|
public function count() {
|
|
return count($this->arr);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.current.php )
|
|
*
|
|
* Get the current array entry.
|
|
*
|
|
* @return mixed The current array entry.
|
|
*/
|
|
public function current() {
|
|
return current($this->arr);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.getarraycopy.php )
|
|
*
|
|
* Get a copy of an array. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed A copy of the array, or array of public properties
|
|
* if ArrayIterator refers to an object.
|
|
*/
|
|
public function getArrayCopy() {
|
|
return $this->arr;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.getflags.php )
|
|
*
|
|
* Get the current flags. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed The current flags.
|
|
*/
|
|
public function getFlags() {
|
|
return $this->flags;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.key.php )
|
|
*
|
|
* This function returns the current array key
|
|
*
|
|
* @return mixed The current array key.
|
|
*/
|
|
public function key() {
|
|
return key($this->arr);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.ksort.php )
|
|
*
|
|
* Sorts an array by the keys. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function ksort() {
|
|
return ksort($this->arr);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.natcasesort.php )
|
|
*
|
|
* Sort the entries by values using a case insensitive "natural order"
|
|
* algorithm. WarningThis function is currently not documented; only its
|
|
* argument list is available.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function natcasesort() {
|
|
return natcasesort($this->arr);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.natsort.php )
|
|
*
|
|
* Sort the entries by values using "natural order" algorithm. WarningThis
|
|
* function is currently not documented; only its argument list is
|
|
* available.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function natsort() {
|
|
return natsort($this->arr);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.next.php )
|
|
*
|
|
* The iterator to the next entry.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function next() {
|
|
next($this->arr);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.offsetexists.php )
|
|
*
|
|
* Checks if the offset exists. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @index mixed The offset being checked.
|
|
*
|
|
* @return mixed TRUE if the offset exists, otherwise FALSE
|
|
*/
|
|
public function offsetExists($index) {
|
|
return isset($this->arr[$index]);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.offsetget.php )
|
|
*
|
|
* Gets the value from the provided offset. WarningThis function is
|
|
* currently not documented; only its argument list is available.
|
|
*
|
|
* @index mixed The offset to get the value from.
|
|
*
|
|
* @return mixed The value at offset index.
|
|
*/
|
|
public function offsetGet($index) {
|
|
return $this->arr[$index];
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.offsetset.php )
|
|
*
|
|
* Sets a value for a given offset. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @index mixed The index to set for.
|
|
* @newval mixed The new value to store at the index.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function offsetSet($index, $newval) {
|
|
$this->arr[$index] = $newval;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.offsetunset.php )
|
|
*
|
|
* Unsets a value for an offset. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @index mixed The offset to unset.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function offsetUnset($index) {
|
|
unset($this->arr[$index]);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.rewind.php )
|
|
*
|
|
* This rewinds the iterator to the beginning.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function rewind() {
|
|
reset($this->arr);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.seek.php )
|
|
*
|
|
*
|
|
* @position mixed The position to seek to.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function seek($position) {
|
|
reset($this->arr);
|
|
for ($i = 0; $i < $position; $i++) {
|
|
if (!next($this->arr)) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.setflags.php )
|
|
*
|
|
* Sets behaviour flags. WarningThis function is currently not documented;
|
|
* only its argument list is available.
|
|
*
|
|
* @flags mixed A bitmask as follows: 0 = Properties of the object
|
|
* have their normal functionality when accessed as
|
|
* list (var_dump, foreach, etc.). 1 = Array indices
|
|
* can be accessed as properties in read/write.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function setFlags($flags) {
|
|
$this->flags = $flags;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.uasort.php )
|
|
*
|
|
* Sort the entries by values using user defined function. WarningThis
|
|
* function is currently not documented; only its argument list is
|
|
* available.
|
|
*
|
|
* @cmp_function
|
|
* mixed The compare function used for the sort.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function uasort($cmp_function) {
|
|
return uasort($this->arr, $cmp_function);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.uksort.php )
|
|
*
|
|
* Sort the entries by key using user defined function. WarningThis
|
|
* function is currently not documented; only its argument list is
|
|
* available.
|
|
*
|
|
* @cmp_function
|
|
* mixed The compare function used for the sort.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function uksort($cmp_function) {
|
|
return uksort($this->arr, $cmp_function);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayiterator.valid.php )
|
|
*
|
|
* Checks if the array contains any more entries.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function valid() {
|
|
return key($this->arr) !== null;
|
|
}
|
|
}
|
|
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.filteriterator.php )
|
|
*
|
|
* This abstract iterator filters out unwanted values. This class should
|
|
* be extended to implement custom iterator filters. The
|
|
* FilterIterator::accept() must be implemented in the subclass.
|
|
*
|
|
*/
|
|
abstract class FilterIterator extends IteratorIterator {
|
|
private $it;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filteriterator.construct.php )
|
|
*
|
|
* Constructs a new FilterIterator, which consists of a passed in iterator
|
|
* with filters applied to it. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @it mixed The iterator that is being filtered.
|
|
*
|
|
* @return mixed The FilterIterator.
|
|
*/
|
|
public function __construct(Iterator $it) {
|
|
$this->it = $it;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filteriterator.rewind.php )
|
|
*
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function rewind() {
|
|
$this->it->rewind();
|
|
$this->fetch();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filteriterator.accept.php )
|
|
*
|
|
* Returns whether the current element of the iterator is acceptable
|
|
* through this filter.
|
|
*
|
|
* @return mixed TRUE if the current element is acceptable, otherwise
|
|
* FALSE.
|
|
*/
|
|
abstract function accept();
|
|
|
|
private function fetch() {
|
|
while ($this->it->valid()) {
|
|
if ($this->accept()) {
|
|
return;
|
|
}
|
|
$this->it->next();
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filteriterator.next.php )
|
|
*
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function next() {
|
|
$this->it->next();
|
|
$this->fetch();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filteriterator.valid.php )
|
|
*
|
|
*
|
|
* @return mixed TRUE if the current element is valid, otherwise
|
|
* FALSE
|
|
*/
|
|
public function valid() {
|
|
return $this->it->valid();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filteriterator.key.php )
|
|
*
|
|
*
|
|
* @return mixed The current key.
|
|
*/
|
|
public function key() {
|
|
return $this->it->key();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/filteriterator.current.php )
|
|
*
|
|
*
|
|
* @return mixed The current element value.
|
|
*/
|
|
public function current() {
|
|
return $this->it->current();
|
|
}
|
|
|
|
protected function __clone() {
|
|
// disallow clone
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/filteriterator.getinneriterator.php )
|
|
*
|
|
*
|
|
* @return mixed The inner iterator.
|
|
*/
|
|
public function getInnerIterator() {
|
|
return $this->it;
|
|
}
|
|
|
|
public function __call($func, $params) {
|
|
return call_user_func_array(array($this->it, $func), $params);
|
|
}
|
|
}
|
|
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/class.recursiveiteratoriterator.php )
|
|
*
|
|
* Can be used to iterate through recursive iterators.
|
|
*
|
|
*/
|
|
class RecursiveIteratorIterator implements OuterIterator, Traversable {
|
|
|
|
const LEAVES_ONLY = 0;
|
|
const SELF_FIRST = 1;
|
|
const CHILD_FIRST = 2;
|
|
const CATCH_GET_CHILD = 16;
|
|
|
|
private $iterators = array();
|
|
private $originalIterator;
|
|
private $mode;
|
|
private $flags;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursiveiteratoriterator.construct.php )
|
|
*
|
|
* Creates a RecursiveIteratorIterator from a RecursiveIterator.
|
|
*
|
|
* @iterator mixed The iterator being constructed from. Either a
|
|
* RecursiveIterator or IteratorAggregate.
|
|
* @mode mixed Optional mode. Possible values are
|
|
* RecursiveIteratorIterator::LEAVES_ONLY - The
|
|
* default. Lists only leaves in iteration.
|
|
* RecursiveIteratorIterator::SELF_FIRST - Lists leaves
|
|
* and parents in iteration with parents coming first.
|
|
* RecursiveIteratorIterator::CHILD_FIRST - Lists
|
|
* leaves and parents in iteration with leaves coming
|
|
* first.
|
|
* @flags mixed Optional flag. Possible values are
|
|
* RecursiveIteratorIterator::CATCH_GET_CHILD which
|
|
* will then ignore exceptions thrown in calls to
|
|
* RecursiveIteratorIterator::getChildren().
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function __construct($iterator,
|
|
$mode = RecursiveIteratorIterator::LEAVES_ONLY,
|
|
$flags = 0) {
|
|
$this->iterators[] = array($iterator, 0);
|
|
$this->originalIterator = $iterator;
|
|
$this->mode = (int) $mode;
|
|
$this->flags = $flags;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursiveiteratoriterator.getinneriterator.php
|
|
* )
|
|
*
|
|
* Gets the current active sub iterator. WarningThis function is currently
|
|
* not documented; only its argument list is available.
|
|
*
|
|
* @return mixed The current active sub iterator.
|
|
*/
|
|
public function getInnerIterator() {
|
|
$it = $this->iterators[count($this->iterators)-1][0];
|
|
if (!$it instanceof RecursiveDirectoryIterator) {
|
|
throw new Exception(
|
|
"RecursiveIteratorIterator only supports RecursiveDirectoryIterator"
|
|
);
|
|
}
|
|
return $it;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursiveiteratoriterator.current.php )
|
|
*
|
|
*
|
|
* @return mixed The current elements value.
|
|
*/
|
|
public function current() {
|
|
return $this->getInnerIterator()->current();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursiveiteratoriterator.key.php )
|
|
*
|
|
*
|
|
* @return mixed The current key.
|
|
*/
|
|
public function key() {
|
|
return $this->getInnerIterator()->key();
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursiveiteratoriterator.next.php )
|
|
*
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function next() {
|
|
if ($this->isEmpty()) {
|
|
return;
|
|
}
|
|
|
|
$it = $this->getInnerIterator();
|
|
|
|
if ($this->mode == self::SELF_FIRST) {
|
|
if ($it->hasChildren() && !$this->getInnerIteratorFlag()) {
|
|
$this->setInnerIteratorFlag(1);
|
|
$newit = $it->getChildren();
|
|
$this->iterators[] = array($newit, 0);
|
|
} else {
|
|
$it->next();
|
|
$this->setInnerIteratorFlag(0);
|
|
}
|
|
|
|
if ($this->valid()) {
|
|
return;
|
|
}
|
|
array_pop($this->iterators);
|
|
return $this->next();
|
|
} else if ($this->mode == self::CHILD_FIRST ||
|
|
$this->mode == self::LEAVES_ONLY) {
|
|
|
|
if (!$it->valid()) {
|
|
array_pop($this->iterators);
|
|
return $this->next();
|
|
} else if ($it->hasChildren()) {
|
|
if (!$this->getInnerIteratorFlag()) {
|
|
$this->setInnerIteratorFlag(1);
|
|
$this->iterators[] = array($it->getChildren(), 0);
|
|
if ($this->valid()) {
|
|
return;
|
|
}
|
|
return $this->next();
|
|
} else {
|
|
// CHILD_FIRST: 0 - drill down; 1 - visit 2 - next
|
|
// LEAVES_ONLY: 0 - drill down; 1 - next
|
|
if ($this->mode == self::CHILD_FIRST &&
|
|
$this->getInnerIteratorFlag() == 1) {
|
|
$this->setInnerIteratorFlag(2);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->setInnerIteratorFlag(0);
|
|
$it->next();
|
|
if ($this->valid()) {
|
|
return;
|
|
}
|
|
return $this->next();
|
|
} else {
|
|
$this->setInnerIteratorFlag(0);
|
|
$it->next();
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursiveiteratoriterator.rewind.php )
|
|
*
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function rewind() {
|
|
$it = $this->originalIterator;
|
|
$this->iterators = array(array($it, 0));
|
|
$it->rewind();
|
|
|
|
// Make sure the first entry is valid
|
|
if (!$this->valid()) {
|
|
$this->next();
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from
|
|
* http://php.net/manual/en/recursiveiteratoriterator.valid.php )
|
|
*
|
|
*
|
|
* @return mixed TRUE if the current position is valid, otherwise
|
|
* FALSE
|
|
*/
|
|
public function valid() {
|
|
if ($this->isEmpty()) {
|
|
return false;
|
|
}
|
|
|
|
$it = $this->getInnerIterator();
|
|
if ($it->valid() &&
|
|
$it->isDir() &&
|
|
($this->mode == self::LEAVES_ONLY ||
|
|
($this->mode == self::CHILD_FIRST &&
|
|
$this->getInnerIteratorFlag() == 0))) {
|
|
return false;
|
|
}
|
|
return $it->valid();
|
|
}
|
|
|
|
private function isEmpty() {
|
|
return count($this->iterators) == 0;
|
|
}
|
|
|
|
private function getInnerIteratorFlag() {
|
|
return $this->iterators[count($this->iterators)-1][1];
|
|
}
|
|
|
|
private function setInnerIteratorFlag($flag) {
|
|
$this->iterators[count($this->iterators)-1][1] = $flag;
|
|
}
|
|
}
|
|
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/class.arrayobject.php )
|
|
*
|
|
* This class allows objects to work as arrays.
|
|
*
|
|
*/
|
|
class ArrayObject implements IteratorAggregate, Traversable, ArrayAccess,
|
|
Serializable, Countable {
|
|
|
|
const integer STD_PROP_LIST = 1;
|
|
const integer ARRAY_AS_PROPS = 2;
|
|
|
|
private $storage;
|
|
private $flags;
|
|
private $iteratorClass;
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.construct.php )
|
|
*
|
|
* This constructs a new array object.
|
|
*
|
|
* @input mixed The input parameter accepts an array or an Object.
|
|
* @flags mixed Flags to control the behaviour of the ArrayObject
|
|
* object. See ArrayObject::setFlags().
|
|
* @iterator_class
|
|
* mixed Specify the class that will be used for iteration of
|
|
* the ArrayObject object.
|
|
*
|
|
* @return mixed Returns an ArrayObject object on success.
|
|
*/
|
|
public function __construct($input = null,
|
|
int $flags = 0,
|
|
string $iterator_class = "ArrayIterator") {
|
|
if (!$input) {
|
|
$input = array();
|
|
}
|
|
$this->storage = $input;
|
|
$this->flags = $flags;
|
|
$this->iteratorClass = $iterator_class;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.append.php )
|
|
*
|
|
* Appends a new value as the last element.
|
|
*
|
|
* This method cannot be called when the ArrayObject was constructed from
|
|
* an object. Use ArrayObject::offsetSet() instead.
|
|
*
|
|
* @value mixed The value being appended.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function append($value) {
|
|
if (!$this->isArray()) {
|
|
throw new Exception(
|
|
'Cannot append properties to objects, '.
|
|
'use ArrayObject::offsetSet() instead'
|
|
);
|
|
}
|
|
$this->storage[] = $value;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.asort.php )
|
|
*
|
|
* Sorts the entries such that the keys maintain their correlation with
|
|
* the entries they are associated with. This is used mainly when sorting
|
|
* associative arrays where the actual element order is significant.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function asort() {
|
|
return asort($this->storage);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.count.php )
|
|
*
|
|
* Get the number of public properties in the ArrayObject.
|
|
*
|
|
* @return mixed The number of public properties in the ArrayObject.
|
|
*
|
|
* When the ArrayObject is constructed from an array
|
|
* all properties are public.
|
|
*/
|
|
public function count() {
|
|
return count($this->storage);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.exchangearray.php )
|
|
*
|
|
* Exchange the current array with another array or object.
|
|
*
|
|
* @input mixed The new array or object to exchange with the current
|
|
* array.
|
|
*
|
|
* @return mixed Returns the old array.
|
|
*/
|
|
public function exchangeArray($input) {
|
|
$old = $this->storage;
|
|
$this->storage = $input;
|
|
return $old;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.getarraycopy.php )
|
|
*
|
|
* Exports the ArrayObject to an array.
|
|
*
|
|
* @return mixed Returns a copy of the array. When the ArrayObject
|
|
* refers to an object an array of the public
|
|
* properties of that object will be returned.
|
|
*/
|
|
public function getArrayCopy() {
|
|
return (array) $this->storage;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.getflags.php )
|
|
*
|
|
* Gets the behavior flags of the ArrayObject. See the
|
|
* ArrayObject::setFlags method for a list of the available flags.
|
|
*
|
|
* @return mixed Returns the behavior flags of the ArrayObject.
|
|
*/
|
|
public function getFlags() {
|
|
return $this->flags;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.getiterator.php )
|
|
*
|
|
* Create a new iterator from an ArrayObject instance.
|
|
*
|
|
* @return mixed An iterator from an ArrayObject.
|
|
*/
|
|
public function getIterator() {
|
|
$class = $this->iteratorClass;
|
|
return new $class($this->storage, $this->flags);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.getiteratorclass.php
|
|
* )
|
|
*
|
|
* Gets the class name of the array iterator that is used by
|
|
* ArrayObject::getIterator().
|
|
*
|
|
* @return mixed Returns the iterator class name that is used to
|
|
* iterate over this object.
|
|
*/
|
|
public function getIteratorClass() {
|
|
return $this->iteratorClass;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.ksort.php )
|
|
*
|
|
* Sorts the entries by key, maintaining key to entry correlations. This
|
|
* is useful mainly for associative arrays.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function ksort() {
|
|
return ksort($this->storage);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.natcasesort.php )
|
|
*
|
|
* This method is a case insensitive version of ArrayObject::natsort.
|
|
*
|
|
* This method implements a sort algorithm that orders alphanumeric
|
|
* strings in the way a human being would while maintaining key/value
|
|
* associations. This is described as a "natural ordering".
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function natcasesort() {
|
|
return natcasesort($this->storage);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.natsort.php )
|
|
*
|
|
* This method implements a sort algorithm that orders alphanumeric
|
|
* strings in the way a human being would while maintaining key/value
|
|
* associations. This is described as a "natural ordering". An example of
|
|
* the difference between this algorithm and the regular computer string
|
|
* sorting algorithms (used in ArrayObject::asort) method can be seen in
|
|
* the example below.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function natsort() {
|
|
return natsort($this->storage);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.offsetexists.php )
|
|
*
|
|
*
|
|
* @index mixed The index being checked.
|
|
*
|
|
* @return mixed TRUE if the requested index exists, otherwise FALSE
|
|
*/
|
|
public function offsetExists($index) {
|
|
if ($this->isArray()) {
|
|
return isset($this->storage[$index]);
|
|
} else {
|
|
return property_exists($this->storage, $index);
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.offsetget.php )
|
|
*
|
|
*
|
|
* @index mixed The index with the value.
|
|
*
|
|
* @return mixed The value at the specified index or NULL.
|
|
*/
|
|
public function offsetGet($index) {
|
|
if ($this->isArray()) {
|
|
return $this->storage[$index];
|
|
} else {
|
|
$obj = $this->storage;
|
|
return $obj->$index;
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.offsetset.php )
|
|
*
|
|
* Sets the value at the specified index to newval.
|
|
*
|
|
* @index mixed The index being set.
|
|
* @newval mixed The new value for the index.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function offsetSet($index, $newval) {
|
|
if ($this->isArray()) {
|
|
$this->storage[$index] = $newval;
|
|
} else {
|
|
$obj = $this->storage;
|
|
$obj->$index = $newval;
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.offsetunset.php )
|
|
*
|
|
* Unsets the value at the specified index.
|
|
*
|
|
* @index mixed The index being unset.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function offsetUnset($index) {
|
|
if ($this->isArray()) {
|
|
unset($this->storage[$index]);
|
|
} else {
|
|
$obj = $this->storage;
|
|
unset($obj->$index);
|
|
}
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.serialize.php )
|
|
*
|
|
* Serializes an ArrayObject. WarningThis function is currently not
|
|
* documented; only its argument list is available.
|
|
*
|
|
* @return mixed The serialized representation of the ArrayObject.
|
|
*/
|
|
public function serialize() {
|
|
return serialize(array(
|
|
'storage' => $this->storage,
|
|
'flags' => $this->flags,
|
|
'iteratorClass' => $this->iteratorClass,
|
|
));
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.setflags.php )
|
|
*
|
|
* Set the flags that change the behavior of the ArrayObject.
|
|
*
|
|
* @flags mixed The new ArrayObject behavior. It takes on either a
|
|
* bitmask, or named constants. Using named constants
|
|
* is strongly encouraged to ensure compatibility for
|
|
* future versions.
|
|
*
|
|
* The available behavior flags are listed below. The
|
|
* actual meanings of these flags are described in the
|
|
* predefined constants. ArrayObject behavior flags
|
|
* value constant 1 ArrayObject::STD_PROP_LIST 2
|
|
* ArrayObject::ARRAY_AS_PROPS
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function setFlags(int $flags) {
|
|
$this->flags = $flags;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.setiteratorclass.php
|
|
* )
|
|
*
|
|
* Sets the classname of the array iterator that is used by
|
|
* ArrayObject::getIterator().
|
|
*
|
|
* @iterator_class
|
|
* mixed The classname of the array iterator to use when
|
|
* iterating over this object.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function setIteratorClass(string $iterator_class) {
|
|
$this->iteratorClass = $iterator_class;
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.uasort.php )
|
|
*
|
|
* This function sorts the entries such that keys maintain their
|
|
* correlation with the entry that they are associated with, using a
|
|
* user-defined comparison function.
|
|
*
|
|
* This is used mainly when sorting associative arrays where the actual
|
|
* element order is significant.
|
|
*
|
|
* @cmp_function
|
|
* mixed Function cmp_function should accept two parameters
|
|
* which will be filled by pairs of entries. The
|
|
* comparison function must return an integer less
|
|
* than, equal to, or greater than zero if the first
|
|
* argument is considered to be respectively less than,
|
|
* equal to, or greater than the second.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function uasort($cmp_function) {
|
|
uasort($this->storage, $cmp_function);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.uksort.php )
|
|
*
|
|
* This function sorts the keys of the entries using a user-supplied
|
|
* comparison function. The key to entry correlations will be maintained.
|
|
*
|
|
* @cmp_function
|
|
* mixed The callback comparison function.
|
|
*
|
|
* Function cmp_function should accept two parameters
|
|
* which will be filled by pairs of entry keys. The
|
|
* comparison function must return an integer less
|
|
* than, equal to, or greater than zero if the first
|
|
* argument is considered to be respectively less than,
|
|
* equal to, or greater than the second.
|
|
*
|
|
* @return mixed No value is returned.
|
|
*/
|
|
public function uksort($cmp_function) {
|
|
uksort($this->storage, $cmp_function);
|
|
}
|
|
|
|
// This doc comment block generated by idl/sysdoc.php
|
|
/**
|
|
* ( excerpt from http://php.net/manual/en/arrayobject.unserialize.php )
|
|
*
|
|
* Unserializes a serialized ArrayObject. WarningThis function is
|
|
* currently not documented; only its argument list is available.
|
|
*
|
|
* @serialized mixed The serialized ArrayObject.
|
|
*
|
|
* @return mixed The unserialized ArrayObject.
|
|
*/
|
|
public function unserialize($serialized) {
|
|
if (empty($serialized)) {
|
|
throw new UnexpectedValueException(
|
|
'Empty serialized string cannot be empty'
|
|
);
|
|
}
|
|
$data = unserialize($serialized);
|
|
$this->storage = $data['storage'];
|
|
$this->flags = $data['flags'];
|
|
$this->iteratorClass = $data['iteratorClass'];
|
|
}
|
|
|
|
public function __set (string $name, $value) {
|
|
if (!$this->hasProps()) {
|
|
$this->$name = $value;
|
|
} else {
|
|
return $this->offsetSet($name, $value);
|
|
}
|
|
}
|
|
|
|
public function __get (string $name) {
|
|
if (!$this->hasProps()) {
|
|
return $this->$name;
|
|
} else {
|
|
return $this->offsetGet($name);
|
|
}
|
|
}
|
|
|
|
public function __isset (string $name) {
|
|
if (!$this->hasProps()) {
|
|
return isset($this->$name);
|
|
} else {
|
|
return $this->offsetExists($name);
|
|
}
|
|
}
|
|
|
|
public function __unset (string $name) {
|
|
if (!$this->hasProps()) {
|
|
unset($this->$name);
|
|
} else {
|
|
return $this->offsetUnset($name);
|
|
}
|
|
}
|
|
|
|
private function isArray() {
|
|
return is_array($this->storage);
|
|
}
|
|
|
|
private function hasProps() {
|
|
return $this->flags & self::ARRAY_AS_PROPS;
|
|
}
|
|
|
|
}
|
|
|
|
// Used as a sentinel type in 86pinit().
|
|
class __pinitSentinel {
|
|
}
|
|
|
|
// Used to represent resources
|
|
class __resource {
|
|
public function __toString() {
|
|
return hphp_to_string($this);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
<?hhas
|
|
|
|
.function array_filter($arr = no_args, $func = no_func, $res = entry) {
|
|
.numiters 2;
|
|
|
|
# if we get here, a value was supplied for $res
|
|
String "array_filter() expects at most 2 parameters"
|
|
Jmp warning
|
|
no_args: String "array_filter() expects at least 1 parameter, 0 given"
|
|
Jmp warning
|
|
not_array:String "array_filter() expects parameter 1 to be array"
|
|
Jmp warning
|
|
bad_func: String "array_filter() expects parameter 2 to be a valid callback"
|
|
Jmp warning
|
|
warning: Cns "E_USER_WARNING"
|
|
FCallBuiltin 2 2 "trigger_error"
|
|
PopR
|
|
Null
|
|
RetC
|
|
|
|
entry: IsArrayL $arr
|
|
JmpZ not_array
|
|
|
|
IssetL $func
|
|
JmpZ no_func
|
|
|
|
CGetL $func
|
|
DecodeCufIter 0 bad_func
|
|
.try_fault kill_iter_0 {
|
|
NewArray
|
|
SetL $res
|
|
PopC
|
|
|
|
CGetL $arr
|
|
WIterInitK 1 endloop_a $v $k
|
|
.try_fault kill_iter_1 1 {
|
|
loop_a: FPushCufIter 1 0
|
|
FPassL 0 $v
|
|
FCall 1
|
|
UnboxR
|
|
JmpZ skip_a
|
|
SetWithRefLM <L:$res EL:$k> $v
|
|
skip_a: WIterNextK 1 loop_a $v $k
|
|
}
|
|
}
|
|
endloop_a:CIterFree 0
|
|
endloop_n:CGetL $res
|
|
RetC
|
|
|
|
no_func: NewArray
|
|
SetL $res
|
|
PopC
|
|
CGetL $arr
|
|
WIterInitK 1 endloop_n $v $k
|
|
.try_fault kill_iter_1_only 1 {
|
|
loop_n: CGetL $v
|
|
JmpZ skip_n
|
|
SetWithRefLM <L:$res EL:$k> $v
|
|
skip_n: WIterNextK 1 loop_n $v $k
|
|
}
|
|
Jmp endloop_n
|
|
|
|
kill_iter_0:
|
|
CIterFree 0
|
|
Unwind
|
|
kill_iter_1:
|
|
IterFree 1
|
|
Unwind
|
|
# Needed for the verifier. Otherwise it complains
|
|
# because from in one fault region iter 0 is live
|
|
# and in the other its not.
|
|
kill_iter_1_only:
|
|
IterFree 1
|
|
Unwind
|
|
}
|
|
.function array_map($func = no_args, $arr = one_arg, $res = one_array) {
|
|
.numiters 2;
|
|
|
|
# If we get here, a value was supplied for $res
|
|
# so we bail out to the c++ implementation
|
|
FPushFuncD 1 "__builtin_array_map"
|
|
FCallBuiltin 0 0 "func_get_args"
|
|
UnboxR
|
|
FPassC 0
|
|
FCallArray
|
|
UnboxR
|
|
RetC
|
|
|
|
no_args: String "array_map() expects at least 2 parameters, 0 given"
|
|
Jmp warning
|
|
|
|
one_arg: String "array_map() expects at least 2 parameters, 1 given"
|
|
Jmp warning
|
|
|
|
not_array_citer_free:
|
|
CIterFree 0
|
|
not_array:String "array_map() expects parameter 2 to be array"
|
|
Jmp warning
|
|
bad_func: String "array_map() expects parameter 1 to be a valid callback"
|
|
Jmp warning
|
|
warning: Cns "E_USER_WARNING"
|
|
FCallBuiltin 2 2 "trigger_error"
|
|
PopR
|
|
Null
|
|
RetC
|
|
|
|
# but if we get here, there was only one array,
|
|
# so we use the fast, php version
|
|
|
|
one_array:IssetL $func
|
|
JmpZ ident
|
|
CGetL $func
|
|
DecodeCufIter 0 bad_func
|
|
.try_fault kill_iter_0 {
|
|
IsArrayL $arr
|
|
JmpZ not_array_citer_free
|
|
|
|
NewArray
|
|
SetL $res
|
|
PopC
|
|
|
|
CGetL $arr
|
|
WIterInitK 1 endloop $v $k
|
|
|
|
.try_fault kill_iter_1 1 {
|
|
loop_x: FPushCufIter 1 0
|
|
FPassL 0 $v
|
|
FCall 1
|
|
SetWithRefRM <L:$res EL:$k>
|
|
WIterNextK 1 loop_x $v $k
|
|
}
|
|
}
|
|
endloop: CIterFree 0
|
|
CGetL $res
|
|
RetC
|
|
|
|
ident: IsArrayL $arr
|
|
JmpZ not_array
|
|
CGetL $arr
|
|
RetC
|
|
|
|
kill_iter_0:
|
|
CIterFree 0
|
|
Unwind
|
|
kill_iter_1:
|
|
IterFree 1
|
|
Unwind
|
|
}
|