diff --git a/Classes/Domain/Model/DataAttribute.php b/Classes/Domain/Model/DataAttribute.php index 791f998..7943941 100644 --- a/Classes/Domain/Model/DataAttribute.php +++ b/Classes/Domain/Model/DataAttribute.php @@ -125,7 +125,7 @@ protected function ensureValue($value){ /** * @return string */ - public function getName() + public function getName() :string { if(substr($this->name, 0, 5) !== 'data-') { return self::NAME_PREFIX . $this->name; @@ -137,7 +137,7 @@ public function getName() /** * @param string $name */ - public function setName($name) + public function setName(string $name) { $this->ensureName($name); } @@ -145,7 +145,7 @@ public function setName($name) /** * @return string */ - public function getValue() + public function getValue() :string { return $this->value; } @@ -153,7 +153,7 @@ public function getValue() /** * @param string $value */ - public function setValue($value) + public function setValue(string $value) { $this->ensureValue($value); } diff --git a/Classes/Domain/Model/Iframe.php b/Classes/Domain/Model/Iframe.php index f511e93..52b9248 100644 --- a/Classes/Domain/Model/Iframe.php +++ b/Classes/Domain/Model/Iframe.php @@ -252,7 +252,7 @@ protected function ensureDataAttributes($definition) { /** * @return string */ - public function getSrc() + public function getSrc() :string { return $this->src; } @@ -261,7 +261,7 @@ public function getSrc() * @param string $src * @return void */ - public function setSrc($src) + public function setSrc(string $src) { $this->ensureSrc($src); } @@ -269,7 +269,7 @@ public function setSrc($src) /** * @return string */ - public function getClass() + public function getClass() :string { return $this->class; } @@ -277,7 +277,7 @@ public function getClass() /** * @param string $class */ - public function setClass($class) + public function setClass(string $class) { $this->class = $class; } @@ -285,7 +285,7 @@ public function setClass($class) /** * @return string */ - public function getName() + public function getName() :string { return $this->name; } @@ -293,7 +293,7 @@ public function getName() /** * @param string $name */ - public function setName($name) + public function setName(string $name) { $this->name = $name; } @@ -301,7 +301,7 @@ public function setName($name) /** * @return int */ - public function getWidth() + public function getWidth() :int { return $this->width; } @@ -310,7 +310,7 @@ public function getWidth() * @param int $width * @return void */ - public function setWidth($width) + public function setWidth(int $width) { $this->ensureWidth($width); } @@ -318,7 +318,7 @@ public function setWidth($width) /** * @return int */ - public function getHeight() + public function getHeight() :int { return $this->height; } @@ -326,7 +326,7 @@ public function getHeight() /** * @param int $height */ - public function setHeight($height) + public function setHeight(int $height) { $this->ensureHeight($height); } @@ -334,7 +334,7 @@ public function setHeight($height) /** * @return array */ - public function getSandbox() + public function getSandbox() :array { return $this->sandbox; } @@ -342,7 +342,7 @@ public function getSandbox() /** * @param string $sandbox */ - public function setSandbox($sandbox) + public function setSandbox(string $sandbox) { $this->ensureSandboxValues($sandbox); } @@ -350,7 +350,7 @@ public function setSandbox($sandbox) /** * @return boolean */ - public function isAllowFullScreen() + public function isAllowFullScreen() :bool { return $this->allowFullScreen; } @@ -358,15 +358,15 @@ public function isAllowFullScreen() /** * @param boolean $allowFullScreen */ - public function setAllowFullScreen($allowFullScreen) + public function setAllowFullScreen(bool $allowFullScreen) { - $this->ensureAllowFullScreen(boolval($allowFullScreen)); + $this->ensureAllowFullScreen($allowFullScreen); } /** * @return boolean */ - public function isAllowPaymentRequest() + public function isAllowPaymentRequest() :bool { return $this->allowPaymentRequest; } @@ -374,15 +374,15 @@ public function isAllowPaymentRequest() /** * @param boolean $allowPaymentRequest */ - public function setAllowPaymentRequest($allowPaymentRequest) + public function setAllowPaymentRequest(bool $allowPaymentRequest) { - $this->ensureAllowPaymentRequest(boolval($allowPaymentRequest)); + $this->ensureAllowPaymentRequest($allowPaymentRequest); } /** * @return array */ - public function getDataAttributes() + public function getDataAttributes() :array { return $this->dataAttributes; } @@ -390,7 +390,7 @@ public function getDataAttributes() /** * @param string $dataAttributes */ - public function setDataAttributes($dataAttributes) + public function setDataAttributes(string $dataAttributes) { $this->ensureDataAttributes($dataAttributes); } @@ -401,7 +401,7 @@ public function setDataAttributes($dataAttributes) * @return string * @throws InvalidValueException */ - public function generateHtmlTag(){ + public function generateHtmlTag() { $attributes = []; if($this->getSrc()) { $attributes['src'] = $this->getSrc(); diff --git a/Classes/Hooks/TypoScriptFrontendControllerHook.php b/Classes/Hooks/TypoScriptFrontendControllerHook.php index 9f429d4..55effac 100644 --- a/Classes/Hooks/TypoScriptFrontendControllerHook.php +++ b/Classes/Hooks/TypoScriptFrontendControllerHook.php @@ -31,9 +31,7 @@ public function contentPostProcAll($pObjArray) if(isset($pObjArray['pObj'])) { /** @var TypoScriptFrontendController $typoScriptFrontendController */ $typoScriptFrontendController = $pObjArray['pObj']; - $enabled = isset($typoScriptFrontendController->config['config']['csp.']['enabled']) - ? boolval($typoScriptFrontendController->config['config']['csp.']['enabled']) - : false; + $enabled = boolval($typoScriptFrontendController->config['config']['csp.']['enabled'] ?? false); if($enabled) { diff --git a/Classes/Service/ContentSecurityPolicyManager.php b/Classes/Service/ContentSecurityPolicyManager.php index e28433d..634f5f4 100644 --- a/Classes/Service/ContentSecurityPolicyManager.php +++ b/Classes/Service/ContentSecurityPolicyManager.php @@ -118,9 +118,8 @@ static public function isNonceModeEnabled() { * @throws InvalidClassException */ static private function createNewBuilderInstance() { - $className = isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['csp']['ContentSecurityPolicyHeaderBuilder']) - ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['csp']['ContentSecurityPolicyHeaderBuilder'] - : ContentSecurityPolicyHeaderBuilder::class; + $className = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['csp']['ContentSecurityPolicyHeaderBuilder'] ?? + ContentSecurityPolicyHeaderBuilder::class; /** @var ContentSecurityPolicyHeaderBuilderInterface $instance */ $instance = GeneralUtility::makeInstance($className); @@ -161,9 +160,7 @@ static public function reloadConfig() { */ static public function addTypoScriptSettings($tsfe) { - $enabled = isset($tsfe->config['config']['csp.']['enabled']) - ? boolval($tsfe->config['config']['csp.']['enabled']) - : false; + $enabled = boolval($tsfe->config['config']['csp.']['enabled'] ?? false); if($enabled) { @@ -182,7 +179,7 @@ static public function addTypoScriptSettings($tsfe) { && is_array($config['presets.'])) { foreach ($config['presets.'] as $preSet) { - $preSetEnabled = isset($preSet['enabled']) ? boolval($preSet['enabled']) : false; + $preSetEnabled = boolval($preSet['enabled'] ?? false); if ($preSetEnabled && isset($preSet['rules.']) ) { @@ -203,8 +200,8 @@ static public function extractHeaders() { $responseHeader = ''; $headers = self::getBuilder()->getHeader(); if(count($headers) > 1) { - $name = isset($headers['name']) ? $headers['name'] : ''; - $value = isset($headers['value']) ? $headers['value'] : '';; + $name = $headers['name'] ?? ''; + $value = $headers['value'] ?? ''; $responseHeader = $name . ': ' . $value; } diff --git a/Classes/Utility/IframeUtility.php b/Classes/Utility/IframeUtility.php index 0ebad76..5cccbbc 100644 --- a/Classes/Utility/IframeUtility.php +++ b/Classes/Utility/IframeUtility.php @@ -45,15 +45,15 @@ class IframeUtility * @return string */ static public function generateIframeTagFromConfigArray($conf){ - $src = isset($conf['src']) ? $conf['src'] : ''; - $class = isset($conf['class']) ? $conf['class'] : ''; - $name = isset($conf['name']) ? $conf['name'] : ''; - $width = isset($conf['width']) ? $conf['width'] : 0; - $height = isset($conf['height']) ? $conf['height'] : 0; - $sandbox = isset($conf['sandbox']) ? $conf['sandbox'] : ''; - $allowFullScreen = isset($conf['allowFullScreen']) ? $conf['allowFullScreen'] : ''; - $allowPaymentRequest = isset($conf['allowPaymentRequest']) ? $conf['allowPaymentRequest'] : ''; - $dataAttributes = isset($conf['dataAttributes']) ? $conf['dataAttributes'] : ''; + $src = $conf['src'] ?? ''; + $class = $conf['class'] ?? ''; + $name = $conf['name'] ?? ''; + $width = $conf['width'] ?? 0; + $height = $conf['height'] ?? 0; + $sandbox = $conf['sandbox'] ?? ''; + $allowFullScreen = $conf['allowFullScreen'] ?? ''; + $allowPaymentRequest = $conf['allowPaymentRequest'] ?? ''; + $dataAttributes = $conf['dataAttributes'] ?? ''; $iframe = new Iframe($src, $class, $name, $width, $height, $sandbox, $allowFullScreen, $allowPaymentRequest, $dataAttributes); diff --git a/Classes/ViewHelpers/ScriptViewHelper.php b/Classes/ViewHelpers/ScriptViewHelper.php index 7a4811e..2d39257 100644 --- a/Classes/ViewHelpers/ScriptViewHelper.php +++ b/Classes/ViewHelpers/ScriptViewHelper.php @@ -80,7 +80,7 @@ public function render($hashMethod = 'sha256') public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { $output = $renderChildrenClosure(); - $hashMethod = isset($arguments['hashMethod']) ? $arguments['hashMethod'] : ''; + $hashMethod = $arguments['hashMethod'] ?? ''; if($hashMethod) { $output = ScriptUtility::getValidScriptTag($output, $hashMethod, true);