mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-04 02:52:25 +00:00
Moved spl to PocketMine-SPL
This commit is contained in:
parent
d6a0e284e3
commit
bda597a71e
5
.gitmodules
vendored
5
.gitmodules
vendored
@ -4,5 +4,8 @@
|
||||
branch = master
|
||||
[submodule "src/raklib"]
|
||||
path = src/raklib
|
||||
url = git@github.com:PocketMine/RakLib.git
|
||||
url = https://github.com/PocketMine/RakLib.git
|
||||
branch = master
|
||||
[submodule "src/spl"]
|
||||
path = src/spl
|
||||
url = https://github.com/PocketMine/PocketMine-SPL.git
|
||||
|
@ -19,12 +19,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
interface LoggerAttachment{
|
||||
namespace pocketmine;
|
||||
|
||||
class CompatibleClassLoader extends \BaseClassLoader{
|
||||
|
||||
/**
|
||||
* @param mixed $level
|
||||
* @param string $message
|
||||
* @deprecated
|
||||
*/
|
||||
public function log($level, $message);
|
||||
|
||||
public function add($namespace, $paths){
|
||||
$this->addPath(array_shift($paths));
|
||||
}
|
||||
}
|
@ -89,16 +89,14 @@ namespace pocketmine {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(!class_exists("SplClassLoader", false)){
|
||||
require_once(\pocketmine\PATH . "src/spl/SplClassLoader.php");
|
||||
if(!class_exists("ClassLoader", false)){
|
||||
require_once(\pocketmine\PATH . "src/spl/ClassLoader.php");
|
||||
require_once(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
|
||||
require_once(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
|
||||
}
|
||||
|
||||
$autoloader = new \SplClassLoader();
|
||||
$autoloader->setMode(\SplAutoloader::MODE_DEBUG);
|
||||
$autoloader->add("pocketmine", [
|
||||
\pocketmine\PATH . "src"
|
||||
]);
|
||||
|
||||
$autoloader = new CompatibleClassLoader();
|
||||
$autoloader->addPath(\pocketmine\PATH . "src");
|
||||
$autoloader->register(true);
|
||||
if(!class_exists("raklib\\RakLib", false)){
|
||||
require(\pocketmine\PATH . "src/raklib/raklib/RakLib.php");
|
||||
|
@ -455,7 +455,7 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \SplClassLoader
|
||||
* @return \ClassLoader
|
||||
*/
|
||||
public function getLoader(){
|
||||
return $this->autoloader;
|
||||
@ -1377,13 +1377,13 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \SplClassLoader $autoloader
|
||||
* @param \ClassLoader $autoloader
|
||||
* @param \ThreadedLogger $logger
|
||||
* @param string $filePath
|
||||
* @param string $dataPath
|
||||
* @param string $pluginPath
|
||||
*/
|
||||
public function __construct(\SplClassLoader $autoloader, \ThreadedLogger $logger, $filePath, $dataPath, $pluginPath){
|
||||
public function __construct(\ClassLoader $autoloader, \ThreadedLogger $logger, $filePath, $dataPath, $pluginPath){
|
||||
self::$instance = $this;
|
||||
|
||||
$this->autoloader = $autoloader;
|
||||
|
@ -93,7 +93,7 @@ class GenerationManager{
|
||||
protected $socket;
|
||||
/** @var \Logger */
|
||||
protected $logger;
|
||||
/** @var \SplAutoLoader */
|
||||
/** @var \ClassLoader */
|
||||
protected $loader;
|
||||
|
||||
/** @var GenerationChunkManager[] */
|
||||
@ -110,11 +110,11 @@ class GenerationManager{
|
||||
protected $shutdown = false;
|
||||
|
||||
/**
|
||||
* @param resource $socket
|
||||
* @param \Logger $logger
|
||||
* @param \SplAutoloader $loader
|
||||
* @param resource $socket
|
||||
* @param \Logger $logger
|
||||
* @param \ClassLoader $loader
|
||||
*/
|
||||
public function __construct($socket, \Logger $logger, \SplAutoloader $loader){
|
||||
public function __construct($socket, \Logger $logger, \ClassLoader $loader){
|
||||
$this->socket = $socket;
|
||||
$this->logger = $logger;
|
||||
$this->loader = $loader;
|
||||
@ -282,7 +282,7 @@ class GenerationManager{
|
||||
$namespace = substr($packet, $offset, $len);
|
||||
$offset += $len;
|
||||
$path = substr($packet, $offset);
|
||||
$this->loader->add($namespace, [$path]);
|
||||
$this->loader->addPath($path);
|
||||
}elseif($pid === self::PACKET_SHUTDOWN){
|
||||
foreach($this->levels as $level){
|
||||
$level->shutdown();
|
||||
|
@ -50,7 +50,7 @@ class GenerationThread extends Thread{
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
public function __construct(\ThreadedLogger $logger, \SplAutoloader $loader){
|
||||
public function __construct(\ThreadedLogger $logger, \ClassLoader $loader){
|
||||
$this->loader = $loader;
|
||||
$this->logger = $logger;
|
||||
$loadPaths = [];
|
||||
|
@ -58,9 +58,7 @@ class PharPluginLoader implements PluginLoader{
|
||||
}
|
||||
$file = "phar://$file";
|
||||
$className = $description->getMain();
|
||||
$this->server->getLoader()->add(substr($className, 0, strrpos($className, "\\")), array(
|
||||
"$file/src"
|
||||
));
|
||||
$this->server->getLoader()->addPath("$file/src");
|
||||
|
||||
if(class_exists($className, true)){
|
||||
$plugin = new $className();
|
||||
|
@ -26,11 +26,9 @@ use pocketmine\Worker;
|
||||
class AsyncWorker extends Worker{
|
||||
|
||||
public function run(){
|
||||
require(\pocketmine\PATH . "src/spl/SplClassLoader.php");
|
||||
$autoloader = new \SplClassLoader();
|
||||
$autoloader->add("pocketmine", array(
|
||||
\pocketmine\PATH . "src"
|
||||
));
|
||||
require(\pocketmine\PATH . "src/spl/ClassLoader.php");
|
||||
$autoloader = new \BaseClassLoader();
|
||||
$autoloader->addPath(\pocketmine\PATH . "src");
|
||||
$autoloader->register(true);
|
||||
}
|
||||
}
|
1
src/spl
Submodule
1
src/spl
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 58e1ee35a99845cebf4419e4b142131aafa48618
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
interface AttachableLogger extends \Logger{
|
||||
|
||||
/**
|
||||
* @param LoggerAttachment $attachment
|
||||
*/
|
||||
public function addAttachment(\LoggerAttachment $attachment);
|
||||
|
||||
/**
|
||||
* @param LoggerAttachment $attachment
|
||||
*/
|
||||
public function removeAttachment(\LoggerAttachment $attachment);
|
||||
|
||||
public function removeAttachments();
|
||||
|
||||
/**
|
||||
* @return \LoggerAttachment[]
|
||||
*/
|
||||
public function getAttachments();
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class AttachableThreadedLogger extends \ThreadedLogger{
|
||||
|
||||
/** @var \ThreadedLoggerAttachment */
|
||||
protected $attachment = null;
|
||||
|
||||
/**
|
||||
* @param ThreadedLoggerAttachment $attachment
|
||||
*/
|
||||
public function addAttachment(\ThreadedLoggerAttachment $attachment){
|
||||
if($this->attachment instanceof \ThreadedLoggerAttachment){
|
||||
$this->attachment->addAttachment($attachment);
|
||||
}else{
|
||||
$this->attachment = $attachment;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ThreadedLoggerAttachment $attachment
|
||||
*/
|
||||
public function removeAttachment(\ThreadedLoggerAttachment $attachment){
|
||||
if($this->attachment instanceof \ThreadedLoggerAttachment){
|
||||
if($this->attachment === $attachment){
|
||||
$this->attachment = null;
|
||||
foreach($attachment->getAttachments() as $attachment){
|
||||
$this->addAttachment($attachment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function removeAttachments(){
|
||||
if($this->attachment instanceof \ThreadedLoggerAttachment){
|
||||
$this->attachment->removeAttachments();
|
||||
$this->attachment = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ThreadedLoggerAttachment[]
|
||||
*/
|
||||
public function getAttachments(){
|
||||
$attachments = [];
|
||||
if($this->attachment instanceof \ThreadedLoggerAttachment){
|
||||
$attachments[] = $this->attachment;
|
||||
$attachments += $this->attachment->getAttachments();
|
||||
}
|
||||
return $attachments;
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
interface LogLevel{
|
||||
const EMERGENCY = "emergency";
|
||||
const ALERT = "alert";
|
||||
const CRITICAL = "critical";
|
||||
const ERROR = "error";
|
||||
const WARNING = "warning";
|
||||
const NOTICE = "notice";
|
||||
const INFO = "info";
|
||||
const DEBUG = "debug";
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
interface Logger{
|
||||
|
||||
/**
|
||||
* System is unusable
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function emergency($message);
|
||||
|
||||
/**
|
||||
* Action must me taken immediately
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function alert($message);
|
||||
|
||||
/**
|
||||
* Critical conditions
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function critical($message);
|
||||
|
||||
/**
|
||||
* Runtime errors that do not require immediate action but should typically
|
||||
* be logged and monitored.
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function error($message);
|
||||
|
||||
/**
|
||||
* Exceptional occurrences that are not errors.
|
||||
*
|
||||
* Example: Use of deprecated APIs, poor use of an API, undesirable things
|
||||
* that are not necessarily wrong.
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function warning($message);
|
||||
|
||||
/**
|
||||
* Normal but significant events.
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function notice($message);
|
||||
|
||||
/**
|
||||
* Inersting events.
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function info($message);
|
||||
|
||||
/**
|
||||
* Detailed debug information.
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function debug($message);
|
||||
|
||||
/**
|
||||
* Logs with an arbitrary level.
|
||||
*
|
||||
* @param mixed $level
|
||||
* @param string $message
|
||||
*/
|
||||
public function log($level, $message);
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SplAutoloader defines the contract that any OO based autoloader must follow.
|
||||
*
|
||||
* @author Guilherme Blanco <guilhermeblanco@php.net>
|
||||
*/
|
||||
interface SplAutoloader{
|
||||
/**
|
||||
* Defines autoloader to work silently if resource is not found.
|
||||
*
|
||||
* @const
|
||||
*/
|
||||
const MODE_SILENT = 0;
|
||||
|
||||
/**
|
||||
* Defines autoloader to work normally (requiring an un-existent resource).
|
||||
*
|
||||
* @const
|
||||
*/
|
||||
const MODE_NORMAL = 1;
|
||||
|
||||
/**
|
||||
* Defines autoloader to work in debug mode, loading file and validating requested resource.
|
||||
*
|
||||
* @const
|
||||
*/
|
||||
const MODE_DEBUG = 2;
|
||||
|
||||
/**
|
||||
* Define the autoloader work mode.
|
||||
*
|
||||
* @param integer $mode Autoloader work mode.
|
||||
*/
|
||||
public function setMode($mode);
|
||||
|
||||
/**
|
||||
* Add a new resource lookup path.
|
||||
*
|
||||
* @param string $resourceName Resource name, namespace or prefix.
|
||||
* @param mixed $resourcePath Resource single path or multiple paths (array).
|
||||
*/
|
||||
public function add($resourceName, $resourcePath = null);
|
||||
|
||||
/**
|
||||
* Load a resource through provided resource name.
|
||||
*
|
||||
* @param string $resourceName Resource name.
|
||||
*/
|
||||
public function load($resourceName);
|
||||
|
||||
/**
|
||||
* Register this as an autoloader instance.
|
||||
*
|
||||
* @param boolean $prepend Whether to prepend the autoloader or not in autoloader's list.
|
||||
*/
|
||||
public function register($prepend = false);
|
||||
|
||||
/**
|
||||
* Unregister this autoloader instance.
|
||||
*
|
||||
*/
|
||||
public function unregister();
|
||||
}
|
@ -1,244 +0,0 @@
|
||||
<?php
|
||||
|
||||
if(!interface_exists("SplAutoloader", false)){
|
||||
require("SplAutoloader.php");
|
||||
}
|
||||
|
||||
if(class_exists("SplClassLoader", false)){
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* SplClassLoader implementation that implements the technical interoperability
|
||||
* standards for PHP 5.3 namespaces and class names.
|
||||
*
|
||||
* https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* $classLoader = new \SplClassLoader();
|
||||
*
|
||||
* // Configure the SplClassLoader to act normally or silently
|
||||
* $classLoader->setMode(\SplClassLoader::MODE_NORMAL);
|
||||
*
|
||||
* // Add a namespace of classes
|
||||
* $classLoader->add('Doctrine', array(
|
||||
* '/path/to/doctrine-common', '/path/to/doctrine-dbal', '/path/to/doctrine-orm'
|
||||
* ));
|
||||
*
|
||||
* // Add a prefix
|
||||
* $classLoader->add('Swift', '/path/to/swift');
|
||||
*
|
||||
* // Add a prefix through PEAR1 convention, requiring include_path lookup
|
||||
* $classLoader->add('PEAR');
|
||||
*
|
||||
* // Allow to PHP use the include_path for file path lookup
|
||||
* $classLoader->setIncludePathLookup(true);
|
||||
*
|
||||
* // Possibility to change the default php file extension
|
||||
* $classLoader->setFileExtension('.php');
|
||||
*
|
||||
* // Register the autoloader, prepending it in the stack
|
||||
* $classLoader->register(true);
|
||||
*
|
||||
* @author Guilherme Blanco <guilhermeblanco@php.net>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
* @author Roman S. Borschel <roman@code-factory.org>
|
||||
* @author Matthew Weier O'Phinney <matthew@zend.com>
|
||||
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.org>
|
||||
*/
|
||||
class SplClassLoader implements SplAutoloader{
|
||||
/** @var string */
|
||||
private $fileExtension = '.php';
|
||||
|
||||
/** @var boolean */
|
||||
private $includePathLookup = false;
|
||||
|
||||
/** @var array */
|
||||
private $resources = [];
|
||||
|
||||
/** @var integer */
|
||||
private $mode = self::MODE_NORMAL;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setMode($mode){
|
||||
if($mode & self::MODE_SILENT && $mode & self::MODE_NORMAL){
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf('Cannot have %s working normally and silently at the same time!', __CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
$this->mode = $mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the file extension of resource files in the path of this class loader.
|
||||
*
|
||||
* @param string $fileExtension
|
||||
*/
|
||||
public function setFileExtension($fileExtension){
|
||||
$this->fileExtension = $fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the file extension of resource files in the path of this class loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileExtension(){
|
||||
return $this->fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include for class files. Allows easy loading installed PEAR packages.
|
||||
*
|
||||
* @param boolean $includePathLookup
|
||||
*/
|
||||
public function setIncludePathLookup($includePathLookup){
|
||||
$this->includePathLookup = $includePathLookup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base include path for all class files in the namespace of this class loader.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIncludePathLookup(){
|
||||
return $this->includePathLookup;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function register($prepend = false){
|
||||
spl_autoload_register(array($this, 'load'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function unregister(){
|
||||
spl_autoload_unregister(array($this, 'load'));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function add($resource, $resourcePath = null){
|
||||
if(isset($this->resources[$resource])){
|
||||
foreach((array) $resourcePath as $path){
|
||||
if(!in_array($path, $this->resources[$resource], true)){
|
||||
$this->resources[$resource][] = $path;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->resources[$resource] = (array) $resourcePath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load($resourceName){
|
||||
$resourceAbsolutePath = $this->getResourceAbsolutePath($resourceName);
|
||||
if($resourceAbsolutePath == ""){
|
||||
if($resourceName{0} !== "\\"){
|
||||
if(file_exists(dirname(__FILE__) ."/" . $resourceName . $this->fileExtension)){
|
||||
require dirname(__FILE__) ."/" . $resourceName . $this->fileExtension;
|
||||
if($this->isResourceDeclared($resourceName)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new \RuntimeException(
|
||||
sprintf('Autoloader couldn\'t find a file to include for %s', $resourceName)
|
||||
);
|
||||
}
|
||||
switch(true){
|
||||
case ($this->mode & self::MODE_SILENT):
|
||||
if($resourceAbsolutePath !== false){
|
||||
require $resourceAbsolutePath;
|
||||
}
|
||||
break;
|
||||
|
||||
case ($this->mode & self::MODE_NORMAL):
|
||||
default:
|
||||
require $resourceAbsolutePath;
|
||||
break;
|
||||
}
|
||||
|
||||
if($this->mode & self::MODE_DEBUG && !$this->isResourceDeclared($resourceName)){
|
||||
throw new \RuntimeException(
|
||||
sprintf('Autoloader expected resource "%s" to be declared in file "%s".', $resourceName, $resourceAbsolutePath)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform resource name into its absolute resource path representation.
|
||||
*
|
||||
* @param string $resourceName
|
||||
*
|
||||
* @return string Resource absolute path.
|
||||
*/
|
||||
private function getResourceAbsolutePath($resourceName){
|
||||
$resourceRelativePath = $this->getResourceRelativePath($resourceName);
|
||||
|
||||
foreach($this->resources as $resource => $resourcesPath){
|
||||
if(strpos($resourceName, $resource) !== 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach($resourcesPath as $resourcePath){
|
||||
$resourceAbsolutePath = $resourcePath . DIRECTORY_SEPARATOR . $resourceRelativePath;
|
||||
|
||||
if(is_file($resourceAbsolutePath)){
|
||||
return $resourceAbsolutePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($this->includePathLookup && ($resourceAbsolutePath = stream_resolve_include_path($resourceRelativePath)) !== false){
|
||||
return $resourceAbsolutePath;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Transform resource name into its relative resource path representation.
|
||||
*
|
||||
* @param string $resourceName
|
||||
*
|
||||
* @return string Resource relative path.
|
||||
*/
|
||||
private function getResourceRelativePath($resourceName){
|
||||
// We always work with FQCN in this context
|
||||
$resourceName = ltrim($resourceName, '\\');
|
||||
$resourcePath = '';
|
||||
|
||||
if(($lastNamespacePosition = strrpos($resourceName, '\\')) !== false){
|
||||
// Namespaced resource name
|
||||
$resourceNamespace = substr($resourceName, 0, $lastNamespacePosition);
|
||||
$resourceName = substr($resourceName, $lastNamespacePosition + 1);
|
||||
$resourcePath = str_replace('\\', DIRECTORY_SEPARATOR, $resourceNamespace) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
return $resourcePath . $resourceName . $this->fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if resource is declared in user space.
|
||||
*
|
||||
* @param string $resourceName
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function isResourceDeclared($resourceName){
|
||||
return class_exists($resourceName, false)
|
||||
|| interface_exists($resourceName, false)
|
||||
|| (function_exists('trait_exists') && trait_exists($resourceName, false));
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class ThreadedLogger extends \Thread implements Logger{
|
||||
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class ThreadedLoggerAttachment extends \Threaded implements \LoggerAttachment{
|
||||
|
||||
/** @var \ThreadedLoggerAttachment */
|
||||
protected $attachment = null;
|
||||
|
||||
/**
|
||||
* @param mixed $level
|
||||
* @param string $message
|
||||
*/
|
||||
public final function call($level, $message){
|
||||
$this->log($level, $message);
|
||||
if($this->attachment instanceof \ThreadedLoggerAttachment){
|
||||
$this->attachment->call($level, $message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ThreadedLoggerAttachment $attachment
|
||||
*/
|
||||
public function addAttachment(\ThreadedLoggerAttachment $attachment){
|
||||
if($this->attachment instanceof \ThreadedLoggerAttachment){
|
||||
$this->attachment->addAttachment($attachment);
|
||||
}else{
|
||||
$this->attachment = $attachment;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ThreadedLoggerAttachment $attachment
|
||||
*/
|
||||
public function removeAttachment(\ThreadedLoggerAttachment $attachment){
|
||||
if($this->attachment instanceof \ThreadedLoggerAttachment){
|
||||
if($this->attachment === $attachment){
|
||||
$this->attachment = null;
|
||||
foreach($attachment->getAttachments() as $attachment){
|
||||
$this->addAttachment($attachment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function removeAttachments(){
|
||||
if($this->attachment instanceof \ThreadedLoggerAttachment){
|
||||
$this->attachment->removeAttachments();
|
||||
$this->attachment = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ThreadedLoggerAttachment[]
|
||||
*/
|
||||
public function getAttachments(){
|
||||
$attachments = [];
|
||||
if($this->attachment instanceof \ThreadedLoggerAttachment){
|
||||
$attachments[] = $this->attachment;
|
||||
$attachments += $this->attachment->getAttachments();
|
||||
}
|
||||
return $attachments;
|
||||
}
|
||||
}
|
@ -1,693 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* pthreads extension stub file for code completion purposes
|
||||
*
|
||||
* WARNING: Do not include this file
|
||||
*
|
||||
* @author Lisachenko Alexander <lisachenko.it@gmail.com>
|
||||
* @version 2.0.0
|
||||
* @link https://github.com/krakjoe/pthreads/blob/master/examples/stub.php
|
||||
*/
|
||||
|
||||
/**
|
||||
* The default inheritance mask used when starting Threads and Workers
|
||||
*/
|
||||
define('PTHREADS_INHERIT_ALL', 0x111111);
|
||||
|
||||
/**
|
||||
* Nothing will be inherited by the new context
|
||||
*/
|
||||
define('PTHREADS_INHERIT_NONE', 0);
|
||||
|
||||
/**
|
||||
* Determines whether the ini entries are inherited by the new context
|
||||
*/
|
||||
define('PTHREADS_INHERIT_INI', 0x1);
|
||||
|
||||
/**
|
||||
* Determines whether the constants are inherited by the new context
|
||||
*/
|
||||
define('PTHREADS_INHERIT_CONSTANTS', 0x10);
|
||||
|
||||
/**
|
||||
* Determines whether the class table is inherited by the new context
|
||||
*/
|
||||
define('PTHREADS_INHERIT_CLASSES', 0x100);
|
||||
|
||||
/**
|
||||
* Determines whether the function table is inherited by the new context
|
||||
*/
|
||||
define('PTHREADS_INHERIT_FUNCTIONS', 0x100);
|
||||
|
||||
/**
|
||||
* Determines whether the included_files table is inherited by the new context
|
||||
*/
|
||||
define('PTHREADS_INHERIT_INCLUDES', 0x10000);
|
||||
|
||||
/**
|
||||
* Determines whether the comments are inherited by the new context
|
||||
*/
|
||||
define('PTHREADS_INHERIT_COMMENTS', 0x100000);
|
||||
|
||||
/**
|
||||
* Allow output headers from the threads
|
||||
*/
|
||||
define('PTHREADS_ALLOW_HEADERS', 0x1000000);
|
||||
|
||||
/**
|
||||
* Allow global inheritance for new threads
|
||||
*/
|
||||
define('PTHREADS_ALLOW_GLOBALS', 0x10000000);
|
||||
|
||||
/**
|
||||
* Threaded class
|
||||
*
|
||||
* Threaded objects form the basis of pthreads ability to execute user code asynchronously;
|
||||
* they expose and include synchronization methods and various useful interfaces.
|
||||
*
|
||||
* Threaded objects, most importantly, provide implicit safety for the programmer;
|
||||
* all operations on the object scope are safe.
|
||||
*
|
||||
* @link http://www.php.net/manual/en/class.threaded.php
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class Threaded implements Traversable, Countable, ArrayAccess{
|
||||
/**
|
||||
* Fetches a chunk of the objects properties table of the given size
|
||||
*
|
||||
* @param int $size The number of items to fetch
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.chunk.php
|
||||
* @return array An array of items from the objects member table
|
||||
*/
|
||||
public function chunk($size){
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function count(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves terminal error information from the referenced object
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.getterminationinfo.php
|
||||
* @return array|bool array containing the termination conditions of the referenced object
|
||||
*/
|
||||
public function getTerminationInfo(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the referenced object is executing
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.isrunning.php
|
||||
* @return bool A boolean indication of state
|
||||
*/
|
||||
public function isRunning(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the referenced object exited, suffered fatal errors, or threw uncaught exceptions during execution
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.isterminated.php
|
||||
* @return bool A boolean indication of state
|
||||
*/
|
||||
public function isTerminated(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the referenced object is waiting for notification
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.iswaiting.php
|
||||
* @return bool A boolean indication of state
|
||||
*/
|
||||
public function isWaiting(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock the referenced objects property table
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.lock.php
|
||||
* @return bool A boolean indication of state
|
||||
*/
|
||||
public function lock(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges data into the current object
|
||||
*
|
||||
* @param mixed $from The data to merge
|
||||
* @param bool $overwrite Overwrite existing keys flag, by default true
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.merge.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
public function merge($from, $overwrite = true){
|
||||
}
|
||||
|
||||
/**
|
||||
* Send notification to the referenced object
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.notify.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
public function notify(){
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function offsetGet($offset){
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function offsetSet($offset, $value){
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function offsetExists($offset){
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function offsetUnset($offset){
|
||||
}
|
||||
|
||||
/**
|
||||
* Pops an item from the objects property table
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.pop.php
|
||||
* @return mixed The last item from the objects properties table
|
||||
*/
|
||||
public function pop(){
|
||||
}
|
||||
|
||||
/**
|
||||
* The programmer should always implement the run method for objects that are intended for execution.
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.run.php
|
||||
* @return void The methods return value, if used, will be ignored
|
||||
*/
|
||||
public function run(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Shifts an item from the objects properties table
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.shift.php
|
||||
* @return mixed The first item from the objects properties table
|
||||
*/
|
||||
public function shift(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the block while retaining the synchronization lock for the current context.
|
||||
*
|
||||
* @param \Closure $function The block of code to execute
|
||||
* @param mixed $args ... Variable length list of arguments to use as function arguments to the block
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.synchronized.php
|
||||
* @return mixed The return value from the block
|
||||
*/
|
||||
public function synchronized(\Closure $function, $args = null){
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock the referenced objects storage for the calling context
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.unlock.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
public function unlock(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for notification from the Stackable
|
||||
*
|
||||
* @param int $timeout An optional timeout in microseconds
|
||||
*
|
||||
* @link http://www.php.net/manual/en/threaded.wait.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
public function wait($timeout){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic thread implementation
|
||||
*
|
||||
* An implementation of a Thread should extend this declaration, implementing the run method.
|
||||
* When the start method of that object is called, the run method code will be executed in separate Thread.
|
||||
*
|
||||
* @link http://www.php.net/manual/en/class.thread.php
|
||||
*/
|
||||
class Thread extends Threaded{
|
||||
|
||||
/**
|
||||
* Detaches a thread
|
||||
*
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
public function detach(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Will return the identity of the Thread that created the referenced Thread
|
||||
*
|
||||
* @link http://www.php.net/manual/en/thread.getcreatorid.php
|
||||
* @return int A numeric identity
|
||||
*/
|
||||
public function getCreatorId(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Will return the instance of currently executing thread
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function getCurrentThread(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Will return the identity of the currently executing thread
|
||||
*
|
||||
* @link http://www.php.net/manual/en/thread.getcurrentthreadid.php
|
||||
* @return int
|
||||
*/
|
||||
public static function getCurrentThreadId(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Will return the identity of the referenced Thread
|
||||
*
|
||||
* @link http://www.php.net/manual/en/thread.getthreadid.php
|
||||
* @return int
|
||||
*/
|
||||
public function getThreadId(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the referenced Thread has been joined by another context
|
||||
*
|
||||
* @link http://www.php.net/manual/en/thread.isjoined.php
|
||||
* @return bool A boolean indication of state
|
||||
*/
|
||||
public function isJoined(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the referenced Thread has been started
|
||||
*
|
||||
* @link http://www.php.net/manual/en/thread.isstarted.php
|
||||
* @return bool A boolean indication of state
|
||||
*/
|
||||
public function isStarted(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes the calling context to wait for the referenced Thread to finish executing
|
||||
*
|
||||
* @link http://www.php.net/manual/en/thread.join.php
|
||||
* @return bool A boolean indication of state
|
||||
*/
|
||||
public function join(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Kills the referenced thread, dangerously !
|
||||
*
|
||||
* @link http://www.php.net/manual/en/thread.kill.php
|
||||
*/
|
||||
public function kill(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Will start a new Thread to execute the implemented run method
|
||||
*
|
||||
* @param int $options An optional mask of inheritance constants, by default PTHREADS_INHERIT_ALL
|
||||
*
|
||||
* @link http://www.php.net/manual/en/thread.start.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
public function start($options = PTHREADS_INHERIT_ALL){
|
||||
}
|
||||
|
||||
/**
|
||||
* Will execute the Callable in the global scope
|
||||
*
|
||||
* @param Callable $block The code to execute
|
||||
* @param ... $args Variable length list of arguments to pass to the Callable upon execution
|
||||
*
|
||||
* @link http://www.php.net/manual/en/thread.start.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
public static function globally(Callable $block, $args = null){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Worker
|
||||
*
|
||||
* Worker Threads have a persistent context, as such should be used over Threads in most cases.
|
||||
*
|
||||
* When a Worker is started, the run method will be executed, but the Thread will not leave until one
|
||||
* of the following conditions are met:
|
||||
* - the Worker goes out of scope (no more references remain)
|
||||
* - the programmer calls shutdown
|
||||
* - the script dies
|
||||
* This means the programmer can reuse the context throughout execution; placing objects on the stack of
|
||||
* the Worker will cause the Worker to execute the stacked objects run method.
|
||||
*
|
||||
* @link http://www.php.net/manual/en/class.worker.php
|
||||
*/
|
||||
class Worker extends Thread{
|
||||
|
||||
/**
|
||||
* Returns the number of threaded tasks waiting to be executed by the referenced Worker
|
||||
*
|
||||
* @link http://www.php.net/manual/en/worker.getstacked.php
|
||||
* @return int An integral value
|
||||
*/
|
||||
public function getStacked(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the referenced Worker has been shutdown
|
||||
*
|
||||
* @link http://www.php.net/manual/en/worker.isshutdown.php
|
||||
* @return bool A boolean indication of state
|
||||
*/
|
||||
public function isShutdown(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if a Worker is executing threaded tasks
|
||||
*
|
||||
* @link http://www.php.net/manual/en/worker.isworking.php
|
||||
* @return bool A boolean indication of state
|
||||
*/
|
||||
public function isWorking(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down the Worker after executing all the threaded tasks previously stacked
|
||||
*
|
||||
* @link http://www.php.net/manual/en/worker.shutdown.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
public function shutdown(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the referenced object to the stack of the referenced Worker
|
||||
*
|
||||
* @param Threaded $work Threaded object to be executed by the referenced Worker
|
||||
*
|
||||
* @link http://www.php.net/manual/en/worker.stack.php
|
||||
* @return int The new length of the stack
|
||||
*/
|
||||
public function stack(Threaded &$work){
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the referenced object ( or all objects if parameter is null ) from stack of the referenced Worker
|
||||
*
|
||||
* @param Threaded $work Threaded object previously stacked onto Worker
|
||||
*
|
||||
* @link http://www.php.net/manual/en/worker.unstack.php
|
||||
* @return int The new length of the stack
|
||||
*/
|
||||
public function unstack(Threaded &$work = null){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutex class
|
||||
*
|
||||
* The static methods contained in the Mutex class provide direct access to Posix Mutex functionality.
|
||||
*
|
||||
* @link http://www.php.net/manual/en/class.mutex.php
|
||||
*/
|
||||
class Mutex{
|
||||
|
||||
/**
|
||||
* Create, and optionally lock a new Mutex for the caller
|
||||
*
|
||||
* @param bool $lock Setting lock to true will lock the Mutex for the caller before returning the handle
|
||||
*
|
||||
* @link http://www.php.net/manual/en/mutex.create.php
|
||||
* @return int A newly created and optionally locked Mutex handle
|
||||
*/
|
||||
final public static function create($lock = false){
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy mutex
|
||||
*
|
||||
* Destroying Mutex handles must be carried out explicitly by the programmer when they are
|
||||
* finished with the Mutex handle.
|
||||
*
|
||||
* @param int $mutex A handle returned by a previous call to Mutex::create().
|
||||
*
|
||||
* @link http://www.php.net/manual/en/mutex.destroy.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
final public static function destroy($mutex){
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to lock the Mutex for the caller.
|
||||
*
|
||||
* An attempt to lock a Mutex owned (locked) by another Thread will result in blocking.
|
||||
*
|
||||
* @param int $mutex A handle returned by a previous call to Mutex::create().
|
||||
*
|
||||
* @link http://www.php.net/manual/en/mutex.lock.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
final public static function lock($mutex){
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to lock the Mutex for the caller without blocking if the Mutex is owned (locked) by another Thread.
|
||||
*
|
||||
* @param int $mutex A handle returned by a previous call to Mutex::create().
|
||||
*
|
||||
* @link http://www.php.net/manual/en/mutex.trylock.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
final public static function trylock($mutex){
|
||||
}
|
||||
|
||||
/**
|
||||
* Release mutex
|
||||
*
|
||||
* Attempts to unlock the Mutex for the caller, optionally destroying the Mutex handle.
|
||||
* The calling thread should own the Mutex at the time of the call.
|
||||
*
|
||||
* @param int $mutex A handle returned by a previous call to Mutex::create().
|
||||
* @param bool $destroy When true pthreads will destroy the Mutex after a successful unlock.
|
||||
*
|
||||
* @link http://www.php.net/manual/en/mutex.unlock.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
final public static function unlock($mutex, $destroy = false){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Condition class
|
||||
*
|
||||
* The static methods contained in the Cond class provide direct access to Posix Condition Variables.
|
||||
*
|
||||
* @link http://www.php.net/manual/en/class.cond.php
|
||||
*/
|
||||
class Cond{
|
||||
/**
|
||||
* Broadcast to all Threads blocking on a call to Cond::wait().
|
||||
*
|
||||
* @param int $condition A handle to a Condition Variable returned by a previous call to Cond::create()
|
||||
*
|
||||
* @link http://www.php.net/manual/en/cond.broadcast.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
final public static function broadcast($condition){
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Condition Variable for the caller.
|
||||
*
|
||||
* @link http://www.php.net/manual/en/cond.create.php
|
||||
* @return int A handle to a Condition Variable
|
||||
*/
|
||||
final public static function create(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a condition
|
||||
*
|
||||
* Destroying Condition Variable handles must be carried out explicitly by the programmer when they are
|
||||
* finished with the Condition Variable.
|
||||
* No Threads should be blocking on a call to Cond::wait() when the call to Cond::destroy() takes place.
|
||||
*
|
||||
* @param int $condition A handle to a Condition Variable returned by a previous call to Cond::create()
|
||||
*
|
||||
* @link http://www.php.net/manual/en/cond.destroy.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
final public static function destroy($condition){
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal a Condition
|
||||
*
|
||||
* @param int $condition A handle to a Condition Variable returned by a previous call to Cond::create()
|
||||
*
|
||||
* @link http://www.php.net/manual/en/cond.signal.php
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
final public static function signal($condition){
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for a signal on a Condition Variable, optionally specifying a timeout to limit waiting time.
|
||||
*
|
||||
* @param int $condition A handle to a Condition Variable returned by a previous call to Cond::create()
|
||||
* @param int $mutex A handle returned by a previous call to Mutex::create() and owned (locked) by the caller.
|
||||
* @param int $timeout An optional timeout, in microseconds
|
||||
*
|
||||
* @return bool A boolean indication of success
|
||||
*/
|
||||
final public static function wait($condition, $mutex, $timeout = null){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pool class
|
||||
*
|
||||
* A Pool is a container for, and controller of, a number of Worker threads, the number of threads can be adjusted
|
||||
* during execution, additionally the Pool provides an easy mechanism to maintain and collect references in the
|
||||
* proper way.
|
||||
*
|
||||
* @link http://www.php.net/manual/en/class.pool.php
|
||||
*/
|
||||
class Pool{
|
||||
/**
|
||||
* The maximum number of Worker threads allowed in this Pool
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $size;
|
||||
|
||||
/**
|
||||
* The name of the Worker class for this Pool
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $class;
|
||||
|
||||
/**
|
||||
* The array of Worker threads for this Pool
|
||||
*
|
||||
* @var array|Worker[]
|
||||
*/
|
||||
protected $workers;
|
||||
|
||||
/**
|
||||
* The array of Stackables submitted to this Pool for execution
|
||||
*
|
||||
* @var array|Threaded[]
|
||||
*/
|
||||
protected $work;
|
||||
|
||||
/**
|
||||
* The constructor arguments to be passed by this Pool to new Workers upon construction
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $ctor;
|
||||
|
||||
/**
|
||||
* The numeric identifier for the last Worker used by this Pool
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $last;
|
||||
|
||||
/**
|
||||
* Construct a new Pool of Workers
|
||||
*
|
||||
* @param integer $size The maximum number of Workers this Pool can create
|
||||
* @param string $class The class for new Workers
|
||||
* @param array $ctor An array of arguments to be passed to new Workers
|
||||
*
|
||||
* @link http://www.php.net/manual/en/pool.__construct.php
|
||||
*/
|
||||
public function __construct($size, $class, array $ctor = []){
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down all Workers, and collect all Stackables, finally destroys the Pool
|
||||
*
|
||||
* @link http://www.php.net/manual/en/pool.__destruct.php
|
||||
*/
|
||||
public function __destruct(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect references to completed tasks
|
||||
*
|
||||
* Allows the Pool to collect references determined to be garbage by the given collector
|
||||
*
|
||||
* @param callable $collector
|
||||
*
|
||||
* @link http://www.php.net/manual/en/pool.collect.php
|
||||
*/
|
||||
public function collect(callable $collector){
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize the Pool
|
||||
*
|
||||
* @param integer $size The maximum number of Workers this Pool can create
|
||||
*
|
||||
* @link http://www.php.net/manual/en/pool.resize.php
|
||||
*/
|
||||
public function resize($size){
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown all Workers in this Pool
|
||||
*
|
||||
* @link http://www.php.net/manual/en/pool.shutdown.php
|
||||
*/
|
||||
public function shutdown(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the task to the next Worker in the Pool
|
||||
*
|
||||
* @param Threaded $task The task for execution
|
||||
*
|
||||
* @return int the identifier of the Worker executing the object
|
||||
*/
|
||||
public function submit(Threaded $task){
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the task to the specific Worker in the Pool
|
||||
*
|
||||
* @param int $worker The worker for execution
|
||||
* @param Threaded $task The task for execution
|
||||
*
|
||||
* @return int the identifier of the Worker that accepted the object
|
||||
*/
|
||||
public function submitTo($worker, Threaded $task){
|
||||
}
|
||||
}
|
@ -1,268 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* uopz extension stub file for code completion purposes
|
||||
*
|
||||
* WARNING: Do not include this file
|
||||
*
|
||||
* @author Shoghi Cervantes <shoghicp@gmail.com>
|
||||
* @version 1.0.0
|
||||
* @link https://github.com/krakjoe/uopz
|
||||
*/
|
||||
|
||||
/**
|
||||
* Invoked by exit() and die(), recieves no arguments. Return boolean TRUE to exit, FALSE to continue
|
||||
*/
|
||||
define('ZEND_EXIT', 79);
|
||||
|
||||
/**
|
||||
* Invoked by object construction, receives the class of object being created as the only argument
|
||||
*/
|
||||
define('ZEND_NEW', 68);
|
||||
|
||||
/**
|
||||
* Invoked by the throw construct, receives the class of exception being thrown as the only argument
|
||||
*/
|
||||
define('ZEND_THROW', 108);
|
||||
|
||||
/**
|
||||
* Determines whether the constants are inherited by the new context
|
||||
*/
|
||||
define('ZEND_FETCH_CLASS', 109);
|
||||
|
||||
/**
|
||||
* Invoked upon composure,
|
||||
* recieves the class the trait is being added to as the first argument,
|
||||
* and the name of the trait as the second argument
|
||||
*/
|
||||
define('ZEND_ADD_TRAIT', 154);
|
||||
|
||||
/**
|
||||
* Invoked upon composure,
|
||||
* recieves the class the interface is being added to as the first argument,
|
||||
* and the name of the interface as the second argument
|
||||
*/
|
||||
define('ZEND_ADD_INTERFACE', 144);
|
||||
|
||||
/**
|
||||
* Invoked by instanceof operator,
|
||||
* recieves the object being verified as the first argument,
|
||||
* and the name of the class which that object should be as the second argument
|
||||
*/
|
||||
define('ZEND_INSTANCEOF', 138);
|
||||
|
||||
|
||||
|
||||
// Modifiers
|
||||
|
||||
/**
|
||||
* Advance 1 opcode and continue
|
||||
*/
|
||||
define('ZEND_USER_OPCODE_CONTINUE', null); //??
|
||||
|
||||
/**
|
||||
* Enter into new op_array without recursion
|
||||
*/
|
||||
define('ZEND_USER_OPCODE_ENTER', null); //??
|
||||
|
||||
/**
|
||||
* Return to calling op_array within the same executor
|
||||
*/
|
||||
define('ZEND_USER_OPCODE_LEAVE', null); //??
|
||||
|
||||
/**
|
||||
* Dispatch to original opcode handler
|
||||
*/
|
||||
define('ZEND_USER_OPCODE_DISPATCH', null); //??
|
||||
|
||||
/**
|
||||
* Dispatch to a specific handler (OR'd with ZEND opcode constant)
|
||||
*/
|
||||
define('ZEND_USER_OPCODE_DISPATCH_TO', null); //??
|
||||
|
||||
/**
|
||||
* Exit from executor (return from function)
|
||||
*/
|
||||
define('ZEND_USER_OPCODE_RETURN', null); //??
|
||||
|
||||
|
||||
|
||||
//Modifiers
|
||||
|
||||
|
||||
/**
|
||||
* Mark function as public, the default
|
||||
*/
|
||||
define('ZEND_USER_ACC_PUBLIC', null); //??
|
||||
|
||||
/**
|
||||
* Mark function as protected
|
||||
*/
|
||||
define('ZEND_USER_ACC_PROTECTED', null); //??
|
||||
|
||||
/**
|
||||
* Mark function as private
|
||||
*/
|
||||
define('ZEND_USER_ACC_PRIVATE', null); //??
|
||||
|
||||
/**
|
||||
* Mark function as static
|
||||
*/
|
||||
define('ZEND_USER_ACC_STATIC', null); //??
|
||||
|
||||
/**
|
||||
* Mark function as abstract
|
||||
*/
|
||||
define('ZEND_USER_ACC_ABSTRACT', null); //??
|
||||
|
||||
/**
|
||||
* Dummy registered for consistency, the default kind of class entry
|
||||
*/
|
||||
define('ZEND_USER_ACC_CLASS', null); //??
|
||||
|
||||
/**
|
||||
* Mark class as interface
|
||||
*/
|
||||
define('ZEND_USER_ACC_INTERFACE', null); //??
|
||||
|
||||
/**
|
||||
* Mark class as trait
|
||||
*/
|
||||
define('ZEND_USER_ACC_TRAIT', null); //??
|
||||
|
||||
/**
|
||||
* Used for getting flags only
|
||||
*/
|
||||
define('ZEND_USER_ACC_FLAGS', null); //??
|
||||
|
||||
/**
|
||||
* Backup a function at runtime, to be restored on shutdown
|
||||
*
|
||||
* @param string $name Function name or class name
|
||||
* @param string $classMethod Class method, if $name is a class name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function uopz_backup($name, $classMethod = null){}
|
||||
|
||||
/**
|
||||
* Creates a new class of the given name that implements, extends, or uses all of the provided classes
|
||||
*
|
||||
* @param string $name A legal class name
|
||||
* @param array $classes An array of class, interface and trait names
|
||||
* @param array $methods An associative array of methods, values are either closures or [modifiers => closure]
|
||||
* @param array $properties An associative array of properties, keys are names, values are modifiers
|
||||
* @param int $flags Entry type, by default ZEND_ACC_CLASS
|
||||
*/
|
||||
function uopz_compose($name, array $classes, array $methods = [], array $properties = [], $flags = ZEND_USER_ACC_CLASS){}
|
||||
|
||||
/**
|
||||
* Copy a function by name
|
||||
*
|
||||
* @param string $name Function name or class name
|
||||
* @param string $classMethod Class method, if $name is a class name
|
||||
*
|
||||
* @return Closure
|
||||
*/
|
||||
function uopz_copy($name, $classMethod = null){}
|
||||
|
||||
/**
|
||||
* Deletes a function or method
|
||||
*
|
||||
* @param string $name Function name or class name
|
||||
* @param string $classMethod Class method, if $name is a class name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function uopz_delete($name, $classMethod = null){}
|
||||
|
||||
/**
|
||||
* @param string $class The name of the class to extend
|
||||
* @param string $parent The name of the class to inherit
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function uopz_extend($class, $parent){}
|
||||
|
||||
/**
|
||||
* Get or set the flags on a class or function entry at runtime
|
||||
*
|
||||
* @param string $name Function name or class name
|
||||
* @param string $classMethod (optional) Class method, if $name is a class name
|
||||
* @param int $flags A valid set of ZEND_ACC_ flags, ZEND_ACC_FETCH to read flags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function uopz_flags($name, $classMethod = null, $flags = null){}
|
||||
|
||||
/**
|
||||
* Creates a function at runtime
|
||||
*
|
||||
* @param string $name Function name or class name
|
||||
* @param string $classMethod (optional) Class method, if $name is a class name
|
||||
* @param Closure $handler The Closure for the function
|
||||
* @param int $modifiers The modifiers for the function, by default copied or ZEND_ACC_PUBLIC
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function uopz_function($name, $classMethod = null, Closure $handler, $modifiers = ZEND_USER_ACC_PUBLIC){}
|
||||
|
||||
/**
|
||||
* Makes class implement interface
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $interface
|
||||
*/
|
||||
function uopz_implement($class, $interface){}
|
||||
|
||||
/**
|
||||
* Overloads the specified VM opcode with the user defined function
|
||||
*
|
||||
* @param int $opcode A valid opcode, see constants for details of supported codes
|
||||
* @param Callable $callable
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function uopz_overload($opcode, $callable){}
|
||||
|
||||
/**
|
||||
* Redefines the given constant as value
|
||||
*
|
||||
* @param string $name Constant ot class name
|
||||
* @param string $classConstant (optional) constant to redefine if $name is a class name
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function uopz_redefine($name, $classConstant, $value){}
|
||||
|
||||
/**
|
||||
* Rename a function at runtime
|
||||
* Note: If both functions exist, this effectively swaps their names
|
||||
*
|
||||
* @param string $name Function name or class name
|
||||
* @param string $classMethod (optional) Class method, if $name is a class name
|
||||
* @param string $rename The new name for the function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function uopz_rename($name, $classMethod = null, $rename){}
|
||||
|
||||
/**
|
||||
* Restore a previously backed up function
|
||||
*
|
||||
* @param string $name Function name or class name
|
||||
* @param string $classMethod Class method, if $name is a class name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function uopz_restore($name, $classMethod = null){}
|
||||
|
||||
/**
|
||||
* Removes the constant at runtime
|
||||
*
|
||||
* @param string $name Function name or class name
|
||||
* @param string $classMethod (optional) Class method, if $name is a class name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function uopz_undefine($name, $classMethod = null){}
|
@ -1,127 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* WeakRef extension stub file for code completion purposes
|
||||
*
|
||||
* WARNING: Do not include this file
|
||||
*
|
||||
*/
|
||||
|
||||
class WeakRef{
|
||||
|
||||
/**
|
||||
* Constructs a new weak reference.
|
||||
*
|
||||
* @param object $object
|
||||
*/
|
||||
public function __construct($object = null){}
|
||||
|
||||
/**
|
||||
* Acquires a strong reference on that object,
|
||||
* virtually turning the weak reference into a strong one.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function acquire(){}
|
||||
|
||||
/**
|
||||
* Returns the object pointed to by the weak reference
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function get(){}
|
||||
|
||||
/**
|
||||
* Releases a previously acquired reference,
|
||||
* potentially turning a strong reference back into a weak reference.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function release(){}
|
||||
|
||||
/**
|
||||
* Checks whether the object referenced still exists
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid(){}
|
||||
}
|
||||
|
||||
class WeakMap implements Countable, ArrayAccess, Iterator{
|
||||
|
||||
/**
|
||||
* Constructs a new map
|
||||
*/
|
||||
public function __construct(){}
|
||||
|
||||
/**
|
||||
* Counts the number of live entries in the map
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count(){}
|
||||
|
||||
/**
|
||||
* Returns the current value being iterated on in the map.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function current(){}
|
||||
|
||||
/**
|
||||
* Returns the object serving as key in the map, at the current iterating position.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function key(){}
|
||||
|
||||
/**
|
||||
* Advances to the next map element.
|
||||
*/
|
||||
public function next(){}
|
||||
|
||||
/**
|
||||
* Checks whether the passed object is referenced in the map.
|
||||
*
|
||||
* @param object $object
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($object){}
|
||||
|
||||
/**
|
||||
* Returns the value pointed to by a certain object.
|
||||
*
|
||||
* @param object $object
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($object){}
|
||||
|
||||
/**
|
||||
* Updates the map with a new key-value pair.
|
||||
* If the key already existed in the map, the old value is replaced with the new.
|
||||
*
|
||||
* @param object $object
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function offsetSet($object, $value){}
|
||||
|
||||
/**
|
||||
* Removes an entry from the map.
|
||||
*
|
||||
* @param object $object
|
||||
*/
|
||||
public function offsetUnset($object){}
|
||||
|
||||
/**
|
||||
* Rewinds the iterator to the beginning of the map.
|
||||
*/
|
||||
public function rewind(){}
|
||||
|
||||
/**
|
||||
* Returns whether the iterator is still on a valid map element.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid(){}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* YAML extension stub file for code completion purposes
|
||||
*
|
||||
* WARNING: Do not include this file
|
||||
*
|
||||
*/
|
||||
|
||||
define("YAML_ANY_SCALAR_STYLE", 0);
|
||||
define("YAML_PLAIN_SCALAR_STYLE", 1);
|
||||
define("YAML_SINGLE_QUOTED_SCALAR_STYLE", 0);
|
||||
define("YAML_DOUBLE_QUOTED_SCALAR_STYLE", 0);
|
||||
define("YAML_LITERAL_SCALAR_STYLE", 0);
|
||||
define("YAML_FOLDED_SCALAR_STYLE", 0);
|
||||
|
||||
define("YAML_NULL_TAG", "tag:yaml.org,2002:null");
|
||||
define("YAML_BOOL_TAG", "tag:yaml.org,2002:bool");
|
||||
define("YAML_STR_TAG", "tag:yaml.org,2002:str");
|
||||
define("YAML_INT_TAG", "tag:yaml.org,2002:int");
|
||||
define("YAML_FLOAT_TAG", "tag:yaml.org,2002:float");
|
||||
define("YAML_TIMESTAMP_TAG", "tag:yaml.org,2002:timestamp");
|
||||
define("YAML_SEQ_TAG", "tag:yaml.org,2002:seq");
|
||||
define("YAML_MAP_TAG", "tag:yaml.org,2002:map");
|
||||
define("YAML_PHP_TAG", "!php/object");
|
||||
|
||||
define("YAML_ANY_ENCODING", 0);
|
||||
define("YAML_UTF8_ENCODING", 1);
|
||||
define("YAML_UTF16LE_ENCODING", 2);
|
||||
define("YAML_UTF16BE_ENCODING", 3);
|
||||
|
||||
|
||||
define("YAML_ANY_BREAK", 0);
|
||||
define("YAML_CR_BREAK", 1);
|
||||
define("YAML_LN_BREAK", 2);
|
||||
define("YAML_CRLN_BREAK", 3);
|
||||
|
||||
/**
|
||||
* Send the YAML representation of a value to a file
|
||||
*
|
||||
* @param string $filename
|
||||
* @param mixed $data
|
||||
* @param int $encoding
|
||||
* @param int $linebreak
|
||||
* @param array $callbacks
|
||||
*
|
||||
* @link http://www.php.net/manual/en/function.yaml-emit-file.php
|
||||
* @return bool
|
||||
*/
|
||||
function yaml_emit_file($filename, $data, $encoding = YAML_ANY_ENCODING, $linebreak = YAML_ANY_BREAK, array $callbacks = []){
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the YAML representation of a value
|
||||
*
|
||||
* @param mixed $data
|
||||
* @param int $encoding
|
||||
* @param int $linebreak
|
||||
* @param array $callbacks
|
||||
*
|
||||
* @link http://www.php.net/manual/en/function.yaml-emit.php
|
||||
* @return string
|
||||
*/
|
||||
function yaml_emit($data, $encoding = YAML_ANY_ENCODING, $linebreak = YAML_ANY_BREAK, array $callbacks = []){
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a YAML stream from a file
|
||||
*
|
||||
* @param string $filename
|
||||
* @param int $pos
|
||||
* @param int &$ndocs
|
||||
* @param array $callbacks
|
||||
*
|
||||
* @link http://www.php.net/manual/en/function.yaml-parse-file.php
|
||||
* @return mixed
|
||||
*/
|
||||
function yaml_parse_file($filename, $pos = 0, &$ndocs = null, array $callbacks = []){
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a YAML stream from a URL
|
||||
*
|
||||
* @param string $url
|
||||
* @param int $pos
|
||||
* @param int &$ndocs
|
||||
* @param array $callbacks
|
||||
*
|
||||
* @link http://www.php.net/manual/en/function.yaml-parse-url.php
|
||||
* @return mixed
|
||||
*/
|
||||
function yaml_parse_url($url, $pos = 0, &$ndocs = null, array $callbacks = []){
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a YAML stream
|
||||
*
|
||||
* @param string $input
|
||||
* @param int $pos
|
||||
* @param int &$ndocs
|
||||
* @param array $callbacks
|
||||
*
|
||||
* @link http://www.php.net/manual/en/function.yaml-parse.php
|
||||
* @return mixed
|
||||
*/
|
||||
function yaml_parse($input, $pos = 0, &$ndocs = null, array $callbacks = []){
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user