From 1ab187ac21d41d7d34a4f529091a1f5d0bb2924f Mon Sep 17 00:00:00 2001 From: Jeremiasz Major Date: Mon, 10 May 2021 14:53:15 +0200 Subject: [PATCH] [Console] Fixes for PHP 8.1 deprecations --- Descriptor/TextDescriptor.php | 2 +- Descriptor/XmlDescriptor.php | 2 +- Helper/ProgressIndicator.php | 2 +- Helper/Table.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Descriptor/TextDescriptor.php b/Descriptor/TextDescriptor.php index 220bd2e68..7d4d5f0bb 100644 --- a/Descriptor/TextDescriptor.php +++ b/Descriptor/TextDescriptor.php @@ -117,7 +117,7 @@ protected function describeInputDefinition(InputDefinition $definition, array $o $this->writeText('Options:', $options); foreach ($definition->getOptions() as $option) { - if (\strlen($option->getShortcut()) > 1) { + if (\strlen($option->getShortcut() ?? '') > 1) { $laterOptions[] = $option; continue; } diff --git a/Descriptor/XmlDescriptor.php b/Descriptor/XmlDescriptor.php index a6288d44f..e0ed53a38 100644 --- a/Descriptor/XmlDescriptor.php +++ b/Descriptor/XmlDescriptor.php @@ -201,7 +201,7 @@ private function getInputOptionDocument(InputOption $option): \DOMDocument $dom->appendChild($objectXML = $dom->createElement('option')); $objectXML->setAttribute('name', '--'.$option->getName()); - $pos = strpos($option->getShortcut(), '|'); + $pos = strpos($option->getShortcut() ?? '', '|'); if (false !== $pos) { $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos)); $objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut())); diff --git a/Helper/ProgressIndicator.php b/Helper/ProgressIndicator.php index c189ba804..dc37148ed 100644 --- a/Helper/ProgressIndicator.php +++ b/Helper/ProgressIndicator.php @@ -197,7 +197,7 @@ private function display() } return $matches[0]; - }, $this->format)); + }, $this->format ?? '')); } private function determineBestFormat(): string diff --git a/Helper/Table.php b/Helper/Table.php index e7a9b6ccb..329f24082 100644 --- a/Helper/Table.php +++ b/Helper/Table.php @@ -561,7 +561,7 @@ private function buildTableRows(array $rows): TableRows if (isset($this->columnMaxWidths[$column]) && Helper::strlenWithoutDecoration($formatter, $cell) > $this->columnMaxWidths[$column]) { $cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column] * $colspan); } - if (!strstr($cell, "\n")) { + if (!strstr($cell ?? '', "\n")) { continue; } $escaped = implode("\n", array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode("\n", $cell)));