diff options
Diffstat (limited to 'modules-available/sysconfig/inc/ppd.inc.php')
-rw-r--r-- | modules-available/sysconfig/inc/ppd.inc.php | 255 |
1 files changed, 126 insertions, 129 deletions
diff --git a/modules-available/sysconfig/inc/ppd.inc.php b/modules-available/sysconfig/inc/ppd.inc.php index 5ccdbd53..c28e0355 100644 --- a/modules-available/sysconfig/inc/ppd.inc.php +++ b/modules-available/sysconfig/inc/ppd.inc.php @@ -134,7 +134,7 @@ class Ppd 'JCLEnd' => '.*', // TODO: The above three need to be either completely absent, or all three must be defined /* - * Resolution and Appearence Control, section 5.9 + * Resolution and Appearance Control, section 5.9 */ /* * Gray Levels and Halftoning, section 5.10 @@ -247,8 +247,8 @@ class Ppd private $data; private $dataLen; - private $error; - private $warnings; + private $error = null; + private $warnings = []; private $knownKeywordMalformed; @@ -301,16 +301,16 @@ class Ppd $this->dataLen = strlen($this->data); $this->encoder = false; $this->sourceEncoding = false; - $this->error = false; + $this->error = null; $this->warnings = array(); $this->knownKeywordMalformed = false; $this->settings = array(); $this->requiredKeywords = array(); // Parse - /* @var $rawOption \PpdOption */ - /* @var $currentBlock \PpdBlockInternal */ - $currentBlock = false; + /* @var PpdOption $rawOption */ + /* @var ?PpdBlockInternal $currentBlock */ + $currentBlock = null; $inRawBlock = false; // True if in a multi-line InvocationValue or QuotedValue (3.6: Parsing Summary for Values) $wantsEnd = false; // For now we ignore values mostly while parsing. The spec says that InvocationValues must only contain printable @@ -318,9 +318,9 @@ class Ppd $lStart = -1; $lEnd = -1; $no = 0; - while ($lStart < $this->dataLen && $lEnd !== false) { + while ($lStart < $this->dataLen) { unset($mainKeyword, $optionKeyword, $optionTranslation, $option, $value, $valueTranslation); - if ($no !== 0 && $this->data{$lEnd} === "\r" && $this->data{$lEnd + 1} === "\n") { + if ($no !== 0 && $this->data[$lEnd] === "\r" && $this->data[$lEnd + 1] === "\n") { $lEnd++; } if ($no === 1) { @@ -332,6 +332,8 @@ class Ppd } $lStart = $lEnd + 1; $lEnd = $this->nextLineEnd($lStart); + if ($lEnd === null) + break; $no++; // Validate $len = $lEnd - $lStart; @@ -343,7 +345,7 @@ class Ppd $this->warn($no, 'Exceeds length of 255'); } if (!$inRawBlock && preg_match_all('/[^\x09\x0A\x0D\x20-\xFF]/', $line, $out)) { - $chars = $this->escapeBinaryArray($out[0]); + $chars = self::escapeBinaryArray($out[0]); $this->warn($no, 'Contains invalid character(s) ' . $chars); } // Handle @@ -373,13 +375,13 @@ class Ppd } } // 3) Handle "key [option]: value" - if ($line{0} === '*') { - if ($line{1} === '%') { + if ($line[0] === '*') { + if ($line[1] === '%') { // Skip comment continue; } $parts = preg_split('/\s*:\s*/', $line, 2); // TODO: UIConstrains - if (count($parts) !== 2) { + if (!is_array($parts) || count($parts) !== 2) { $this->warn($no, 'No colon found; not in "key [option]: value" format, ignoring line'); continue; } @@ -390,11 +392,12 @@ class Ppd continue; } $mainKeyword = $out[1]; - $optionKeyword = isset($out[3]) ? $out[3] : false; + $optionKeyword = $out[3] ?? null; $optionTranslation = isset($out[4]) ? $this->unhexTranslation($no, substr($out[4], 1)) : $optionKeyword; // If no translation given, fallback to option // 3b) Handle value + /** @var string $value */ $value = $parts[1]; - if ($value{0} === '"') { + if ($value[0] === '"') { // Start of InvocationValue or QuotedValue if (preg_match(',^"([^"]*)"(/.*)?$,', $value, $vMatch)) { // Single line @@ -417,30 +420,25 @@ class Ppd $valueTranslation = $value; } // Key-value-pair parsed, now the fun part - // Special cases for openening closing certain groups + // Special cases for opening closing certain groups if ($mainKeyword === 'OpenGroup') { - if ($currentBlock !== false) { + if ($currentBlock !== null) { $this->error = 'Line ' . $no . ': OpenGroup while other block (type=' . $currentBlock->type . ', id=' . $currentBlock->id . ') was not closed yet'; return; } // TODO: Check unique - $nb = new PpdBlockInternal($value, $valueTranslation, 'Group', $currentBlock, $lStart); - if ($currentBlock !== false) { - $currentBlock->childBlocks[] = $nb; - } + $nb = new PpdBlockInternal($value, $valueTranslation, 'Group', null, $lStart); $currentBlock = $nb; continue; } elseif ($mainKeyword === 'OpenSubGroup') { - if ($currentBlock === false || $currentBlock->type !== 'Group') { - $this->error = 'Line ' . $no . ': OpenSubGroup with no preceeding OpenGroup'; + if ($currentBlock === null || $currentBlock->type !== 'Group') { + $this->error = 'Line ' . $no . ': OpenSubGroup with no preceding OpenGroup'; return; } // TODO: Check unique $nb = new PpdBlockInternal($value, $valueTranslation, 'SubGroup', $currentBlock, $lStart); - if ($currentBlock !== false) { - $currentBlock->childBlocks[] = $nb; - } + $currentBlock->childBlocks[] = $nb; $currentBlock = $nb; continue; } elseif ($mainKeyword === 'OpenUI' || $mainKeyword === 'JCLOpenUI') { @@ -450,23 +448,24 @@ class Ppd } else { $type = substr($type, 4); } - if ($currentBlock !== false && $currentBlock->isUi()) { + if ($currentBlock !== null && $currentBlock->isUi()) { $this->error = 'Line ' . $no . ': ' . $mainKeyword . ' while previous ' . $type . ' "' . $currentBlock->id . '" was not closed yet'; return; } - if ($optionKeyword === false) { + if ($optionKeyword === null) { $this->error = 'Line ' . $no . ': ' . $mainKeyword . ' with no option keyword'; return; } - if ($optionKeyword{0} !== '*') { + if ($optionKeyword[0] !== '*') { $this->error = 'Line ' . $no . ': ' . $mainKeyword . " with option keyword that doesn't start with asterisk (*)."; return; } // TODO: Check unique - $nb = new PpdBlockInternal($optionKeyword, $optionTranslation, $type, $currentBlock, $lStart); + $nb = new PpdBlockInternal($optionKeyword, $optionTranslation ?? $optionKeyword, + $type, $currentBlock, $lStart); $nb->value = $value; - if ($currentBlock !== false) { + if ($currentBlock !== null) { $currentBlock->childBlocks[] = $nb; } $currentBlock = $nb; @@ -481,7 +480,7 @@ class Ppd } else { $type = substr($type, 5); } - if ($currentBlock === false) { + if ($currentBlock === null) { $this->error = 'Line ' . $no . ': ' . $mainKeyword . ' with no Open' . $type; return; } @@ -498,7 +497,7 @@ class Ppd $currentBlock = $currentBlock->parent; continue; } elseif ($mainKeyword === 'OrderDependency') { - if ($currentBlock === false || $currentBlock->isUi()) { + if ($currentBlock === null || $currentBlock->isUi()) { $this->warn($no, 'OrderDependency outside OpenUI/CloseUI block'); } continue; @@ -521,9 +520,10 @@ class Ppd $this->warn($no, 'Required keyword ' . $mainKeyword . ' declared twice, ignoring'); continue; } + } else { + $this->requiredKeywords[$mainKeyword] = array($value); } - $this->requiredKeywords[$mainKeyword] = array($value); - if (($err = $this->validateLine($this->REQUIRED_KEYWORDS[$mainKeyword], $optionKeyword, $value)) !== true) { + if (($err = Ppd::validateLine($this->REQUIRED_KEYWORDS[$mainKeyword], $optionKeyword, $value)) !== true) { $this->warn($no, 'Required main keyword ' . $mainKeyword . ': ' . $err); $this->knownKeywordMalformed = true; } @@ -531,7 +531,7 @@ class Ppd } // Other well known keywords if (isset($this->KNOWN_KEYWORDS[$mainKeyword])) { - if (($err = $this->validateLine($this->KNOWN_KEYWORDS[$mainKeyword], $optionKeyword, $value)) !== true) { + if (($err = Ppd::validateLine($this->KNOWN_KEYWORDS[$mainKeyword], $optionKeyword, $value)) !== true) { $this->warn($no, 'Known main keyword ' . $mainKeyword . ': ' . $err); $this->knownKeywordMalformed = true; } @@ -541,17 +541,18 @@ class Ppd $option = $this->getOption(substr($mainKeyword, 7), $currentBlock); $option->default = new PpdOption($lStart, $len, $value, $valueTranslation); continue; - } elseif (substr($mainKeyword, 0, 17) === 'FoomaticRIPOption') { - if ($optionKeyword === false) { + } + if (substr($mainKeyword, 0, 17) === 'FoomaticRIPOption') { + if ($optionKeyword === null) { $this->warn($no, "$mainKeyword with no option keyword"); - } elseif ($currentBlock !== false && isset($this->settings[$optionKeyword])) { + } elseif ($currentBlock !== null && isset($this->settings[$optionKeyword])) { $option = $this->getOption($optionKeyword, $currentBlock); $option->foomatic[substr($mainKeyword, 11)] = new PpdOption($lStart, $len, $value, $valueTranslation); } else { $this->warn($no, 'TODO: ' . $line); } } elseif (substr($mainKeyword, 0, 6) === 'Custom') { - if ($optionKeyword === false) { + if ($optionKeyword === null) { $this->warn($no, "$mainKeyword with no option keyword"); } elseif ($optionKeyword !== 'True') { $this->warn($no, "$mainKeyword with option keyword other than 'True'; ignored"); @@ -560,7 +561,7 @@ class Ppd $option->custom = new PpdOption($lStart, $len, $value, $valueTranslation); } } elseif (substr($mainKeyword, 0, 11) === 'ParamCustom') { - if ($optionKeyword === false) { + if ($optionKeyword === null) { $this->warn($no, "$mainKeyword with no option keyword"); } elseif (substr($mainKeyword, 11) !== $optionKeyword) { $this->warn($no, "Don't know how to handle $mainKeyword with option keyword $optionKeyword " @@ -569,20 +570,20 @@ class Ppd $option = $this->getOption($optionKeyword, $currentBlock); $option->customParam = new PpdOption($lStart, $len, $value, $valueTranslation); } - } elseif ($mainKeyword{0} === '?') { + } elseif ($mainKeyword[0] === '?') { // Ignoring option query for now - } elseif ($optionKeyword === false && !isset($this->KNOWN_KEYWORDS[$mainKeyword])) { + } elseif ($optionKeyword === null && !isset($this->KNOWN_KEYWORDS[$mainKeyword])) { // Must be a definition for an option $this->warn($no, "Don't know how to handle line with main keyword '$mainKeyword', no option keyword found."); } else { // Some option for some option ;) - if ($optionKeyword === false) { + if ($optionKeyword === null) { // We know that this is a known main keyword otherwise we would have hit the previous elseif block $optionKeyword = $value; $optionTranslation = $valueTranslation; } $option = $this->getOption($mainKeyword, $currentBlock); - $optionInstance = new PpdOption($lStart, $len, $optionKeyword, $optionTranslation); + $optionInstance = new PpdOption($lStart, $len, $optionKeyword, $optionTranslation ?? $optionKeyword); if ($this->binary_in_array($mainKeyword, $this->REPEATED_KEYWORDS)) { // This can occur multiple times, just pile them up $option->values[] = $optionInstance; @@ -603,9 +604,9 @@ class Ppd } elseif (strlen(trim($line)) !== 0) { $this->warn($no, 'Invalid format; not empty and not starting with asterisk (*)'); } - } + } // end while loop over ppd contents // - if ($currentBlock !== false) { + if ($currentBlock !== null) { $this->error = 'Block ' . $currentBlock->id . ' (' . $currentBlock->type . ') was never closed.'; return; } @@ -615,11 +616,11 @@ class Ppd $this->error = 'One or more required keywords missing'; } } - if ($this->error !== false) { + if ($this->error !== null) { return; } // All required keywords exist - if (preg_match('/utf\-?8/i', $this->requiredKeywords['LanguageEncoding'][0])) { + if (preg_match('/utf-?8/i', $this->requiredKeywords['LanguageEncoding'][0])) { $this->sourceEncoding = false; // Would be a NOOP } elseif (isset($this->ENCODINGS[$this->requiredKeywords['LanguageEncoding'][0]])) { $this->sourceEncoding = $this->ENCODINGS[$this->requiredKeywords['LanguageEncoding'][0]]; @@ -669,12 +670,12 @@ class Ppd } } - private function nextLineEnd($start) + private function nextLineEnd(int $start): ?int { if ($start >= $this->dataLen) - return false; + return null; while ($start < $this->dataLen) { - $char = $this->data{$start}; + $char = $this->data[$start]; if ($char === "\r" || $char === "\n") return $start; ++$start; @@ -682,27 +683,26 @@ class Ppd return $this->dataLen; } - private function warn($lineNo, $message) + private function warn(int $lineNo, string $message): void { $line = 'Line ' . $lineNo . ': ' . $message; $this->warnings[] = $line; } - private function escapeBinaryArray($array) + private static function escapeBinaryArray(array $array): string { - $chars = array_reduce(array_unique($array), function ($carry, $item) { + return array_reduce(array_unique($array), function ($carry, $item) { return $carry . '\x' . dechex(ord($item)); }, ''); - return $chars; } - private function unhexTranslation($lineNo, $translation) + private function unhexTranslation(int $lineNo, string $translation): string { if (strpos($translation, '<') === false) return $translation; return preg_replace_callback('/<[^>]*>/', function ($match) use ($lineNo) { if (preg_match_all('/[^a-fA-F0-9\<\>\s]/', $match[0], $out)) { - $this->warn($lineNo, 'Invalid character(s) in hex substring: ' . $this->escapeBinaryArray($out[0])); + $this->warn($lineNo, 'Invalid character(s) in hex substring: ' . self::escapeBinaryArray($out[0])); } $string = preg_replace('/[^a-fA-F0-9]/', '', $match[0]); if (strlen($string) % 2 !== 0) { @@ -713,7 +713,7 @@ class Ppd }, $translation); } - private function hexTranslation($translation) + private function hexTranslation(string $translation): string { return preg_replace_callback('/[\x00-\x1f\x7b-\xff\:\<\>]+/', function ($match) { return '<' . unpack('H*', $match[0])[1] . '>'; @@ -724,23 +724,23 @@ class Ppd * Get option object * * @param string $name option name - * @param \PpdBlockInternal $block which block this option is defined in - * @return \PpdSettingInternal the option object + * @param ?PpdBlockInternal $block which block this option is defined in + * @return PpdSettingInternal the option object */ - private function getOption($name, $block = false) + private function getOption(string $name, ?PpdBlockInternal $block = null): PpdSettingInternal { if (!isset($this->settings[$name])) { $this->settings[$name] = new PpdSettingInternal(); $this->settings[$name]->block = $block; - } elseif ($block !== false) { - if ($this->settings[$name]->block === false || $block->isChildOf($this->settings[$name]->block)) { + } elseif ($block !== null) { + if ($this->settings[$name]->block === null || $block->isChildOf($this->settings[$name]->block)) { $this->settings[$name]->block = $block; } } return $this->settings[$name]; } - private function binary_in_array($elem, $array) + private function binary_in_array($elem, $array): bool { $top = sizeof($array) - 1; $bot = 0; @@ -755,7 +755,7 @@ class Ppd return false; } - private function validateLine($validator, $option, $value) + private static function validateLine($validator, ?string $option, string $value) { if (is_array($validator)) { $oExp = $validator[0]; @@ -780,7 +780,7 @@ class Ppd return true; } - private function getEolChar() + private function getEolChar(): string { $rn = substr_count("\r\n", $this->data); $r = substr_count("\r", $this->data) - $rn; @@ -799,21 +799,21 @@ class Ppd * */ - public function getError() + public function getError(): ?string { return $this->error; } - public function getWarnings() + public function getWarnings(): array { return $this->warnings; } - public function getUISettings() + public function getUISettings(): array { $result = array(); foreach ($this->settings as $mk => $option) { - $isUi = ($option->block !== false && $option->block->isUi()) || isset($this->UI_KEYWORDS[$mk]); + $isUi = ($option->block !== null && $option->block->isUi()) || isset($this->UI_KEYWORDS[$mk]); if ($isUi) { $result[] = $mk; } @@ -821,30 +821,30 @@ class Ppd return $result; } - public function getSetting($name) + public function getSetting(string $name): ?PpdSetting { if (!isset($this->settings[$name])) - return false; + return null; return new PpdSetting($this->settings[$name], isset($this->UI_KEYWORDS[$name]), $this->encoder); } - public function removeSetting($name) + public function removeSetting(string $name): bool { if (!isset($this->settings[$name])) return false; $setting = $this->settings[$name]; $ranges = array(); - $this->mergeRanges($ranges, $setting->default); - $this->mergeRanges($ranges, $setting->custom); - $this->mergeRanges($ranges, $setting->customParam); + Ppd::mergeRangesFromOption($ranges, $setting->default); + Ppd::mergeRangesFromOption($ranges, $setting->custom); + Ppd::mergeRangesFromOption($ranges, $setting->customParam); foreach ($setting->foomatic as $obj) { - $this->mergeRanges($ranges, $obj); + Ppd::mergeRangesFromOption($ranges, $obj); } foreach ($setting->values as $obj) { - $this->mergeRanges($ranges, $obj); + Ppd::mergeRangesFromOption($ranges, $obj); } - if ($setting->block !== false && $setting->block->isUi()) { - $this->mergeRanges($ranges, $setting->block->start, $setting->block->end); + if ($setting->block !== null && $setting->block->isUi()) { + Ppd::mergeRanges($ranges, $setting->block->start, $setting->block->end); } $tmp = array_map(function ($e) { return $e[0]; }, $ranges); array_multisort($tmp, SORT_NUMERIC, $ranges); @@ -853,20 +853,20 @@ class Ppd foreach ($ranges as $range) { $new .= substr($this->data, $last, $range[0] - $last); $last = $range[1]; - if ($this->data{$last} === "\r") { + if ($this->data[$last] === "\r") { $last++; } - if ($this->data{$last} === "\n") { + if ($this->data[$last] === "\n") { $last++; } } $new .= substr($this->data, $last); $this->data = $new; $this->parse(); - return $this->error === false; + return $this->error === null; } - public function addEmptyOption($settingName, $option, $translation = false, $prepend = true) + public function addEmptyOption(string $settingName, string $option, string $translation = null, bool $prepend = true): bool { if (!isset($this->settings[$settingName])) return false; @@ -874,15 +874,15 @@ class Ppd $pos = false; if (!empty($setting->values)) { if ($prepend) { - $pos = array_reduce($setting->values, function ($carry, $option) { return min($carry, $option->lineOffset); }, PHP_INT_MAX); + $pos = array_reduce($setting->values, function (int $carry, PpdOption $option) { return min($carry, $option->lineOffset); }, PHP_INT_MAX); } else { - $pos = array_reduce($setting->values, function ($carry, $option) { return max($carry, $option->lineOffset); }, 0); + $pos = array_reduce($setting->values, function (int $carry, PpdOption $option) { return max($carry, $option->lineOffset); }, 0); } - } elseif ($setting->default !== false) { + } elseif ($setting->default !== null) { $pos = $setting->default->lineOffset; - } elseif ($setting->block !== false && $setting->block->isUi()) { + } elseif ($setting->block !== null && $setting->block->isUi()) { $pos = $this->nextLineEnd($setting->block->start); - while ($pos !== false && $pos < $this->dataLen && ($this->data{$pos} === "\r" || $this->data{$pos} === "\n")) { + while ($pos !== null && $pos < $this->dataLen && ($this->data[$pos] === "\r" || $this->data[$pos] === "\n")) { $pos++; } } @@ -890,23 +890,23 @@ class Ppd return false; } $line = '*' . $settingName . ' ' . $option; - if ($translation !== false) { + if ($translation !== null) { $line .= '/' . $this->hexTranslation(($this->encoder)($translation, true)); } $eol = $this->getEolChar(); $line .= ': ""' . $eol; $this->data = substr($this->data, 0, $pos) . $line . substr($this->data, $pos); $this->parse(); - return $this->error === false; + return $this->error === null; } - public function setDefaultOption($settingName, $optionName) + public function setDefaultOption($settingName, $optionName): bool { if (!isset($this->settings[$settingName])) return false; $setting = $this->settings[$settingName]; $line = '*Default' . $settingName . ': ' . $optionName; - if ($setting->default !== false) { + if ($setting->default !== null) { $start = $setting->default->lineOffset; $end = $start + $setting->default->lineLen; } elseif (empty($setting->values)) { @@ -918,22 +918,21 @@ class Ppd } $this->data = substr($this->data, 0, $start) . $line . substr($this->data, $end); $this->parse(); - return $this->error === false; + return $this->error === null; } - public function write($file) + public function write(string $file) { return file_put_contents($file, $this->data); } - private function mergeRanges(&$ranges, $start, $end = false) + private static function mergeRangesFromOption(array &$ranges, PpdOption $option): void + { + self::mergeRanges($ranges, $option->lineOffset, $option->lineOffset + $option->lineLen); + } + + private static function mergeRanges(array &$ranges, int $start, int $end): void { - if (is_object($start) && get_class($start) === 'PpdOption') { - $end = $start->lineOffset + $start->lineLen; - $start = $start->lineOffset; - } - if ($start === false || $end === false) - return; if ($start >= $end) return; // Don't even bother foreach (array_keys($ranges) as $key) { @@ -956,7 +955,7 @@ class Ppd // $start must lie before range start, otherwise we'd have hit the case above $end = $ranges[$key][1]; unset($ranges[$key]); - continue; + //continue; } } $ranges[] = array($start, $end); @@ -965,7 +964,7 @@ class Ppd /** * @return bool whether there was at least one known option with format restriction violated. */ - public function hasInvalidOption() + public function hasInvalidOption(): bool { return $this->knownKeywordMalformed; } @@ -1013,15 +1012,13 @@ class PpdSetting /** * PpdSetting constructor. - * - * @param \PpdSettingInternal $setting */ - public function __construct($setting, $isUi, $enc) + public function __construct(PpdSettingInternal $setting, bool $isUi, callable $enc) { - if ($setting->default !== false) { + if ($setting->default !== null) { $this->default = $setting->default->option; } - if ($setting->block !== false && $setting->block->isUi()) { + if ($setting->block !== null && $setting->block->isUi()) { $this->uiOptionType = $setting->block->value; $this->uiOptionTranslation = $enc($setting->block->translation); $this->isUi = true; @@ -1055,9 +1052,9 @@ class PpdSetting class PpdSettingInternal { /** - * @var \PpdOption + * @var ?PpdOption */ - public $default = false; + public $default = null; /** * @var \PpdOption[] */ @@ -1067,17 +1064,17 @@ class PpdSettingInternal */ public $foomatic = array(); /** - * @var \PpdOption + * @var ?PpdOption */ - public $custom = false; + public $custom = null; /** - * @var \PpdOption + * @var ?PpdOption */ - public $customParam = false; + public $customParam = null; /** - * @var \PpdBlockInternal the innermost block this option resides in + * @var ?PpdBlockInternal the innermost block this option resides in */ - public $block = false; + public $block = null; } class PpdOption @@ -1088,7 +1085,7 @@ class PpdOption public $lineLen; public $multiLine = false; - public function __construct($lineOffset, $lineLen, $option, $optionTranslation) + public function __construct(int $lineOffset, int $lineLen, string $option, string $optionTranslation) { $this->option = $option; $this->optionTranslation = $optionTranslation; @@ -1106,13 +1103,13 @@ class PpdBlockInternal public $translation; public $type; /** - * @var \PpdBlockInternal[] + * @var PpdBlockInternal[] */ public $childBlocks = array(); /** - * @var \PpdBlockInternal + * @var ?PpdBlockInternal */ - public $parent; + public $parent = null; /** * @var int start byte in ppd @@ -1120,16 +1117,16 @@ class PpdBlockInternal public $start; /** - * @var int|bool end byte in ppd, false if block is not closed + * @var ?int end byte in ppd, null if block is not closed */ - public $end = false; + public $end = null; /** * @var string value of opening line for block, e.g. 'PickOne' for OpenUI */ - public $value = false; + public $value = ''; - public function __construct($id, $translation, $type, $parent, $start) + public function __construct(string $id, string $translation, string $type, ?PpdBlockInternal $parent, int $start) { $this->id = $id; $this->translation = $translation; @@ -1141,16 +1138,16 @@ class PpdBlockInternal /** * @return bool true if this is a UI block */ - public function isUi() + public function isUi(): bool { return $this->type == 'UI' || $this->type === 'JCLUI'; } /** - * @param \PpdBlockInternal $block some other PpdBlock instance + * @param PpdBlockInternal $block some other PpdBlock instance * @return bool true if this is a child of $block */ - public function isChildOf($block) + public function isChildOf(PpdBlockInternal $block): bool { $parent = $this->parent; while ($parent !== false) { |