Skip to content

Commit

Permalink
pocketmine root: sweep missing return type information
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Jan 19, 2020
1 parent e8a5fa8 commit ea935a1
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/pocketmine/Collectable.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public function isGarbage() : bool{
return $this->isGarbage;
}

/**
* @return void
*/
public function setGarbage(){
$this->isGarbage = true;
}
Expand Down
7 changes: 7 additions & 0 deletions src/pocketmine/CrashDump.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ public function getPath() : string{
return $this->path;
}

/**
* @return string
*/
public function getEncodedData(){
return $this->encodedData;
}
Expand Down Expand Up @@ -345,13 +348,17 @@ private function generalData() : void{

/**
* @param string $line
*
* @return void
*/
public function addLine($line = ""){
fwrite($this->fp, $line . PHP_EOL);
}

/**
* @param string $str
*
* @return void
*/
public function add($str){
fwrite($this->fp, $str);
Expand Down
4 changes: 4 additions & 0 deletions src/pocketmine/IPlayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public function isBanned() : bool;

/**
* @param bool $banned
*
* @return void
*/
public function setBanned(bool $banned);

Expand All @@ -54,6 +56,8 @@ public function isWhitelisted() : bool;

/**
* @param bool $value
*
* @return void
*/
public function setWhitelisted(bool $value);

Expand Down
11 changes: 9 additions & 2 deletions src/pocketmine/MemoryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function __construct(Server $server){
$this->init();
}

private function init(){
private function init() : void{
$this->memoryLimit = ((int) $this->server->getProperty("memory.main-limit", 0)) * 1024 * 1024;

$defaultMemory = 1024;
Expand Down Expand Up @@ -201,6 +201,8 @@ public function getViewDistance(int $distance) : int{
* @param int $limit
* @param bool $global
* @param int $triggerCount
*
* @return void
*/
public function trigger(int $memory, int $limit, bool $global = false, int $triggerCount = 0){
$this->server->getLogger()->debug(sprintf("[Memory Manager] %sLow memory triggered, limit %gMB, using %gMB",
Expand Down Expand Up @@ -230,6 +232,8 @@ public function trigger(int $memory, int $limit, bool $global = false, int $trig

/**
* Called every tick to update the memory manager state.
*
* @return void
*/
public function check(){
Timings::$memoryManagerTimer->startTiming();
Expand Down Expand Up @@ -297,6 +301,8 @@ public function triggerGarbageCollector() : int{
* @param string $outputFolder
* @param int $maxNesting
* @param int $maxStringSize
*
* @return void
*/
public function dumpServerMemory(string $outputFolder, int $maxNesting, int $maxStringSize){
$this->server->getLogger()->notice("[Dump] After the memory dump is done, the server might crash");
Expand All @@ -319,6 +325,7 @@ public function dumpServerMemory(string $outputFolder, int $maxNesting, int $max
* @param int $maxStringSize
* @param \Logger $logger
*
* @return void
* @throws \ReflectionException
*/
public static function dumpMemory($startingObject, string $outputFolder, int $maxNesting, int $maxStringSize, \Logger $logger){
Expand Down Expand Up @@ -479,7 +486,7 @@ public static function dumpMemory($startingObject, string $outputFolder, int $ma
* @param int $maxNesting
* @param int $maxStringSize
*/
private static function continueDump($from, &$data, array &$objects, array &$refCounts, int $recursion, int $maxNesting, int $maxStringSize){
private static function continueDump($from, &$data, array &$objects, array &$refCounts, int $recursion, int $maxNesting, int $maxStringSize) : void{
if($maxNesting <= 0){
$data = "(error) NESTING LIMIT REACHED";
return;
Expand Down
3 changes: 3 additions & 0 deletions src/pocketmine/OfflinePlayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public function getName() : string{
return $this->name;
}

/**
* @return Server
*/
public function getServer(){
return $this->server;
}
Expand Down
17 changes: 17 additions & 0 deletions src/pocketmine/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,18 @@ abstract class Thread extends \Thread{
/** @var bool */
protected $isKilled = false;

/**
* @return \ClassLoader|null
*/
public function getClassLoader(){
return $this->classLoader;
}

/**
* @param \ClassLoader|null $loader
*
* @return void
*/
public function setClassLoader(\ClassLoader $loader = null){
$this->composerAutoloaderPath = \pocketmine\COMPOSER_AUTOLOADER_PATH;

Expand All @@ -55,6 +63,8 @@ public function setClassLoader(\ClassLoader $loader = null){
* WARNING: This method MUST be called from any descendent threads' run() method to make autoloading usable.
* If you do not do this, you will not be able to use new classes that were not loaded when the thread was started
* (unless you are using a custom autoloader).
*
* @return void
*/
public function registerClassLoader(){
if($this->composerAutoloaderPath !== null){
Expand All @@ -65,6 +75,11 @@ public function registerClassLoader(){
}
}

/**
* @param int|null $options TODO: pthreads bug
*
* @return bool
*/
public function start(?int $options = \PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this);

Expand All @@ -76,6 +91,8 @@ public function start(?int $options = \PTHREADS_INHERIT_ALL){

/**
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
*
* @return void
*/
public function quit(){
$this->isKilled = true;
Expand Down
7 changes: 7 additions & 0 deletions src/pocketmine/ThreadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class ThreadManager extends \Volatile{
/** @var ThreadManager */
private static $instance = null;

/**
* @return void
*/
public static function init(){
self::$instance = new ThreadManager();
}
Expand All @@ -44,6 +47,8 @@ public static function getInstance(){

/**
* @param Worker|Thread $thread
*
* @return void
*/
public function add($thread){
if($thread instanceof Thread or $thread instanceof Worker){
Expand All @@ -53,6 +58,8 @@ public function add($thread){

/**
* @param Worker|Thread $thread
*
* @return void
*/
public function remove($thread){
if($thread instanceof Thread or $thread instanceof Worker){
Expand Down
17 changes: 17 additions & 0 deletions src/pocketmine/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,18 @@ abstract class Worker extends \Worker{
/** @var bool */
protected $isKilled = false;

/**
* @return \ClassLoader|null
*/
public function getClassLoader(){
return $this->classLoader;
}

/**
* @param \ClassLoader|null $loader
*
* @return void
*/
public function setClassLoader(\ClassLoader $loader = null){
$this->composerAutoloaderPath = \pocketmine\COMPOSER_AUTOLOADER_PATH;

Expand All @@ -55,6 +63,8 @@ public function setClassLoader(\ClassLoader $loader = null){
* WARNING: This method MUST be called from any descendent threads' run() method to make autoloading usable.
* If you do not do this, you will not be able to use new classes that were not loaded when the thread was started
* (unless you are using a custom autoloader).
*
* @return void
*/
public function registerClassLoader(){
if($this->composerAutoloaderPath !== null){
Expand All @@ -65,6 +75,11 @@ public function registerClassLoader(){
}
}

/**
* @param int|null $options TODO: pthreads bug
*
* @return bool
*/
public function start(?int $options = \PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this);

Expand All @@ -76,6 +91,8 @@ public function start(?int $options = \PTHREADS_INHERIT_ALL){

/**
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
*
* @return void
*/
public function quit(){
$this->isKilled = true;
Expand Down

0 comments on commit ea935a1

Please sign in to comment.