Introduce type hinting in methods prototype (PHP >= 7.1)

This commit is contained in:
Molkobain
2020-08-26 21:21:56 +02:00
parent 77cd764b1c
commit 825c70c001
30 changed files with 246 additions and 191 deletions

View File

@@ -114,7 +114,7 @@ abstract class UIBlock implements iUIBlock
*
* @param string|null $sId
*/
public function __construct($sId = null)
public function __construct(?string $sId = null)
{
$this->sId = ($sId !== null) ? $sId : $this->GenerateId();
}
@@ -161,7 +161,7 @@ abstract class UIBlock implements iUIBlock
* @inheritDoc
* @throws \Exception
*/
public function GetJsFilesUrlRecursively($bAbsoluteUrl = false)
public function GetJsFilesUrlRecursively(bool $bAbsoluteUrl = false)
{
return $this->GetFilesUrlRecursively(static::ENUM_BLOCK_FILES_TYPE_JS, $bAbsoluteUrl);
}
@@ -170,7 +170,7 @@ abstract class UIBlock implements iUIBlock
* @inheritDoc
* @throws \Exception
*/
public function GetCssFilesUrlRecursively($bAbsoluteUrl = false)
public function GetCssFilesUrlRecursively(bool $bAbsoluteUrl = false)
{
return $this->GetFilesUrlRecursively(static::ENUM_BLOCK_FILES_TYPE_CSS, $bAbsoluteUrl);
}
@@ -185,14 +185,14 @@ abstract class UIBlock implements iUIBlock
* @return array
* @throws \Exception
*/
protected function GetFilesUrlRecursively($sFilesType, $bAbsoluteUrl = false)
protected function GetFilesUrlRecursively(string $sFilesType, bool $bAbsoluteUrl = false)
{
$aFiles = [];
$sFilesRelPathMethodName = 'Get'.ucfirst($sFilesType).'FilesRelPaths';
$sFilesAbsUrlMethodName = 'Get'.ucfirst($sFilesType).'FilesUrlRecursively';
// Files from the block itself
foreach($this::$sFilesRelPathMethodName() as $sFilePath)
foreach ($this::$sFilesRelPathMethodName() as $sFilePath)
{
$aFiles[] = (($bAbsoluteUrl === true) ? utils::GetAbsoluteUrlAppRoot() : '').$sFilePath;
}