Skip to content

Commit

Permalink
A major update for PHP 7.0 type hinting
Browse files Browse the repository at this point in the history
  • Loading branch information
iranianpep committed Nov 13, 2017
1 parent d0ab692 commit 888c549
Show file tree
Hide file tree
Showing 42 changed files with 259 additions and 255 deletions.
14 changes: 7 additions & 7 deletions src/Botonomous/AbstractAccessList.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function getSubAccessControlList($sublistKey)
*
* @return bool
*/
protected function isEmailInList(array $list)
protected function isEmailInList(array $list): bool
{
// get user info
$userInfo = $this->getSlackUserInfo();
Expand All @@ -59,7 +59,7 @@ protected function isEmailInList(array $list)
*
* @return bool
*/
protected function checkEmail()
protected function checkEmail(): bool
{
// load the relevant list based on the class name e.g. BlackList or WhiteList
$list = $this->getSubAccessControlList($this->getShortClassName());
Expand All @@ -74,12 +74,12 @@ protected function checkEmail()

/**
* @param string $requestKey
* @param $listKey
* @param string $listKey
* @param string $subListKey
*
* @return bool|null
*/
protected function findInListByRequestKey($requestKey, $listKey, $subListKey)
protected function findInListByRequestKey(string $requestKey, string $listKey, string $subListKey)
{
/**
* load the relevant list to start checking
Expand Down Expand Up @@ -123,7 +123,7 @@ public function setRequest($request)
/**
* @return Dictionary
*/
public function getDictionary()
public function getDictionary(): Dictionary
{
if (!isset($this->dictionary)) {
$this->setDictionary(new Dictionary());
Expand All @@ -143,7 +143,7 @@ public function setDictionary(Dictionary $dictionary)
/**
* @return ApiClient
*/
public function getApiClient()
public function getApiClient(): ApiClient
{
if (!isset($this->apiClient)) {
$this->setApiClient(new ApiClient());
Expand Down Expand Up @@ -192,7 +192,7 @@ public function getSlackUserInfo()
/**
* @return ClassUtility
*/
public function getClassUtility()
public function getClassUtility(): ClassUtility
{
if (!isset($this->classUtility)) {
$this->setClassUtility(new ClassUtility());
Expand Down
26 changes: 13 additions & 13 deletions src/Botonomous/AbstractBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class AbstractBot
/**
* @return Config
*/
public function getConfig()
public function getConfig(): Config
{
if ($this->config === null) {
$this->config = (new Config());
Expand All @@ -52,7 +52,7 @@ public function setConfig(Config $config)
/**
* @return AbstractBaseListener
*/
public function getListener()
public function getListener(): AbstractBaseListener
{
if (!isset($this->listener)) {
$listenerClass = __NAMESPACE__.'\\listener\\'.ucwords($this->getConfig()->get('listener')).'Listener';
Expand All @@ -70,7 +70,7 @@ public function setListener(AbstractBaseListener $listener)
/**
* @return MessageUtility
*/
public function getMessageUtility()
public function getMessageUtility(): MessageUtility
{
if (!isset($this->messageUtility)) {
$this->setMessageUtility(new MessageUtility());
Expand All @@ -90,7 +90,7 @@ public function setMessageUtility(MessageUtility $messageUtility)
/**
* @return CommandContainer
*/
public function getCommandContainer()
public function getCommandContainer(): CommandContainer
{
if (!isset($this->commandContainer)) {
$this->setCommandContainer(new CommandContainer());
Expand All @@ -110,7 +110,7 @@ public function setCommandContainer(CommandContainer $commandContainer)
/**
* @return FormattingUtility
*/
public function getFormattingUtility()
public function getFormattingUtility(): FormattingUtility
{
if (!isset($this->formattingUtility)) {
$this->setFormattingUtility(new FormattingUtility());
Expand All @@ -130,7 +130,7 @@ public function setFormattingUtility(FormattingUtility $formattingUtility)
/**
* @return LoggerUtility
*/
public function getLoggerUtility()
public function getLoggerUtility(): LoggerUtility
{
if (!isset($this->loggerUtility)) {
$this->setLoggerUtility(new LoggerUtility());
Expand All @@ -150,7 +150,7 @@ public function setLoggerUtility(LoggerUtility $loggerUtility)
/**
* @return OAuth
*/
public function getOauth()
public function getOauth(): OAuth
{
if (!isset($this->oauth)) {
$this->setOauth(new OAuth());
Expand All @@ -170,7 +170,7 @@ public function setOauth(OAuth $oauth)
/**
* @return RequestUtility
*/
public function getRequestUtility()
public function getRequestUtility(): RequestUtility
{
return $this->getListener()->getRequestUtility();
}
Expand All @@ -186,7 +186,7 @@ public function setRequestUtility(RequestUtility $requestUtility)
/**
* @return BlackList
*/
public function getBlackList()
public function getBlackList(): BlackList
{
if (!isset($this->blackList)) {
$this->setBlackList(new BlackList($this->getListener()->getRequest()));
Expand All @@ -206,7 +206,7 @@ public function setBlackList(BlackList $blackList)
/**
* @return WhiteList
*/
public function getWhiteList()
public function getWhiteList(): WhiteList
{
if (!isset($this->whiteList)) {
$this->setWhiteList(new WhiteList($this->getListener()->getRequest()));
Expand All @@ -226,7 +226,7 @@ public function setWhiteList(WhiteList $whiteList)
/**
* @return Sender
*/
public function getSender()
public function getSender(): Sender
{
if (!isset($this->sender)) {
$this->setSender(new Sender($this));
Expand All @@ -246,7 +246,7 @@ public function setSender(Sender $sender)
/**
* @return Dictionary
*/
public function getDictionary()
public function getDictionary(): Dictionary
{
if (!isset($this->dictionary)) {
$this->setDictionary(new Dictionary());
Expand All @@ -266,7 +266,7 @@ public function setDictionary(Dictionary $dictionary)
/**
* @return CommandExtractor
*/
public function getCommandExtractor()
public function getCommandExtractor(): CommandExtractor
{
if (!isset($this->commandExtractor)) {
$this->setCommandExtractor(new CommandExtractor());
Expand Down
4 changes: 2 additions & 2 deletions src/Botonomous/AbstractCommandContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public function getAll()
}

/**
* @param null $key
* @param string $key
*
* @throws \Exception
*
* @return mixed
*/
public function getAllAsObject($key = null)
public function getAllAsObject(string $key = null)
{
$commands = $this->getAll();
if (!empty($commands)) {
Expand Down
6 changes: 3 additions & 3 deletions src/Botonomous/AbstractConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract class AbstractConfig
*
* @return mixed
*/
public function get($key, $replacements = [], $plugin = null)
public function get(string $key, array $replacements = [], $plugin = null)
{
$configs = static::$configs;

Expand Down Expand Up @@ -50,7 +50,7 @@ public function get($key, $replacements = [], $plugin = null)
*
* @return self
*/
private function getPluginConfigObject($plugin)
private function getPluginConfigObject($plugin): self
{
$pluginConfigClass = __NAMESPACE__.'\\plugin\\'.strtolower($plugin)
.'\\'.ucfirst($plugin).'Config';
Expand Down Expand Up @@ -81,7 +81,7 @@ public function getPluginConfigs($plugin)
/**
* @return array
*/
public function getConfigs()
public function getConfigs(): array
{
return static::$configs;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Botonomous/AbstractSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class AbstractSender
/**
* @return LoggerUtility
*/
public function getLoggerUtility()
public function getLoggerUtility(): LoggerUtility
{
if (!isset($this->loggerUtility)) {
$this->setLoggerUtility(new LoggerUtility());
Expand All @@ -39,7 +39,7 @@ public function setLoggerUtility(LoggerUtility $loggerUtility)
/**
* @return Config
*/
public function getConfig()
public function getConfig(): Config
{
if (!isset($this->config)) {
$this->config = (new Config());
Expand All @@ -59,7 +59,7 @@ public function setConfig(Config $config)
/**
* @return ApiClient
*/
public function getApiClient()
public function getApiClient(): ApiClient
{
if (!isset($this->apiClient)) {
$this->setApiClient(new ApiClient());
Expand All @@ -79,7 +79,7 @@ public function setApiClient(ApiClient $apiClient)
/**
* @return Client
*/
public function getClient()
public function getClient(): Client
{
if (!isset($this->client)) {
$this->setClient(new Client());
Expand All @@ -99,7 +99,7 @@ public function setClient(Client $client)
/**
* @return MessageUtility
*/
public function getMessageUtility()
public function getMessageUtility(): MessageUtility
{
if (!isset($this->messageUtility)) {
$this->setMessageUtility(new MessageUtility());
Expand Down
4 changes: 2 additions & 2 deletions src/Botonomous/AbstractSlackEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ abstract class AbstractSlackEntity extends AbstractBaseSlack
/**
* @return string
*/
public function getSlackId()
public function getSlackId(): string
{
return $this->slackId;
}

/**
* @param string $slackId
*/
public function setSlackId($slackId)
public function setSlackId(string $slackId)
{
$this->slackId = $slackId;
}
Expand Down
14 changes: 7 additions & 7 deletions src/Botonomous/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class Action extends AbstractBaseSlack
/**
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}

/**
* @param string $name
*/
public function setName($name)
public function setName(string $name)
{
$this->name = $name;
}
Expand All @@ -41,39 +41,39 @@ public function getText()
/**
* @param string $text
*/
public function setText($text)
public function setText(string $text)
{
$this->text = $text;
}

/**
* @return string
*/
public function getValue()
public function getValue(): string
{
return $this->value;
}

/**
* @param string $value
*/
public function setValue($value)
public function setValue(string $value)
{
$this->value = $value;
}

/**
* @return string
*/
public function getType()
public function getType(): string
{
return $this->type;
}

/**
* @param string $type
*/
public function setType($type)
public function setType(string $type)
{
$this->type = $type;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Botonomous/BlackList.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct($request)
/**
* @return bool
*/
public function isBlackListed()
public function isBlackListed(): bool
{
return $this->isUsernameBlackListed()
|| $this->isUserIdBlackListed()
Expand All @@ -27,7 +27,7 @@ public function isBlackListed()
/**
* @return bool
*/
public function isUsernameBlackListed()
public function isUsernameBlackListed(): bool
{
return $this->findInListByRequestKey('user_name', $this->getShortClassName(), 'username') === true
? true : false;
Expand All @@ -36,7 +36,7 @@ public function isUsernameBlackListed()
/**
* @return bool
*/
public function isUserIdBlackListed()
public function isUserIdBlackListed(): bool
{
return $this->findInListByRequestKey('user_id', $this->getShortClassName(), 'userId') === true
? true : false;
Expand Down
4 changes: 2 additions & 2 deletions src/Botonomous/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class Channel extends AbstractSlackEntity
/**
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}

/**
* @param string $name
*/
public function setName($name)
public function setName(string $name)
{
$this->name = $name;
}
Expand Down

0 comments on commit 888c549

Please sign in to comment.