diff --git a/Descriptor/TextDescriptor.php b/Descriptor/TextDescriptor.php index ccfbd6d36..16ab3eb55 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 4931fba62..5323a3ba8 100644 --- a/Descriptor/XmlDescriptor.php +++ b/Descriptor/XmlDescriptor.php @@ -200,7 +200,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 491a537eb..2d8774201 100644 --- a/Helper/ProgressIndicator.php +++ b/Helper/ProgressIndicator.php @@ -185,7 +185,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 ee969bcff..9662f4e75 100644 --- a/Helper/Table.php +++ b/Helper/Table.php @@ -572,7 +572,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)));