Reformatting, removing unused imports

This commit is contained in:
Shoghi Cervantes 2014-03-28 12:57:08 +01:00
parent fd8e5b27e5
commit 38809f7da2
49 changed files with 285 additions and 224 deletions

View File

@ -71,7 +71,6 @@ use PocketMine\Tile\Tile;
use PocketMine\Utils\Config; use PocketMine\Utils\Config;
use PocketMine\Utils\TextFormat; use PocketMine\Utils\TextFormat;
use PocketMine\Utils\Utils; use PocketMine\Utils\Utils;
use PocketMine\Command\CommandSender;
/** /**
* Main class that handles networking, recovery, and packet sending to the server part * Main class that handles networking, recovery, and packet sending to the server part

View File

@ -32,7 +32,6 @@ use PocketMine\Command\ConsoleCommandSender;
use PocketMine\Command\PluginCommand; use PocketMine\Command\PluginCommand;
use PocketMine\Command\SimpleCommandMap; use PocketMine\Command\SimpleCommandMap;
use PocketMine\Entity\Entity; use PocketMine\Entity\Entity;
use PocketMine\Event\Event;
use PocketMine\Event\HandlerList; use PocketMine\Event\HandlerList;
use PocketMine\Event\Server\PacketReceiveEvent; use PocketMine\Event\Server\PacketReceiveEvent;
use PocketMine\Event\Server\PacketSendEvent; use PocketMine\Event\Server\PacketSendEvent;
@ -454,9 +453,9 @@ class Server{
/** /**
* @param \SplClassLoader $autoloader * @param \SplClassLoader $autoloader
* @param string $filePath * @param string $filePath
* @param string $dataPath * @param string $dataPath
* @param string $pluginPath * @param string $pluginPath
*/ */
public function __construct(\SplClassLoader $autoloader, $filePath, $dataPath, $pluginPath){ public function __construct(\SplClassLoader $autoloader, $filePath, $dataPath, $pluginPath){
self::$instance = $this; self::$instance = $this;

View File

@ -21,17 +21,10 @@
namespace PocketMine; namespace PocketMine;
use PocketMine\Block\Block;
use PocketMine\Entity\Entity;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine\Network\Protocol\Info;
use PocketMine\Network\Query\QueryHandler; use PocketMine\Network\Query\QueryHandler;
use PocketMine\Network\RCON\RCON; use PocketMine\Network\RCON\RCON;
use PocketMine\Network\UPnP\UPnP; use PocketMine\Network\UPnP\UPnP;
use PocketMine\Plugin\PluginManager; use PocketMine\Plugin\PluginManager;
use PocketMine\Recipes\Crafting;
use PocketMine\Tile\Tile;
use PocketMine\Utils\Config; use PocketMine\Utils\Config;
use PocketMine\Utils\TextFormat; use PocketMine\Utils\TextFormat;
use PocketMine\Utils\Utils; use PocketMine\Utils\Utils;
@ -261,7 +254,6 @@ class ServerAPI{
} }
if($this->getProperty("send-usage", true) !== false){ if($this->getProperty("send-usage", true) !== false){
$this->server->schedule(6000, array($this, "sendUsage"), array(), true); //Send the info after 5 minutes have passed $this->server->schedule(6000, array($this, "sendUsage"), array(), true); //Send the info after 5 minutes have passed
$this->sendUsage(); $this->sendUsage();

View File

@ -89,6 +89,7 @@ class ServerOld{
if(isset(self::$instance)){ if(isset(self::$instance)){
return self::$instance; return self::$instance;
} }
return null; return null;
} }

View File

@ -509,14 +509,14 @@ abstract class Block extends Position{
/** /**
* Places the Block, using block space and block target, and side. Returns if the block has been placed. * Places the Block, using block space and block target, and side. Returns if the block has been placed.
* *
* @param Item $item * @param Item $item
* @param Block $block * @param Block $block
* @param Block $target * @param Block $target
* @param int $face * @param int $face
* @param float $fx * @param float $fx
* @param float $fy * @param float $fy
* @param float $fz * @param float $fz
* @param Player $player = null * @param Player $player = null
* *
* @return bool * @return bool
*/ */
@ -525,7 +525,7 @@ abstract class Block extends Position{
/** /**
* Do actions when activated by Item. Returns if it has done anything * Do actions when activated by Item. Returns if it has done anything
* *
* @param Item $item * @param Item $item
* @param Player $player * @param Player $player
* *
* @return bool * @return bool

View File

@ -22,7 +22,6 @@
namespace PocketMine\Block; namespace PocketMine\Block;
class Furnace extends BurningFurnace{ class Furnace extends BurningFurnace{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct($meta); parent::__construct($meta);

View File

@ -80,9 +80,9 @@ abstract class Command{
private $permissionMessage = null; private $permissionMessage = null;
/** /**
* @param string $name * @param string $name
* @param string $description * @param string $description
* @param string $usageMessage * @param string $usageMessage
* @param string[] $aliases * @param string[] $aliases
*/ */
public function __construct($name, $description = "", $usageMessage = null, array $aliases = array()){ public function __construct($name, $description = "", $usageMessage = null, array $aliases = array()){
@ -174,8 +174,10 @@ abstract class Command{
$this->nextLabel = $name; $this->nextLabel = $name;
if(!$this->isRegistered()){ if(!$this->isRegistered()){
$this->label = $name; $this->label = $name;
return true; return true;
} }
return false; return false;
} }
@ -189,8 +191,10 @@ abstract class Command{
public function register(CommandMap $commandMap){ public function register(CommandMap $commandMap){
if($this->allowChangesFrom($commandMap)){ if($this->allowChangesFrom($commandMap)){
$this->commandMap = $commandMap; $this->commandMap = $commandMap;
return true; return true;
} }
return false; return false;
} }
@ -204,8 +208,10 @@ abstract class Command{
$this->commandMap = null; $this->commandMap = null;
$this->activeAliases = $this->aliases; $this->activeAliases = $this->aliases;
$this->label = $this->nextLabel; $this->label = $this->nextLabel;
return true; return true;
} }
return false; return false;
} }
@ -292,12 +298,12 @@ abstract class Command{
* @param bool $sendToSource * @param bool $sendToSource
*/ */
public static function broadcastCommandMessage(CommandSender $source, $message, $sendToSource = true){ public static function broadcastCommandMessage(CommandSender $source, $message, $sendToSource = true){
$result = $source->getName() .": " . $message; $result = $source->getName() . ": " . $message;
//Command minecarts or command blocks are not implemented //Command minecarts or command blocks are not implemented
$users = Server::getInstance()->getPluginManager()->getPermissionSubscriptions(Player::BROADCAST_CHANNEL_ADMINISTRATIVE); $users = Server::getInstance()->getPluginManager()->getPermissionSubscriptions(Player::BROADCAST_CHANNEL_ADMINISTRATIVE);
$colored = TextFormat::GRAY . TextFormat::ITALIC . "[$result".TextFormat::GRAY . TextFormat::ITALIC."]"; $colored = TextFormat::GRAY . TextFormat::ITALIC . "[$result" . TextFormat::GRAY . TextFormat::ITALIC . "]";
if($sendToSource === true and !($source instanceof ConsoleCommandSender)){ if($sendToSource === true and !($source instanceof ConsoleCommandSender)){
$source->sendMessage($message); $source->sendMessage($message);
} }

View File

@ -25,7 +25,7 @@ namespace PocketMine\Command;
interface CommandMap{ interface CommandMap{
/** /**
* @param string $fallbackPrefix * @param string $fallbackPrefix
* @param Command[] $commands * @param Command[] $commands
*/ */
public function registerAll($fallbackPrefix, array $commands); public function registerAll($fallbackPrefix, array $commands);

View File

@ -63,10 +63,11 @@ class CommandReader extends \Thread{
*/ */
public function getLine(){ public function getLine(){
if($this->buffer->count() !== 0){ if($this->buffer->count() !== 0){
return $this->buffer->synchronized(function(){ return $this->buffer->synchronized(function (){
return $this->buffer->shift(); return $this->buffer->shift();
}); });
} }
return null; return null;
} }
@ -83,7 +84,7 @@ class CommandReader extends \Thread{
$lastLine = microtime(true); $lastLine = microtime(true);
while(true){ while(true){
if(($line = $this->readLine()) !== ""){ if(($line = $this->readLine()) !== ""){
$this->buffer->synchronized(function(\Threaded $buffer, $line){ $this->buffer->synchronized(function (\Threaded $buffer, $line){
$buffer[] = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", $line); $buffer[] = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", $line);
}, $this->buffer, $line); }, $this->buffer, $line);
$lastLine = microtime(true); $lastLine = microtime(true);

View File

@ -23,7 +23,6 @@ namespace PocketMine\Command;
use PocketMine\Permission\PermissibleBase; use PocketMine\Permission\PermissibleBase;
use PocketMine\Permission\PermissionAttachment; use PocketMine\Permission\PermissionAttachment;
use PocketMine\Player;
use PocketMine\Plugin\Plugin; use PocketMine\Plugin\Plugin;
use PocketMine\Server; use PocketMine\Server;
@ -55,7 +54,7 @@ class ConsoleCommandSender implements CommandSender{
/** /**
* @param Plugin $plugin * @param Plugin $plugin
* @param string $name * @param string $name
* @param bool $value * @param bool $value
* *
* @return \PocketMine\Permission\PermissionAttachment * @return \PocketMine\Permission\PermissionAttachment

View File

@ -21,13 +21,13 @@
namespace PocketMine\Command; namespace PocketMine\Command;
use PocketMine\Command\Defaults\HelpCommand;
use PocketMine\Command\Defaults\PluginsCommand; use PocketMine\Command\Defaults\PluginsCommand;
use PocketMine\Command\Defaults\SeedCommand;
use PocketMine\Command\Defaults\StopCommand; use PocketMine\Command\Defaults\StopCommand;
use PocketMine\Command\Defaults\TellCommand; use PocketMine\Command\Defaults\TellCommand;
use PocketMine\Command\Defaults\VanillaCommand; use PocketMine\Command\Defaults\VanillaCommand;
use PocketMine\Command\Defaults\VersionCommand; use PocketMine\Command\Defaults\VersionCommand;
use PocketMine\Command\Defaults\SeedCommand;
use PocketMine\Command\Defaults\HelpCommand;
use PocketMine\Server; use PocketMine\Server;
class SimpleCommandMap implements CommandMap{ class SimpleCommandMap implements CommandMap{
@ -140,6 +140,7 @@ class SimpleCommandMap implements CommandMap{
if(isset($this->knownCommands[$name])){ if(isset($this->knownCommands[$name])){
return $this->knownCommands[$name]; return $this->knownCommands[$name];
} }
return null; return null;
} }

View File

@ -21,11 +21,11 @@
namespace PocketMine\Command\Defaults; namespace PocketMine\Command\Defaults;
use PocketMine\Command\Command;
use PocketMine\Command\CommandSender; use PocketMine\Command\CommandSender;
use PocketMine\Utils\TextFormat;
use PocketMine\Command\ConsoleCommandSender; use PocketMine\Command\ConsoleCommandSender;
use PocketMine\Server; use PocketMine\Server;
use PocketMine\Command\Command; use PocketMine\Utils\TextFormat;
class HelpCommand extends VanillaCommand{ class HelpCommand extends VanillaCommand{
@ -77,25 +77,28 @@ class HelpCommand extends VanillaCommand{
if($pageNumber < 1){ if($pageNumber < 1){
$pageNumber = 1; $pageNumber = 1;
} }
$message = TextFormat::RED . "-" . TextFormat::RESET . " Showing help page ".$pageNumber." of ".count($commands)." (/help <pageNumber>) " . TextFormat::RED . "-" . TextFormat::RESET . "\n"; $message = TextFormat::RED . "-" . TextFormat::RESET . " Showing help page " . $pageNumber . " of " . count($commands) . " (/help <pageNumber>) " . TextFormat::RED . "-" . TextFormat::RESET . "\n";
if(isset($commands[$pageNumber - 1])){ if(isset($commands[$pageNumber - 1])){
foreach($commands[$pageNumber - 1] as $command){ foreach($commands[$pageNumber - 1] as $command){
$message .= TextFormat::DARK_GREEN . "/" . $command->getName().": ". TextFormat::WHITE. $command->getDescription()."\n"; $message .= TextFormat::DARK_GREEN . "/" . $command->getName() . ": " . TextFormat::WHITE . $command->getDescription() . "\n";
} }
} }
$sender->sendMessage($message); $sender->sendMessage($message);
return true; return true;
}else{ }else{
if(($command = Server::getInstance()->getCommandMap()->getCommand(strtolower($command))) instanceof Command){ if(($command = Server::getInstance()->getCommandMap()->getCommand(strtolower($command))) instanceof Command){
if($command->testPermissionSilent($sender)){ if($command->testPermissionSilent($sender)){
$message = TextFormat::YELLOW . "--------- ". TextFormat::WHITE . " Help: /" .$command->getName() . TextFormat::YELLOW . " ---------\n"; $message = TextFormat::YELLOW . "--------- " . TextFormat::WHITE . " Help: /" . $command->getName() . TextFormat::YELLOW . " ---------\n";
$message .= TextFormat::DARK_GREEN . "Description: " . TextFormat::WHITE . $command->getDescription() . "\n"; $message .= TextFormat::DARK_GREEN . "Description: " . TextFormat::WHITE . $command->getDescription() . "\n";
$message .= TextFormat::DARK_GREEN . "Usage: " . TextFormat::WHITE . implode("\n".TextFormat::WHITE, explode("\n", $command->getUsage())) . "\n"; $message .= TextFormat::DARK_GREEN . "Usage: " . TextFormat::WHITE . implode("\n" . TextFormat::WHITE, explode("\n", $command->getUsage())) . "\n";
$sender->sendMessage($message); $sender->sendMessage($message);
return true; return true;
} }
} }
$sender->sendMessage(TextFormat::RED . "No help for ".strtolower($command)); $sender->sendMessage(TextFormat::RED . "No help for " . strtolower($command));
return true; return true;
} }
} }

View File

@ -22,9 +22,8 @@
namespace PocketMine\Command\Defaults; namespace PocketMine\Command\Defaults;
use PocketMine\Command\CommandSender; use PocketMine\Command\CommandSender;
use PocketMine\Utils\TextFormat;
use PocketMine\Player;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Player;
class SeedCommand extends VanillaCommand{ class SeedCommand extends VanillaCommand{

View File

@ -23,8 +23,8 @@ namespace PocketMine\Command\Defaults;
use PocketMine\Command\Command; use PocketMine\Command\Command;
use PocketMine\Command\CommandSender; use PocketMine\Command\CommandSender;
use PocketMine\Server;
use PocketMine\Player; use PocketMine\Player;
use PocketMine\Server;
class StopCommand extends VanillaCommand{ class StopCommand extends VanillaCommand{

View File

@ -22,9 +22,8 @@
namespace PocketMine\Command\Defaults; namespace PocketMine\Command\Defaults;
use PocketMine\Command\CommandSender; use PocketMine\Command\CommandSender;
use PocketMine\Utils\TextFormat;
use PocketMine\Player; use PocketMine\Player;
use PocketMine\Level\Level; use PocketMine\Utils\TextFormat;
class TellCommand extends VanillaCommand{ class TellCommand extends VanillaCommand{
@ -44,7 +43,8 @@ class TellCommand extends VanillaCommand{
} }
if(count($args) < 2){ if(count($args) < 2){
$sender->sendMessage(TextFormat::RED . "Usage: ".$this->usageMessage); $sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage);
return false; return false;
} }
@ -53,8 +53,8 @@ class TellCommand extends VanillaCommand{
$player = Player::get($name, true, false); $player = Player::get($name, true, false);
if($player instanceof Player){ if($player instanceof Player){
$sender->sendMessage("[me -> ".$player->getName()."] ".implode($args)); $sender->sendMessage("[me -> " . $player->getName() . "] " . implode($args));
$player->sendMessage("[".$sender->getName()." -> me] ".implode($args)); $player->sendMessage("[" . $sender->getName() . " -> me] " . implode($args));
}else{ }else{
$sender->sendMessage("There's no player by that name online."); $sender->sendMessage("There's no player by that name online.");
} }

View File

@ -48,8 +48,10 @@ abstract class VanillaCommand extends Command{
protected function getRelativeDouble($original, CommandSender $sender, $input){ protected function getRelativeDouble($original, CommandSender $sender, $input){
if($input{0} === "~"){ if($input{0} === "~"){
$value = $this->getDouble($sender, substr($input, 1)); $value = $this->getDouble($sender, substr($input, 1));
return $original + $value; return $original + $value;
} }
return $this->getDouble($input); return $this->getDouble($input);
} }

View File

@ -56,6 +56,7 @@ class VersionCommand extends VanillaCommand{
if($exactPlugin instanceof Plugin){ if($exactPlugin instanceof Plugin){
$this->describeToSender($exactPlugin, $sender); $this->describeToSender($exactPlugin, $sender);
return true; return true;
} }

View File

@ -29,17 +29,16 @@ use PocketMine\Event\Entity\EntityLevelChangeEvent;
use PocketMine\Event\Entity\EntityMotionEvent; use PocketMine\Event\Entity\EntityMotionEvent;
use PocketMine\Event\Entity\EntityMoveEvent; use PocketMine\Event\Entity\EntityMoveEvent;
use PocketMine\Event\Entity\EntitySpawnEvent; use PocketMine\Event\Entity\EntitySpawnEvent;
use PocketMine\Event\Event;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Level\Position; use PocketMine\Level\Position;
use PocketMine\Math\AxisAlignedBB; use PocketMine\Math\AxisAlignedBB;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Compound;
use PocketMine\Network;
use PocketMine\Network\Protocol\MoveEntityPacket_PosRot; use PocketMine\Network\Protocol\MoveEntityPacket_PosRot;
use PocketMine\Network\Protocol\MovePlayerPacket; use PocketMine\Network\Protocol\MovePlayerPacket;
use PocketMine\Network\Protocol\RemoveEntityPacket; use PocketMine\Network\Protocol\RemoveEntityPacket;
use PocketMine\Network\Protocol\SetEntityMotionPacket; use PocketMine\Network\Protocol\SetEntityMotionPacket;
use PocketMine\Network;
use PocketMine\Player; use PocketMine\Player;
use PocketMine\PMF\LevelFormat; use PocketMine\PMF\LevelFormat;
use PocketMine\Server; use PocketMine\Server;

View File

@ -23,19 +23,18 @@ namespace PocketMine\Entity;
use PocketMine\Event\Entity\EntityArmorChangeEvent; use PocketMine\Event\Entity\EntityArmorChangeEvent;
use PocketMine\Event\Entity\EntityInventoryChangeEvent; use PocketMine\Event\Entity\EntityInventoryChangeEvent;
use PocketMine\Event\Event;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\NBT\NBT; use PocketMine\NBT\NBT;
use PocketMine\NBT\Tag\Byte; use PocketMine\NBT\Tag\Byte;
use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Compound;
use PocketMine\NBT\Tag\Enum; use PocketMine\NBT\Tag\Enum;
use PocketMine\NBT\Tag\Short; use PocketMine\NBT\Tag\Short;
use PocketMine\Network;
use PocketMine\Network\Protocol\AddPlayerPacket; use PocketMine\Network\Protocol\AddPlayerPacket;
use PocketMine\Network\Protocol\ContainerSetContentPacket; use PocketMine\Network\Protocol\ContainerSetContentPacket;
use PocketMine\Network\Protocol\PlayerEquipmentPacket; use PocketMine\Network\Protocol\PlayerEquipmentPacket;
use PocketMine\Network\Protocol\RemovePlayerPacket; use PocketMine\Network\Protocol\RemovePlayerPacket;
use PocketMine\Network\Protocol\SetEntityMotionPacket; use PocketMine\Network\Protocol\SetEntityMotionPacket;
use PocketMine\Network;
use PocketMine\Player; use PocketMine\Player;
use PocketMine\Server; use PocketMine\Server;

View File

@ -67,6 +67,7 @@ abstract class Event{
if(static::$handlerList === null){ if(static::$handlerList === null){
static::$handlerList = new HandlerList(); static::$handlerList = new HandlerList();
} }
return static::$handlerList; return static::$handlerList;
} }

View File

@ -85,7 +85,8 @@ class HandlerList{
return; return;
} }
if(isset($this->handlerSlots[$listener->getPriority()][spl_object_hash($listener)])){ if(isset($this->handlerSlots[$listener->getPriority()][spl_object_hash($listener)])){
trigger_error("This listener is already registered to priority ".$listener->getPriority(), E_USER_WARNING); trigger_error("This listener is already registered to priority " . $listener->getPriority(), E_USER_WARNING);
return; return;
} }
$this->handlers = null; $this->handlers = null;
@ -110,7 +111,8 @@ class HandlerList{
foreach($this->handlerSlots as $priority => $list){ foreach($this->handlerSlots as $priority => $list){
foreach($list as $hash => $listener){ foreach($list as $hash => $listener){
if(($object instanceof Plugin and $listener->getPlugin() === $object) if(($object instanceof Plugin and $listener->getPlugin() === $object)
or ($object instanceof Listener and $listener->getListener() === $object)){ or ($object instanceof Listener and $listener->getListener() === $object)
){
unset($this->handlerSlots[$priority][$hash]); unset($this->handlerSlots[$priority][$hash]);
$changed = true; $changed = true;
} }
@ -153,11 +155,13 @@ class HandlerList{
$listeners[$hash] = $plugin; $listeners[$hash] = $plugin;
} }
} }
return $listeners; return $listeners;
}else{ }else{
while(($handlers = $this->handlers) === null){ while(($handlers = $this->handlers) === null){
$this->bake(); $this->bake();
} }
return $handlers; return $handlers;
} }
} }

View File

@ -21,8 +21,8 @@
namespace PocketMine\Event\Player; namespace PocketMine\Event\Player;
use PocketMine\Event;
use PocketMine\Event\Cancellable; use PocketMine\Event\Cancellable;
use PocketMine\Event;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Player; use PocketMine\Player;

View File

@ -21,8 +21,8 @@
namespace PocketMine\Event\Server; namespace PocketMine\Event\Server;
use PocketMine\Event\Cancellable;
use PocketMine\Event; use PocketMine\Event;
use PocketMine\Event\Cancellable;
use PocketMine\Network\Protocol\DataPacket; use PocketMine\Network\Protocol\DataPacket;
use PocketMine\Player; use PocketMine\Player;

View File

@ -21,8 +21,8 @@
namespace PocketMine\Event\Server; namespace PocketMine\Event\Server;
use PocketMine\Event\Cancellable;
use PocketMine\Event; use PocketMine\Event;
use PocketMine\Event\Cancellable;
use PocketMine\Network\Protocol\DataPacket; use PocketMine\Network\Protocol\DataPacket;
use PocketMine\Player; use PocketMine\Player;

View File

@ -21,8 +21,8 @@
namespace PocketMine\Event\Tile; namespace PocketMine\Event\Tile;
use PocketMine\Event\Cancellable;
use PocketMine\Event; use PocketMine\Event;
use PocketMine\Event\Cancellable;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Tile\Tile; use PocketMine\Tile\Tile;

View File

@ -25,7 +25,6 @@ use PocketMine\Block\Block;
use PocketMine\Block\TNT; use PocketMine\Block\TNT;
use PocketMine\Entity\Entity; use PocketMine\Entity\Entity;
use PocketMine\Event\Entity\EntityExplodeEvent; use PocketMine\Event\Entity\EntityExplodeEvent;
use PocketMine\Event\Event;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Network\Protocol\ExplodePacket; use PocketMine\Network\Protocol\ExplodePacket;

View File

@ -26,9 +26,9 @@ namespace PocketMine\Level;
use PocketMine\Block\Air; use PocketMine\Block\Air;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine\Entity\Entity;
use PocketMine\Event\Block\BlockBreakEvent; use PocketMine\Event\Block\BlockBreakEvent;
use PocketMine\Event\Block\BlockPlaceEvent; use PocketMine\Event\Block\BlockPlaceEvent;
use PocketMine\Event\Event;
use PocketMine\Event\Player\PlayerInteractEvent; use PocketMine\Event\Player\PlayerInteractEvent;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Generator\Flat; use PocketMine\Level\Generator\Flat;
@ -51,7 +51,6 @@ use PocketMine\Tile\Chest;
use PocketMine\Tile\Furnace; use PocketMine\Tile\Furnace;
use PocketMine\Tile\Sign; use PocketMine\Tile\Sign;
use PocketMine\Tile\Tile; use PocketMine\Tile\Tile;
use PocketMine\Entity\Entity;
use PocketMine\Utils\Cache; use PocketMine\Utils\Cache;
use PocketMine\Utils\Config; use PocketMine\Utils\Config;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
@ -124,6 +123,7 @@ class Level{
$default = Server::getInstance()->getConfigString("level-name", null); $default = Server::getInstance()->getConfigString("level-name", null);
if($default == ""){ if($default == ""){
trigger_error("level-name cannot be null", E_USER_ERROR); trigger_error("level-name cannot be null", E_USER_ERROR);
return; return;
} }
if(self::loadLevel($default) === false){ if(self::loadLevel($default) === false){

View File

@ -25,7 +25,6 @@
namespace PocketMine\Level\Generator\Noise; namespace PocketMine\Level\Generator\Noise;
abstract class Generator{ abstract class Generator{
protected $perm = array(); protected $perm = array();
protected $offsetX = 0; protected $offsetX = 0;

View File

@ -122,7 +122,7 @@ class ThreadedHandler extends \Thread{
@socket_set_option($this->socket, SOL_SOCKET, SO_SNDBUF, 1024 * 1024 * 2); //2MB @socket_set_option($this->socket, SOL_SOCKET, SO_SNDBUF, 1024 * 1024 * 2); //2MB
@socket_set_option($this->socket, SOL_SOCKET, SO_RCVBUF, 1024 * 1024); //1MB @socket_set_option($this->socket, SOL_SOCKET, SO_RCVBUF, 1024 * 1024); //1MB
}else{ }else{
console("[SEVERE] **** FAILED TO BIND TO ".$this->serverip.":" . $this->port."!", true, true, 0); console("[SEVERE] **** FAILED TO BIND TO " . $this->serverip . ":" . $this->port . "!", true, true, 0);
console("[SEVERE] Perhaps a server is already running on that port?", true, true, 0); console("[SEVERE] Perhaps a server is already running on that port?", true, true, 0);
exit(1); exit(1);
} }
@ -142,7 +142,7 @@ class ThreadedHandler extends \Thread{
} }
private function putPacket(){ private function putPacket(){
if(($packet = $this->queue->synchronized(function(){ if(($packet = $this->queue->synchronized(function (){
return $this->queue->shift(); return $this->queue->shift();
})) instanceof Packet })) instanceof Packet
){ ){

View File

@ -25,7 +25,6 @@
namespace PocketMine\Network\Protocol; namespace PocketMine\Network\Protocol;
abstract class Info{ abstract class Info{
/** /**

View File

@ -35,9 +35,11 @@ abstract class DefaultPermissions{
public static function registerPermission(Permission $perm, Permission $parent = null){ public static function registerPermission(Permission $perm, Permission $parent = null){
if($parent instanceof Permission){ if($parent instanceof Permission){
$parent->getChildren()[$perm->getName()] = true; $parent->getChildren()[$perm->getName()] = true;
return self::registerPermission($perm); return self::registerPermission($perm);
} }
Server::getInstance()->getPluginManager()->addPermission($perm); Server::getInstance()->getPluginManager()->addPermission($perm);
return Server::getInstance()->getPluginManager()->getPermission($perm->getName()); return Server::getInstance()->getPluginManager()->getPermission($perm->getName());
} }

View File

@ -21,8 +21,8 @@
namespace PocketMine\Permission; namespace PocketMine\Permission;
use PocketMine\Server;
use PocketMine\Plugin\Plugin; use PocketMine\Plugin\Plugin;
use PocketMine\Server;
class PermissibleBase implements Permissible{ class PermissibleBase implements Permissible{
/** /**
@ -74,6 +74,7 @@ class PermissibleBase implements Permissible{
public function setOp($value){ public function setOp($value){
if($this->opable === null){ if($this->opable === null){
trigger_error("Cannot change ip value as no ServerOperator is set", E_USER_WARNING); trigger_error("Cannot change ip value as no ServerOperator is set", E_USER_WARNING);
return; return;
}else{ }else{
$this->opable->setOp($value); $this->opable->setOp($value);
@ -105,6 +106,7 @@ class PermissibleBase implements Permissible{
if(($perm = Server::getInstance()->getPluginManager()->getPermission($name)) !== null){ if(($perm = Server::getInstance()->getPluginManager()->getPermission($name)) !== null){
$perm = $perm->getDefault(); $perm = $perm->getDefault();
return $perm === Permission::DEFAULT_TRUE or ($this->isOp() and $perm === Permission::DEFAULT_OP) or (!$this->isOp() and $perm === Permission::DEFAULT_NOT_OP); return $perm === Permission::DEFAULT_TRUE or ($this->isOp() and $perm === Permission::DEFAULT_OP) or (!$this->isOp() and $perm === Permission::DEFAULT_NOT_OP);
}else{ }else{
return Permission::$DEFAULT_PERMISSION === Permission::DEFAULT_TRUE or ($this->isOp() and Permission::$DEFAULT_PERMISSION === Permission::DEFAULT_OP) or (!$this->isOp() and Permission::$DEFAULT_PERMISSION === Permission::DEFAULT_NOT_OP); return Permission::$DEFAULT_PERMISSION === Permission::DEFAULT_TRUE or ($this->isOp() and Permission::$DEFAULT_PERMISSION === Permission::DEFAULT_OP) or (!$this->isOp() and Permission::$DEFAULT_PERMISSION === Permission::DEFAULT_NOT_OP);
@ -116,7 +118,7 @@ class PermissibleBase implements Permissible{
* //TODO: tick scheduled attachments * //TODO: tick scheduled attachments
* *
* @param Plugin $plugin * @param Plugin $plugin
* @param string $name * @param string $name
* @param bool $value * @param bool $value
* *
* @return PermissionAttachment * @return PermissionAttachment
@ -124,9 +126,11 @@ class PermissibleBase implements Permissible{
public function addAttachment(Plugin $plugin, $name = null, $value = null){ public function addAttachment(Plugin $plugin, $name = null, $value = null){
if($plugin === null){ if($plugin === null){
trigger_error("Plugin cannot be null", E_USER_WARNING); trigger_error("Plugin cannot be null", E_USER_WARNING);
return null; return null;
}elseif(!$plugin->isEnabled()){ }elseif(!$plugin->isEnabled()){
trigger_error("Plugin ".$plugin->getDescription()->getName()." is disabled", E_USER_WARNING); trigger_error("Plugin " . $plugin->getDescription()->getName() . " is disabled", E_USER_WARNING);
return null; return null;
} }
@ -149,6 +153,7 @@ class PermissibleBase implements Permissible{
public function removeAttachment(PermissionAttachment $attachment){ public function removeAttachment(PermissionAttachment $attachment){
if($attachment === null){ if($attachment === null){
trigger_error("Attachment cannot be null", E_USER_WARNING); trigger_error("Attachment cannot be null", E_USER_WARNING);
return; return;
} }

View File

@ -86,9 +86,9 @@ class Permission{
/** /**
* Creates a new Permission object to be attached to Permissible objects * Creates a new Permission object to be attached to Permissible objects
* *
* @param string $name * @param string $name
* @param string $description * @param string $description
* @param string $defaultValue * @param string $defaultValue
* @param Permission[] $children * @param Permission[] $children
*/ */
public function __construct($name, $description = null, $defaultValue = null, array $children = array()){ public function __construct($name, $description = null, $defaultValue = null, array $children = array()){
@ -165,7 +165,7 @@ class Permission{
/** /**
* @param string|Permission $name * @param string|Permission $name
* @param $value * @param $value
* *
* @return Permission|void * @return Permission|void
*/ */
@ -181,6 +181,7 @@ class Permission{
} }
$this->addParent($perm, $value); $this->addParent($perm, $value);
return $perm; return $perm;
} }
} }

View File

@ -50,7 +50,8 @@ class PermissionAttachment{
*/ */
public function __construct(Plugin $plugin, Permissible $permissible){ public function __construct(Plugin $plugin, Permissible $permissible){
if(!$plugin->isEnabled()){ if(!$plugin->isEnabled()){
trigger_error("Plugin ".$plugin->getDescription()->getName()." is disabled", E_USER_WARNING); trigger_error("Plugin " . $plugin->getDescription()->getName() . " is disabled", E_USER_WARNING);
return; return;
} }
@ -95,7 +96,7 @@ class PermissionAttachment{
/** /**
* @param string|Permission $name * @param string|Permission $name
* @param bool $value * @param bool $value
*/ */
public function setPermission($name, $value){ public function setPermission($name, $value){
$this->permissions[$name instanceof Permission ? $name->getName() : $name] = $value; $this->permissions[$name instanceof Permission ? $name->getName() : $name] = $value;

View File

@ -52,6 +52,7 @@ class PermissionAttachmentInfo{
public function __construct(Permissible $permissible, $permission, $attachment, $value){ public function __construct(Permissible $permissible, $permission, $attachment, $value){
if($permission === null){ if($permission === null){
trigger_error("Permission may not be null", E_USER_WARNING); trigger_error("Permission may not be null", E_USER_WARNING);
return; return;
} }

View File

@ -55,12 +55,12 @@ class FolderPluginLoader implements PluginLoader{
console("[INFO] Loading " . $description->getName()); console("[INFO] Loading " . $description->getName());
$dataFolder = basename($file) . "/" . $description->getName(); $dataFolder = basename($file) . "/" . $description->getName();
if(file_exists($dataFolder) and !is_dir($dataFolder)){ if(file_exists($dataFolder) and !is_dir($dataFolder)){
trigger_error("Projected dataFolder '".$dataFolder."' for ".$description->getName()." exists and is not a directory", E_USER_WARNING); trigger_error("Projected dataFolder '" . $dataFolder . "' for " . $description->getName() . " exists and is not a directory", E_USER_WARNING);
return null; return null;
} }
$className = $description->getMain(); $className = $description->getMain();
$this->server->getLoader()->add(substr($className, 0, strpos($className, "\\")), array( $this->server->getLoader()->add(substr($className, 0, strpos($className, "\\")), array(
$file . "/src" $file . "/src"
@ -69,13 +69,16 @@ class FolderPluginLoader implements PluginLoader{
if(class_exists($className, true)){ if(class_exists($className, true)){
$plugin = new $className(); $plugin = new $className();
$this->initPlugin($plugin, $description, $dataFolder, $file); $this->initPlugin($plugin, $description, $dataFolder, $file);
return $plugin; return $plugin;
}else{ }else{
trigger_error("Couldn't load plugin ".$description->getName().": main class not found", E_USER_WARNING); trigger_error("Couldn't load plugin " . $description->getName() . ": main class not found", E_USER_WARNING);
return null; return null;
} }
} }
} }
return null; return null;
} }
@ -93,6 +96,7 @@ class FolderPluginLoader implements PluginLoader{
return new PluginDescription($yaml); return new PluginDescription($yaml);
} }
} }
return null; return null;
} }
@ -121,7 +125,7 @@ class FolderPluginLoader implements PluginLoader{
*/ */
public function enablePlugin(Plugin $plugin){ public function enablePlugin(Plugin $plugin){
if($plugin instanceof PluginBase and !$plugin->isEnabled()){ if($plugin instanceof PluginBase and !$plugin->isEnabled()){
console("[INFO] Enabling ".$plugin->getDescription()->getName()); console("[INFO] Enabling " . $plugin->getDescription()->getName());
$plugin->setEnabled(true); $plugin->setEnabled(true);
@ -134,7 +138,7 @@ class FolderPluginLoader implements PluginLoader{
*/ */
public function disablePlugin(Plugin $plugin){ public function disablePlugin(Plugin $plugin){
if($plugin instanceof PluginBase and $plugin->isEnabled()){ if($plugin instanceof PluginBase and $plugin->isEnabled()){
console("[INFO] Disabling ".$plugin->getDescription()->getName()); console("[INFO] Disabling " . $plugin->getDescription()->getName());
Server::getInstance()->getPluginManager()->callEvent(new PluginDisableEvent($plugin)); Server::getInstance()->getPluginManager()->callEvent(new PluginDisableEvent($plugin));

View File

@ -20,7 +20,6 @@
*/ */
namespace PocketMine\Plugin; namespace PocketMine\Plugin;
use PocketMine\Event\Listener;
/** /**
* Handles different types of plugins * Handles different types of plugins

View File

@ -22,14 +22,13 @@
namespace PocketMine\Plugin; namespace PocketMine\Plugin;
use PocketMine\Command\PluginCommand; use PocketMine\Command\PluginCommand;
use PocketMine\Event\Cancellable; use PocketMine\Command\SimpleCommandMap;
use PocketMine\Event\Event; use PocketMine\Event\Event;
use PocketMine\Event\HandlerList;
use PocketMine\Event\Listener; use PocketMine\Event\Listener;
use PocketMine\Permission\Permissible; use PocketMine\Permission\Permissible;
use PocketMine\Permission\Permission; use PocketMine\Permission\Permission;
use PocketMine\Server; use PocketMine\Server;
use PocketMine\Command\SimpleCommandMap;
use PocketMine\Event\HandlerList;
/** /**
* Manages all the plugins, Permissions and Permissibles * Manages all the plugins, Permissions and Permissibles
@ -156,6 +155,7 @@ class PluginManager{
if($description instanceof PluginDescription){ if($description instanceof PluginDescription){
if(($plugin = $loader->loadPlugin($path)) instanceof Plugin){ if(($plugin = $loader->loadPlugin($path)) instanceof Plugin){
$this->plugins[$plugin->getDescription()->getName()] = $plugin; $this->plugins[$plugin->getDescription()->getName()] = $plugin;
return $plugin; return $plugin;
} }
} }
@ -519,7 +519,7 @@ class PluginManager{
foreach($plugin->getDescription()->getCommands() as $key => $data){ foreach($plugin->getDescription()->getCommands() as $key => $data){
if(strpos($key, ":") !== false){ if(strpos($key, ":") !== false){
console("[SEVERE] Could not load command ".$key." for plugin ".$plugin->getDescription()->getName()); console("[SEVERE] Could not load command " . $key . " for plugin " . $plugin->getDescription()->getName());
continue; continue;
} }
if(is_array($data)){ if(is_array($data)){
@ -536,7 +536,7 @@ class PluginManager{
$aliasList = array(); $aliasList = array();
foreach($data["aliases"] as $alias){ foreach($data["aliases"] as $alias){
if(strpos($alias, ":") !== false){ if(strpos($alias, ":") !== false){
console("[SEVERE] Could not load alias ".$alias." for plugin ".$plugin->getDescription()->getName()); console("[SEVERE] Could not load alias " . $alias . " for plugin " . $plugin->getDescription()->getName());
continue; continue;
} }
$aliasList[] = $alias; $aliasList[] = $alias;
@ -555,6 +555,7 @@ class PluginManager{
$pluginCmds[] = $newCmd; $pluginCmds[] = $newCmd;
} }
return $pluginCmds; return $pluginCmds;
} }
} }
@ -616,11 +617,13 @@ class PluginManager{
*/ */
public function registerEvent($event, Listener $listener, $priority, EventExecutor $executor, Plugin $plugin, $ignoreCancelled = false){ public function registerEvent($event, Listener $listener, $priority, EventExecutor $executor, Plugin $plugin, $ignoreCancelled = false){
if(!is_subclass_of($event, "PocketMine\\Event\\Event")){ if(!is_subclass_of($event, "PocketMine\\Event\\Event")){
trigger_error($event ." is not a valid Event", E_USER_WARNING); trigger_error($event . " is not a valid Event", E_USER_WARNING);
return; return;
} }
if(!$plugin->isEnabled()){ if(!$plugin->isEnabled()){
trigger_error("Plugin attempted to register ".$event." while not enabled"); trigger_error("Plugin attempted to register " . $event . " while not enabled");
return; return;
} }
@ -636,6 +639,7 @@ class PluginManager{
if($event::$handlerList === null){ if($event::$handlerList === null){
$event::$handlerList = new HandlerList(); $event::$handlerList = new HandlerList();
} }
return $event::$handlerList; return $event::$handlerList;
} }

View File

@ -25,7 +25,6 @@
namespace PocketMine\Recipes; namespace PocketMine\Recipes;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Server;
abstract class Crafting{ abstract class Crafting{

View File

@ -133,6 +133,7 @@ class ServerScheduler{
private function addTask(Task $task, $delay, $period){ private function addTask(Task $task, $delay, $period){
if($task instanceof PluginTask and !$task->getOwner()->isEnabled()){ if($task instanceof PluginTask and !$task->getOwner()->isEnabled()){
trigger_error("Plugin attempted to register a task while disabled", E_USER_WARNING); trigger_error("Plugin attempted to register a task while disabled", E_USER_WARNING);
return null; return null;
} }

View File

@ -42,6 +42,7 @@ abstract class Task{
if($this->taskHandler !== null){ if($this->taskHandler !== null){
return $this->taskHandler->getTaskId(); return $this->taskHandler->getTaskId();
} }
return -1; return -1;
} }

View File

@ -40,9 +40,10 @@ class TickScheduler extends \Thread{
* @return bool * @return bool
*/ */
public function hasTick(){ public function hasTick(){
return $this->synchronized(function(){ return $this->synchronized(function (){
$hasTick = $this->hasTick; $hasTick = $this->hasTick;
$this->hasTick = false; $this->hasTick = false;
return $hasTick === true; return $hasTick === true;
}); });
} }
@ -55,7 +56,7 @@ class TickScheduler extends \Thread{
* @return float * @return float
*/ */
public function getTPS(){ public function getTPS(){
return $this->synchronized(function(){ return $this->synchronized(function (){
return round(($this->sleepTime / $this->tickMeasure) * $this->ticksPerSecond, 2); return round(($this->sleepTime / $this->tickMeasure) * $this->ticksPerSecond, 2);
}); });
} }
@ -64,7 +65,7 @@ class TickScheduler extends \Thread{
$tickTime = microtime(true); $tickTime = microtime(true);
$this->hasTick = true; $this->hasTick = true;
while(true){ while(true){
$this->synchronized(function(){ $this->synchronized(function (){
$this->hasTick = true; $this->hasTick = true;
$this->wait(); $this->wait();
$this->hasTick = false; $this->hasTick = false;

View File

@ -21,7 +21,6 @@
namespace PocketMine\Tile; namespace PocketMine\Tile;
use PocketMine\Event\Event;
use PocketMine\Event\Tile\TileInventoryChangeEvent; use PocketMine\Event\Tile\TileInventoryChangeEvent;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\NBT\Tag\Byte; use PocketMine\NBT\Tag\Byte;

View File

@ -707,6 +707,7 @@ class Utils{
if($unpacked > 2147483647){ if($unpacked > 2147483647){
$unpacked -= 4294967296; $unpacked -= 4294967296;
} }
return (int) $unpacked; return (int) $unpacked;
} }
@ -719,6 +720,7 @@ class Utils{
if($unpacked >= 2147483648){ if($unpacked >= 2147483648){
$unpacked -= 4294967296; $unpacked -= 4294967296;
} }
return (int) $unpacked; return (int) $unpacked;
} }

View File

@ -5,8 +5,7 @@
* *
* @author Guilherme Blanco <guilhermeblanco@php.net> * @author Guilherme Blanco <guilhermeblanco@php.net>
*/ */
interface SplAutoloader interface SplAutoloader{
{
/** /**
* Defines autoloader to work silently if resource is not found. * Defines autoloader to work silently if resource is not found.
* *
@ -39,7 +38,7 @@ interface SplAutoloader
* Add a new resource lookup path. * Add a new resource lookup path.
* *
* @param string $resourceName Resource name, namespace or prefix. * @param string $resourceName Resource name, namespace or prefix.
* @param mixed $resourcePath Resource single path or multiple paths (array). * @param mixed $resourcePath Resource single path or multiple paths (array).
*/ */
public function add($resourceName, $resourcePath = null); public function add($resourceName, $resourcePath = null);

View File

@ -42,8 +42,7 @@ require_once("SplAutoLoader.php");
* @author Kris Wallsmith <kris.wallsmith@gmail.com> * @author Kris Wallsmith <kris.wallsmith@gmail.com>
* @author Fabien Potencier <fabien.potencier@symfony-project.org> * @author Fabien Potencier <fabien.potencier@symfony-project.org>
*/ */
class SplClassLoader implements SplAutoloader class SplClassLoader implements SplAutoloader{
{
/** /**
* @var string * @var string
*/ */
@ -67,9 +66,8 @@ class SplClassLoader implements SplAutoloader
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setMode($mode) public function setMode($mode){
{ if($mode & self::MODE_SILENT && $mode & self::MODE_NORMAL){
if ($mode & self::MODE_SILENT && $mode & self::MODE_NORMAL) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf('Cannot have %s working normally and silently at the same time!', __CLASS__) sprintf('Cannot have %s working normally and silently at the same time!', __CLASS__)
); );
@ -83,8 +81,7 @@ class SplClassLoader implements SplAutoloader
* *
* @param string $fileExtension * @param string $fileExtension
*/ */
public function setFileExtension($fileExtension) public function setFileExtension($fileExtension){
{
$this->fileExtension = $fileExtension; $this->fileExtension = $fileExtension;
} }
@ -93,8 +90,7 @@ class SplClassLoader implements SplAutoloader
* *
* @return string * @return string
*/ */
public function getFileExtension() public function getFileExtension(){
{
return $this->fileExtension; return $this->fileExtension;
} }
@ -103,8 +99,7 @@ class SplClassLoader implements SplAutoloader
* *
* @param boolean $includePathLookup * @param boolean $includePathLookup
*/ */
public function setIncludePathLookup($includePathLookup) public function setIncludePathLookup($includePathLookup){
{
$this->includePathLookup = $includePathLookup; $this->includePathLookup = $includePathLookup;
} }
@ -113,45 +108,40 @@ class SplClassLoader implements SplAutoloader
* *
* @return boolean * @return boolean
*/ */
public function getIncludePathLookup() public function getIncludePathLookup(){
{
return $this->includePathLookup; return $this->includePathLookup;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function register($prepend = false) public function register($prepend = false){
{
spl_autoload_register(array($this, 'load'), true, $prepend); spl_autoload_register(array($this, 'load'), true, $prepend);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function unregister() public function unregister(){
{
spl_autoload_unregister(array($this, 'load')); spl_autoload_unregister(array($this, 'load'));
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function add($resource, $resourcePath = null) public function add($resource, $resourcePath = null){
{
$this->resources[$resource] = (array) $resourcePath; $this->resources[$resource] = (array) $resourcePath;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function load($resourceName) public function load($resourceName){
{
$resourceAbsolutePath = $this->getResourceAbsolutePath($resourceName); $resourceAbsolutePath = $this->getResourceAbsolutePath($resourceName);
switch (true) { switch(true){
case ($this->mode & self::MODE_SILENT): case ($this->mode & self::MODE_SILENT):
if ($resourceAbsolutePath !== false) { if($resourceAbsolutePath !== false){
require $resourceAbsolutePath; require $resourceAbsolutePath;
} }
break; break;
@ -162,7 +152,7 @@ class SplClassLoader implements SplAutoloader
break; break;
} }
if ($this->mode & self::MODE_DEBUG && ! $this->isResourceDeclared($resourceName)) { if($this->mode & self::MODE_DEBUG && !$this->isResourceDeclared($resourceName)){
throw new \RuntimeException( throw new \RuntimeException(
sprintf('Autoloader expected resource "%s" to be declared in file "%s".', $resourceName, $resourceAbsolutePath) sprintf('Autoloader expected resource "%s" to be declared in file "%s".', $resourceName, $resourceAbsolutePath)
); );
@ -176,25 +166,24 @@ class SplClassLoader implements SplAutoloader
* *
* @return string Resource absolute path. * @return string Resource absolute path.
*/ */
private function getResourceAbsolutePath($resourceName) private function getResourceAbsolutePath($resourceName){
{
$resourceRelativePath = $this->getResourceRelativePath($resourceName); $resourceRelativePath = $this->getResourceRelativePath($resourceName);
foreach ($this->resources as $resource => $resourcesPath) { foreach($this->resources as $resource => $resourcesPath){
if (strpos($resourceName, $resource) !== 0) { if(strpos($resourceName, $resource) !== 0){
continue; continue;
} }
foreach ($resourcesPath as $resourcePath) { foreach($resourcesPath as $resourcePath){
$resourceAbsolutePath = $resourcePath . DIRECTORY_SEPARATOR . $resourceRelativePath; $resourceAbsolutePath = $resourcePath . DIRECTORY_SEPARATOR . $resourceRelativePath;
if (is_file($resourceAbsolutePath)) { if(is_file($resourceAbsolutePath)){
return $resourceAbsolutePath; return $resourceAbsolutePath;
} }
} }
} }
if ($this->includePathLookup && ($resourceAbsolutePath = stream_resolve_include_path($resourceRelativePath)) !== false) { if($this->includePathLookup && ($resourceAbsolutePath = stream_resolve_include_path($resourceRelativePath)) !== false){
return $resourceAbsolutePath; return $resourceAbsolutePath;
} }
@ -208,17 +197,16 @@ class SplClassLoader implements SplAutoloader
* *
* @return string Resource relative path. * @return string Resource relative path.
*/ */
private function getResourceRelativePath($resourceName) private function getResourceRelativePath($resourceName){
{
// We always work with FQCN in this context // We always work with FQCN in this context
$resourceName = ltrim($resourceName, '\\'); $resourceName = ltrim($resourceName, '\\');
$resourcePath = ''; $resourcePath = '';
if (($lastNamespacePosition = strrpos($resourceName, '\\')) !== false) { if(($lastNamespacePosition = strrpos($resourceName, '\\')) !== false){
// Namespaced resource name // Namespaced resource name
$resourceNamespace = substr($resourceName, 0, $lastNamespacePosition); $resourceNamespace = substr($resourceName, 0, $lastNamespacePosition);
$resourceName = substr($resourceName, $lastNamespacePosition + 1); $resourceName = substr($resourceName, $lastNamespacePosition + 1);
$resourcePath = str_replace('\\', DIRECTORY_SEPARATOR, $resourceNamespace) . DIRECTORY_SEPARATOR; $resourcePath = str_replace('\\', DIRECTORY_SEPARATOR, $resourceNamespace) . DIRECTORY_SEPARATOR;
} }
return $resourcePath . str_replace('_', DIRECTORY_SEPARATOR, $resourceName) . $this->fileExtension; return $resourcePath . str_replace('_', DIRECTORY_SEPARATOR, $resourceName) . $this->fileExtension;
@ -231,8 +219,7 @@ class SplClassLoader implements SplAutoloader
* *
* @return boolean * @return boolean
*/ */
private function isResourceDeclared($resourceName) private function isResourceDeclared($resourceName){
{
return class_exists($resourceName, false) return class_exists($resourceName, false)
|| interface_exists($resourceName, false) || interface_exists($resourceName, false)
|| (function_exists('trait_exists') && trait_exists($resourceName, false)); || (function_exists('trait_exists') && trait_exists($resourceName, false));

View File

@ -4,9 +4,9 @@
* *
* WARNING: Do not include this file * WARNING: Do not include this file
* *
* @author Lisachenko Alexander <lisachenko.it@gmail.com> * @author Lisachenko Alexander <lisachenko.it@gmail.com>
* @version 2.0.0 * @version 2.0.0
* @link https://github.com/krakjoe/pthreads/blob/master/examples/stub.php * @link https://github.com/krakjoe/pthreads/blob/master/examples/stub.php
*/ */
/** /**
@ -68,11 +68,10 @@ define('PTHREADS_ALLOW_GLOBALS', 0x10000000);
* Threaded objects, most importantly, provide implicit safety for the programmer; * Threaded objects, most importantly, provide implicit safety for the programmer;
* all operations on the object scope are safe. * all operations on the object scope are safe.
* *
* @link http://www.php.net/manual/en/class.threaded.php * @link http://www.php.net/manual/en/class.threaded.php
* @since 2.0.0 * @since 2.0.0
*/ */
class Threaded implements Traversable, Countable, ArrayAccess class Threaded implements Traversable, Countable, ArrayAccess{
{
/** /**
* Fetches a chunk of the objects properties table of the given size * Fetches a chunk of the objects properties table of the given size
* *
@ -81,12 +80,14 @@ class Threaded implements Traversable, Countable, ArrayAccess
* @link http://www.php.net/manual/en/threaded.chunk.php * @link http://www.php.net/manual/en/threaded.chunk.php
* @return array An array of items from the objects member table * @return array An array of items from the objects member table
*/ */
public function chunk($size) {} public function chunk($size){
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function count() {} public function count(){
}
/** /**
* Retrieves terminal error information from the referenced object * Retrieves terminal error information from the referenced object
@ -94,7 +95,8 @@ class Threaded implements Traversable, Countable, ArrayAccess
* @link http://www.php.net/manual/en/threaded.getterminationinfo.php * @link http://www.php.net/manual/en/threaded.getterminationinfo.php
* @return array|bool array containing the termination conditions of the referenced object * @return array|bool array containing the termination conditions of the referenced object
*/ */
public function getTerminationInfo() {} public function getTerminationInfo(){
}
/** /**
* Tell if the referenced object is executing * Tell if the referenced object is executing
@ -102,7 +104,8 @@ class Threaded implements Traversable, Countable, ArrayAccess
* @link http://www.php.net/manual/en/threaded.isrunning.php * @link http://www.php.net/manual/en/threaded.isrunning.php
* @return bool A boolean indication of state * @return bool A boolean indication of state
*/ */
public function isRunning() {} public function isRunning(){
}
/** /**
* Tell if the referenced object exited, suffered fatal errors, or threw uncaught exceptions during execution * Tell if the referenced object exited, suffered fatal errors, or threw uncaught exceptions during execution
@ -110,7 +113,8 @@ class Threaded implements Traversable, Countable, ArrayAccess
* @link http://www.php.net/manual/en/threaded.isterminated.php * @link http://www.php.net/manual/en/threaded.isterminated.php
* @return bool A boolean indication of state * @return bool A boolean indication of state
*/ */
public function isTerminated() {} public function isTerminated(){
}
/** /**
* Tell if the referenced object is waiting for notification * Tell if the referenced object is waiting for notification
@ -118,7 +122,8 @@ class Threaded implements Traversable, Countable, ArrayAccess
* @link http://www.php.net/manual/en/threaded.iswaiting.php * @link http://www.php.net/manual/en/threaded.iswaiting.php
* @return bool A boolean indication of state * @return bool A boolean indication of state
*/ */
public function isWaiting() {} public function isWaiting(){
}
/** /**
* Lock the referenced objects property table * Lock the referenced objects property table
@ -126,18 +131,20 @@ class Threaded implements Traversable, Countable, ArrayAccess
* @link http://www.php.net/manual/en/threaded.lock.php * @link http://www.php.net/manual/en/threaded.lock.php
* @return bool A boolean indication of state * @return bool A boolean indication of state
*/ */
public function lock() {} public function lock(){
}
/** /**
* Merges data into the current object * Merges data into the current object
* *
* @param mixed $from The data to merge * @param mixed $from The data to merge
* @param bool $overwrite Overwrite existing keys flag, by default true * @param bool $overwrite Overwrite existing keys flag, by default true
* *
* @link http://www.php.net/manual/en/threaded.merge.php * @link http://www.php.net/manual/en/threaded.merge.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
public function merge($from, $overwrite = true) {} public function merge($from, $overwrite = true){
}
/** /**
* Send notification to the referenced object * Send notification to the referenced object
@ -145,27 +152,32 @@ class Threaded implements Traversable, Countable, ArrayAccess
* @link http://www.php.net/manual/en/threaded.notify.php * @link http://www.php.net/manual/en/threaded.notify.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
public function notify() {} public function notify(){
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function offsetGet($offset) {} public function offsetGet($offset){
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function offsetSet($offset, $value) {} public function offsetSet($offset, $value){
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function offsetExists($offset) {} public function offsetExists($offset){
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function offsetUnset($offset) {} public function offsetUnset($offset){
}
/** /**
* Pops an item from the objects property table * Pops an item from the objects property table
@ -173,7 +185,8 @@ class Threaded implements Traversable, Countable, ArrayAccess
* @link http://www.php.net/manual/en/threaded.pop.php * @link http://www.php.net/manual/en/threaded.pop.php
* @return mixed The last item from the objects properties table * @return mixed The last item from the objects properties table
*/ */
public function pop() {} public function pop(){
}
/** /**
* The programmer should always implement the run method for objects that are intended for execution. * The programmer should always implement the run method for objects that are intended for execution.
@ -181,7 +194,8 @@ class Threaded implements Traversable, Countable, ArrayAccess
* @link http://www.php.net/manual/en/threaded.run.php * @link http://www.php.net/manual/en/threaded.run.php
* @return void The methods return value, if used, will be ignored * @return void The methods return value, if used, will be ignored
*/ */
public function run() {} public function run(){
}
/** /**
* Shifts an item from the objects properties table * Shifts an item from the objects properties table
@ -189,18 +203,20 @@ class Threaded implements Traversable, Countable, ArrayAccess
* @link http://www.php.net/manual/en/threaded.shift.php * @link http://www.php.net/manual/en/threaded.shift.php
* @return mixed The first item from the objects properties table * @return mixed The first item from the objects properties table
*/ */
public function shift() {} public function shift(){
}
/** /**
* Executes the block while retaining the synchronization lock for the current context. * Executes the block while retaining the synchronization lock for the current context.
* *
* @param \Closure $function The block of code to execute * @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 * @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 * @link http://www.php.net/manual/en/threaded.synchronized.php
* @return mixed The return value from the block * @return mixed The return value from the block
*/ */
public function synchronized(\Closure $function, $args = null) {} public function synchronized(\Closure $function, $args = null){
}
/** /**
* Unlock the referenced objects storage for the calling context * Unlock the referenced objects storage for the calling context
@ -208,7 +224,8 @@ class Threaded implements Traversable, Countable, ArrayAccess
* @link http://www.php.net/manual/en/threaded.unlock.php * @link http://www.php.net/manual/en/threaded.unlock.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
public function unlock() {} public function unlock(){
}
/** /**
* Waits for notification from the Stackable * Waits for notification from the Stackable
@ -218,7 +235,8 @@ class Threaded implements Traversable, Countable, ArrayAccess
* @link http://www.php.net/manual/en/threaded.wait.php * @link http://www.php.net/manual/en/threaded.wait.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
public function wait($timeout) {} public function wait($timeout){
}
} }
/** /**
@ -229,15 +247,15 @@ class Threaded implements Traversable, Countable, ArrayAccess
* *
* @link http://www.php.net/manual/en/class.thread.php * @link http://www.php.net/manual/en/class.thread.php
*/ */
class Thread extends Threaded class Thread extends Threaded{
{
/** /**
* Detaches a thread * Detaches a thread
* *
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
public function detach() {} public function detach(){
}
/** /**
* Will return the identity of the Thread that created the referenced Thread * Will return the identity of the Thread that created the referenced Thread
@ -245,14 +263,16 @@ class Thread extends Threaded
* @link http://www.php.net/manual/en/thread.getcreatorid.php * @link http://www.php.net/manual/en/thread.getcreatorid.php
* @return int A numeric identity * @return int A numeric identity
*/ */
public function getCreatorId() {} public function getCreatorId(){
}
/** /**
* Will return the instance of currently executing thread * Will return the instance of currently executing thread
* *
* @return static * @return static
*/ */
public static function getCurrentThread() {} public static function getCurrentThread(){
}
/** /**
* Will return the identity of the currently executing thread * Will return the identity of the currently executing thread
@ -260,7 +280,8 @@ class Thread extends Threaded
* @link http://www.php.net/manual/en/thread.getcurrentthreadid.php * @link http://www.php.net/manual/en/thread.getcurrentthreadid.php
* @return int * @return int
*/ */
public static function getCurrentThreadId() {} public static function getCurrentThreadId(){
}
/** /**
* Will return the identity of the referenced Thread * Will return the identity of the referenced Thread
@ -268,7 +289,8 @@ class Thread extends Threaded
* @link http://www.php.net/manual/en/thread.getthreadid.php * @link http://www.php.net/manual/en/thread.getthreadid.php
* @return int * @return int
*/ */
public function getThreadId() {} public function getThreadId(){
}
/** /**
* Tell if the referenced Thread has been joined by another context * Tell if the referenced Thread has been joined by another context
@ -276,7 +298,8 @@ class Thread extends Threaded
* @link http://www.php.net/manual/en/thread.isjoined.php * @link http://www.php.net/manual/en/thread.isjoined.php
* @return bool A boolean indication of state * @return bool A boolean indication of state
*/ */
public function isJoined() {} public function isJoined(){
}
/** /**
* Tell if the referenced Thread has been started * Tell if the referenced Thread has been started
@ -284,7 +307,8 @@ class Thread extends Threaded
* @link http://www.php.net/manual/en/thread.isstarted.php * @link http://www.php.net/manual/en/thread.isstarted.php
* @return bool A boolean indication of state * @return bool A boolean indication of state
*/ */
public function isStarted() {} public function isStarted(){
}
/** /**
* Causes the calling context to wait for the referenced Thread to finish executing * Causes the calling context to wait for the referenced Thread to finish executing
@ -292,14 +316,16 @@ class Thread extends Threaded
* @link http://www.php.net/manual/en/thread.join.php * @link http://www.php.net/manual/en/thread.join.php
* @return bool A boolean indication of state * @return bool A boolean indication of state
*/ */
public function join() {} public function join(){
}
/** /**
* Kills the referenced thread, dangerously ! * Kills the referenced thread, dangerously !
* *
* @link http://www.php.net/manual/en/thread.kill.php * @link http://www.php.net/manual/en/thread.kill.php
*/ */
public function kill() {} public function kill(){
}
/** /**
* Will start a new Thread to execute the implemented run method * Will start a new Thread to execute the implemented run method
@ -309,17 +335,20 @@ class Thread extends Threaded
* @link http://www.php.net/manual/en/thread.start.php * @link http://www.php.net/manual/en/thread.start.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
public function start($options = PTHREADS_INHERIT_ALL) {} public function start($options = PTHREADS_INHERIT_ALL){
}
/** /**
* Will execute the Callable in the global scope * Will execute the Callable in the global scope
* *
* @param Callable $block The code to execute * @param Callable $block The code to execute
* @param ... $args Variable length list of arguments to pass to the Callable upon execution * @param ... $args Variable length list of arguments to pass to the Callable upon execution
* @link http://www.php.net/manual/en/thread.start.php *
* @link http://www.php.net/manual/en/thread.start.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
public static function globally(Callable $block, $args = null){} public static function globally(Callable $block, $args = null){
}
} }
/** /**
@ -337,8 +366,7 @@ class Thread extends Threaded
* *
* @link http://www.php.net/manual/en/class.worker.php * @link http://www.php.net/manual/en/class.worker.php
*/ */
class Worker extends Thread class Worker extends Thread{
{
/** /**
* Returns the number of threaded tasks waiting to be executed by the referenced Worker * Returns the number of threaded tasks waiting to be executed by the referenced Worker
@ -346,7 +374,8 @@ class Worker extends Thread
* @link http://www.php.net/manual/en/worker.getstacked.php * @link http://www.php.net/manual/en/worker.getstacked.php
* @return int An integral value * @return int An integral value
*/ */
public function getStacked() {} public function getStacked(){
}
/** /**
* Tell if the referenced Worker has been shutdown * Tell if the referenced Worker has been shutdown
@ -354,7 +383,8 @@ class Worker extends Thread
* @link http://www.php.net/manual/en/worker.isshutdown.php * @link http://www.php.net/manual/en/worker.isshutdown.php
* @return bool A boolean indication of state * @return bool A boolean indication of state
*/ */
public function isShutdown() {} public function isShutdown(){
}
/** /**
* Tell if a Worker is executing threaded tasks * Tell if a Worker is executing threaded tasks
@ -362,7 +392,8 @@ class Worker extends Thread
* @link http://www.php.net/manual/en/worker.isworking.php * @link http://www.php.net/manual/en/worker.isworking.php
* @return bool A boolean indication of state * @return bool A boolean indication of state
*/ */
public function isWorking() {} public function isWorking(){
}
/** /**
* Shuts down the Worker after executing all the threaded tasks previously stacked * Shuts down the Worker after executing all the threaded tasks previously stacked
@ -370,7 +401,8 @@ class Worker extends Thread
* @link http://www.php.net/manual/en/worker.shutdown.php * @link http://www.php.net/manual/en/worker.shutdown.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
public function shutdown() {} public function shutdown(){
}
/** /**
* Appends the referenced object to the stack of the referenced Worker * Appends the referenced object to the stack of the referenced Worker
@ -380,7 +412,8 @@ class Worker extends Thread
* @link http://www.php.net/manual/en/worker.stack.php * @link http://www.php.net/manual/en/worker.stack.php
* @return int The new length of the stack * @return int The new length of the stack
*/ */
public function stack(Threaded &$work) {} public function stack(Threaded &$work){
}
/** /**
* Removes the referenced object ( or all objects if parameter is null ) from stack of the referenced Worker * Removes the referenced object ( or all objects if parameter is null ) from stack of the referenced Worker
@ -390,7 +423,8 @@ class Worker extends Thread
* @link http://www.php.net/manual/en/worker.unstack.php * @link http://www.php.net/manual/en/worker.unstack.php
* @return int The new length of the stack * @return int The new length of the stack
*/ */
public function unstack(Threaded &$work = null) {} public function unstack(Threaded &$work = null){
}
} }
/** /**
@ -400,8 +434,7 @@ class Worker extends Thread
* *
* @link http://www.php.net/manual/en/class.mutex.php * @link http://www.php.net/manual/en/class.mutex.php
*/ */
class Mutex class Mutex{
{
/** /**
* Create, and optionally lock a new Mutex for the caller * Create, and optionally lock a new Mutex for the caller
@ -411,7 +444,8 @@ class Mutex
* @link http://www.php.net/manual/en/mutex.create.php * @link http://www.php.net/manual/en/mutex.create.php
* @return int A newly created and optionally locked Mutex handle * @return int A newly created and optionally locked Mutex handle
*/ */
final public static function create($lock = false) {} final public static function create($lock = false){
}
/** /**
* Destroy mutex * Destroy mutex
@ -424,7 +458,8 @@ class Mutex
* @link http://www.php.net/manual/en/mutex.destroy.php * @link http://www.php.net/manual/en/mutex.destroy.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
final public static function destroy($mutex) {} final public static function destroy($mutex){
}
/** /**
* Attempt to lock the Mutex for the caller. * Attempt to lock the Mutex for the caller.
@ -436,7 +471,8 @@ class Mutex
* @link http://www.php.net/manual/en/mutex.lock.php * @link http://www.php.net/manual/en/mutex.lock.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
final public static function lock($mutex) {} 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. * Attempt to lock the Mutex for the caller without blocking if the Mutex is owned (locked) by another Thread.
@ -446,7 +482,8 @@ class Mutex
* @link http://www.php.net/manual/en/mutex.trylock.php * @link http://www.php.net/manual/en/mutex.trylock.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
final public static function trylock($mutex) {} final public static function trylock($mutex){
}
/** /**
* Release mutex * Release mutex
@ -454,13 +491,14 @@ class Mutex
* Attempts to unlock the Mutex for the caller, optionally destroying the Mutex handle. * 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. * 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 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. * @param bool $destroy When true pthreads will destroy the Mutex after a successful unlock.
* *
* @link http://www.php.net/manual/en/mutex.unlock.php * @link http://www.php.net/manual/en/mutex.unlock.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
final public static function unlock($mutex, $destroy = false) {} final public static function unlock($mutex, $destroy = false){
}
} }
/** /**
@ -470,8 +508,7 @@ class Mutex
* *
* @link http://www.php.net/manual/en/class.cond.php * @link http://www.php.net/manual/en/class.cond.php
*/ */
class Cond class Cond{
{
/** /**
* Broadcast to all Threads blocking on a call to Cond::wait(). * Broadcast to all Threads blocking on a call to Cond::wait().
* *
@ -480,7 +517,8 @@ class Cond
* @link http://www.php.net/manual/en/cond.broadcast.php * @link http://www.php.net/manual/en/cond.broadcast.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
final public static function broadcast($condition) {} final public static function broadcast($condition){
}
/** /**
* Creates a new Condition Variable for the caller. * Creates a new Condition Variable for the caller.
@ -488,7 +526,8 @@ class Cond
* @link http://www.php.net/manual/en/cond.create.php * @link http://www.php.net/manual/en/cond.create.php
* @return int A handle to a Condition Variable * @return int A handle to a Condition Variable
*/ */
final public static function create() {} final public static function create(){
}
/** /**
* Destroy a condition * Destroy a condition
@ -502,7 +541,8 @@ class Cond
* @link http://www.php.net/manual/en/cond.destroy.php * @link http://www.php.net/manual/en/cond.destroy.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
final public static function destroy($condition) {} final public static function destroy($condition){
}
/** /**
* Signal a Condition * Signal a Condition
@ -512,18 +552,20 @@ class Cond
* @link http://www.php.net/manual/en/cond.signal.php * @link http://www.php.net/manual/en/cond.signal.php
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
final public static function signal($condition) {} final public static function signal($condition){
}
/** /**
* Wait for a signal on a Condition Variable, optionally specifying a timeout to limit waiting time. * 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 $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 $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 * @param int $timeout An optional timeout, in microseconds
* *
* @return bool A boolean indication of success * @return bool A boolean indication of success
*/ */
final public static function wait($condition, $mutex, $timeout = null) {} final public static function wait($condition, $mutex, $timeout = null){
}
} }
/** /**
@ -535,8 +577,7 @@ class Cond
* *
* @link http://www.php.net/manual/en/class.pool.php * @link http://www.php.net/manual/en/class.pool.php
*/ */
class Pool class Pool{
{
/** /**
* The maximum number of Worker threads allowed in this Pool * The maximum number of Worker threads allowed in this Pool
* *
@ -582,20 +623,22 @@ class Pool
/** /**
* Construct a new Pool of Workers * Construct a new Pool of Workers
* *
* @param integer $size The maximum number of Workers this Pool can create * @param integer $size The maximum number of Workers this Pool can create
* @param string $class The class for new Workers * @param string $class The class for new Workers
* @param array $ctor An array of arguments to be passed to 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 * @link http://www.php.net/manual/en/pool.__construct.php
*/ */
public function __construct($size, $class, array $ctor = array()) {} public function __construct($size, $class, array $ctor = array()){
}
/** /**
* Shuts down all Workers, and collect all Stackables, finally destroys the Pool * Shuts down all Workers, and collect all Stackables, finally destroys the Pool
* *
* @link http://www.php.net/manual/en/pool.__destruct.php * @link http://www.php.net/manual/en/pool.__destruct.php
*/ */
public function __destruct() {} public function __destruct(){
}
/** /**
* Collect references to completed tasks * Collect references to completed tasks
@ -606,7 +649,8 @@ class Pool
* *
* @link http://www.php.net/manual/en/pool.collect.php * @link http://www.php.net/manual/en/pool.collect.php
*/ */
public function collect(callable $collector) {} public function collect(callable $collector){
}
/** /**
* Resize the Pool * Resize the Pool
@ -615,14 +659,16 @@ class Pool
* *
* @link http://www.php.net/manual/en/pool.resize.php * @link http://www.php.net/manual/en/pool.resize.php
*/ */
public function resize($size) {} public function resize($size){
}
/** /**
* Shutdown all Workers in this Pool * Shutdown all Workers in this Pool
* *
* @link http://www.php.net/manual/en/pool.shutdown.php * @link http://www.php.net/manual/en/pool.shutdown.php
*/ */
public function shutdown() {} public function shutdown(){
}
/** /**
* Submit the task to the next Worker in the Pool * Submit the task to the next Worker in the Pool
@ -631,15 +677,17 @@ class Pool
* *
* @return int the identifier of the Worker executing the object * @return int the identifier of the Worker executing the object
*/ */
public function submit(Threaded $task) {} public function submit(Threaded $task){
}
/** /**
* Submit the task to the specific Worker in the Pool * Submit the task to the specific Worker in the Pool
* *
* @param int $worker The worker for execution * @param int $worker The worker for execution
* @param Threaded $task The task for execution * @param Threaded $task The task for execution
* *
* @return int the identifier of the Worker that accepted the object * @return int the identifier of the Worker that accepted the object
*/ */
public function submitTo($worker, Threaded $task) {} public function submitTo($worker, Threaded $task){
}
} }

View File

@ -46,7 +46,8 @@ define("YAML_CRLN_BREAK", 3);
* @link http://www.php.net/manual/en/function.yaml-emit-file.php * @link http://www.php.net/manual/en/function.yaml-emit-file.php
* @return bool * @return bool
*/ */
function yaml_emit_file($filename, $data, $encoding = YAML_ANY_ENCODING, $linebreak = YAML_ANY_BREAK, array $callbacks = array()){} function yaml_emit_file($filename, $data, $encoding = YAML_ANY_ENCODING, $linebreak = YAML_ANY_BREAK, array $callbacks = array()){
}
/** /**
* Returns the YAML representation of a value * Returns the YAML representation of a value
@ -59,7 +60,8 @@ function yaml_emit_file($filename, $data, $encoding = YAML_ANY_ENCODING, $linebr
* @link http://www.php.net/manual/en/function.yaml-emit.php * @link http://www.php.net/manual/en/function.yaml-emit.php
* @return string * @return string
*/ */
function yaml_emit($data, $encoding = YAML_ANY_ENCODING, $linebreak = YAML_ANY_BREAK, array $callbacks = array()){} function yaml_emit($data, $encoding = YAML_ANY_ENCODING, $linebreak = YAML_ANY_BREAK, array $callbacks = array()){
}
/** /**
* Parse a YAML stream from a file * Parse a YAML stream from a file
@ -72,7 +74,8 @@ function yaml_emit($data, $encoding = YAML_ANY_ENCODING, $linebreak = YAML_ANY_B
* @link http://www.php.net/manual/en/function.yaml-parse-file.php * @link http://www.php.net/manual/en/function.yaml-parse-file.php
* @return mixed * @return mixed
*/ */
function yaml_parse_file($filename, $pos = 0, &$ndocs = null, array $callbacks = array()){} function yaml_parse_file($filename, $pos = 0, &$ndocs = null, array $callbacks = array()){
}
/** /**
* Parse a YAML stream from a URL * Parse a YAML stream from a URL
@ -85,7 +88,8 @@ function yaml_parse_file($filename, $pos = 0, &$ndocs = null, array $callbacks =
* @link http://www.php.net/manual/en/function.yaml-parse-url.php * @link http://www.php.net/manual/en/function.yaml-parse-url.php
* @return mixed * @return mixed
*/ */
function yaml_parse_url($url, $pos = 0, &$ndocs = null, array $callbacks = array()){} function yaml_parse_url($url, $pos = 0, &$ndocs = null, array $callbacks = array()){
}
/** /**
* Parse a YAML stream * Parse a YAML stream
@ -98,4 +102,5 @@ function yaml_parse_url($url, $pos = 0, &$ndocs = null, array $callbacks = array
* @link http://www.php.net/manual/en/function.yaml-parse.php * @link http://www.php.net/manual/en/function.yaml-parse.php
* @return mixed * @return mixed
*/ */
function yaml_parse($input, $pos = 0, &$ndocs = null, array $callbacks = array()){} function yaml_parse($input, $pos = 0, &$ndocs = null, array $callbacks = array()){
}

View File

@ -15,7 +15,7 @@ function testCase($name, $output, $expected){
global $testErrors; global $testErrors;
if($output === $expected){ if($output === $expected){
console("[TEST] $name: " . Utils\TextFormat::GREEN . "Ok."); console("[TEST] $name: " . Utils\TextFormat::GREEN . "Ok.");
} else{ }else{
console("[TEST] $name: " . Utils\TextFormat::RED . "Error."); console("[TEST] $name: " . Utils\TextFormat::RED . "Error.");
console("Expected " . print_r($expected, true) . ", got " . print_r($output, true)); console("Expected " . print_r($expected, true) . ", got " . print_r($output, true));
++$testErrors; ++$testErrors;
@ -33,7 +33,7 @@ if(!class_exists("\\PocketMine\\Server", false)){
if($testErrors === 0){ if($testErrors === 0){
console(Utils\TextFormat::GREEN . "[TEST] No errors. Test complete."); console(Utils\TextFormat::GREEN . "[TEST] No errors. Test complete.");
exit(0); exit(0);
} else{ }else{
console(Utils\TextFormat::RED . "[TEST] Errors found."); console(Utils\TextFormat::RED . "[TEST] Errors found.");
exit(1); exit(1);
} }