Added typehints and PhpDoc for events API

excluded blocks and entities events API to avoid merge conflicts
This commit is contained in:
Dylan K. Taylor
2017-07-05 16:42:06 +01:00
parent 6504fdabab
commit 6cd4d2c5a2
57 changed files with 461 additions and 198 deletions

View File

@ -44,7 +44,7 @@ abstract class Event{
/**
* @return string
*/
final public function getEventName(){
final public function getEventName() : string{
return $this->eventName === null ? get_class($this) : $this->eventName;
}
@ -53,7 +53,7 @@ abstract class Event{
*
* @throws \BadMethodCallException
*/
public function isCancelled(){
public function isCancelled() : bool{
if(!($this instanceof Cancellable)){
throw new \BadMethodCallException("Event is not Cancellable");
}
@ -67,19 +67,19 @@ abstract class Event{
*
* @throws \BadMethodCallException
*/
public function setCancelled($value = true){
public function setCancelled(bool $value = true){
if(!($this instanceof Cancellable)){
throw new \BadMethodCallException("Event is not Cancellable");
}
/** @var Event $this */
$this->isCancelled = (bool) $value;
$this->isCancelled = $value;
}
/**
* @return HandlerList
*/
public function getHandlers(){
public function getHandlers() : HandlerList{
if(static::$handlerList === null){
static::$handlerList = new HandlerList();
}