Skip to content

Commit

Permalink
enforce type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
m-vo committed Apr 20, 2022
1 parent 8e74730 commit d0d73f1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 37 deletions.
4 changes: 2 additions & 2 deletions core-bundle/src/Resources/contao/library/Contao/System.php
Expand Up @@ -125,9 +125,9 @@ protected function __construct()
*
* @param string $strKey The property name
*
* @return mixed|null The property value or null
* @return mixed The property value or null
*/
public function __get($strKey)
public function __get(string $strKey): mixed
{
if (!isset($this->arrObjects[$strKey]))
{
Expand Down
14 changes: 7 additions & 7 deletions core-bundle/src/Resources/contao/library/Contao/Template.php
Expand Up @@ -132,7 +132,7 @@ public function __construct($strTemplate='', $strContentType='text/html')
* @param string $strKey The property name
* @param mixed $varValue The property value
*/
public function __set($strKey, $varValue)
public function __set(string $strKey, mixed $varValue): void
{
$this->arrData[$strKey] = $varValue;
}
Expand All @@ -144,7 +144,7 @@ public function __set($strKey, $varValue)
*
* @return mixed The property value
*/
public function __get($strKey)
public function __get(string $strKey): mixed
{
if (isset($this->arrData[$strKey]))
{
Expand Down Expand Up @@ -186,7 +186,7 @@ public function __call($strKey, $arrParams)
*
* @return boolean True if the property is set
*/
public function __isset($strKey)
public function __isset(string $strKey): bool
{
return isset($this->arrData[$strKey]);
}
Expand All @@ -196,7 +196,7 @@ public function __isset($strKey)
*
* @param array $arrData The data array
*/
public function setData($arrData)
public function setData(array $arrData): void
{
$this->arrData = $arrData;
}
Expand All @@ -206,7 +206,7 @@ public function setData($arrData)
*
* @return array The data array
*/
public function getData()
public function getData(): array
{
return $this->arrData;
}
Expand All @@ -216,7 +216,7 @@ public function getData()
*
* @param string $strTemplate The template name
*/
public function setName($strTemplate)
public function setName(string $strTemplate): void
{
$this->strTemplate = $strTemplate;
}
Expand All @@ -226,7 +226,7 @@ public function setName($strTemplate)
*
* @return string The template name
*/
public function getName()
public function getName(): string
{
return $this->strTemplate;
}
Expand Down
35 changes: 7 additions & 28 deletions core-bundle/src/Twig/FragmentTemplate.php
Expand Up @@ -41,29 +41,17 @@ public function __construct(private string $templateName, private \Closure $onGe
// Do not call parent constructor
}

/**
* @param string $key
* @param mixed $value
*/
public function __set(/* string */ $key, $value): void
public function __set(string $key, mixed $value): void
{
$this->set($key, $value);
}

/**
* @param string $key
*
* @return mixed
*/
public function __get(/* string */ $key)
public function __get(string $key): mixed
{
return $this->get($key);
}

/**
* @param string $key
*/
public function __isset(/* string */ $key): bool
public function __isset(string $key): bool
{
return $this->has($key);
}
Expand All @@ -73,18 +61,12 @@ public function __call($strKey, $arrParams): never
self::throwOnAccess();
}

/**
* @param mixed $value
*/
public function set(string $key, $value): void
public function set(string $key, mixed $value): void
{
$this->context[$key] = $value;
}

/**
* @return mixed
*/
public function get(string $key)
public function get(string $key): mixed
{
return $this->context[$key] ?? throw new \RuntimeException(sprintf('Key "%s" does not exist.', $key));
}
Expand All @@ -97,7 +79,7 @@ public function has(string $key): bool
/**
* @param array<string, mixed> $data
*/
public function setData(/* array */ $data): void
public function setData(array $data): void
{
$this->context = $data;
}
Expand All @@ -110,10 +92,7 @@ public function getData(): array
return $this->context;
}

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

0 comments on commit d0d73f1

Please sign in to comment.