[Console] Fixes for PHP 8.1 deprecations

This commit is contained in:
Jeremiasz Major 2021-05-10 14:53:15 +02:00
parent be480d8f97
commit 545f058367
No known key found for this signature in database
GPG Key ID: 482514409C7EBE01
4 changed files with 4 additions and 4 deletions

View File

@ -117,7 +117,7 @@ class TextDescriptor extends Descriptor
$this->writeText('<comment>Options:</comment>', $options);
foreach ($definition->getOptions() as $option) {
if (\strlen($option->getShortcut()) > 1) {
if (\strlen($option->getShortcut() ?? '') > 1) {
$laterOptions[] = $option;
continue;
}

View File

@ -201,7 +201,7 @@ class XmlDescriptor extends Descriptor
$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()));

View File

@ -197,7 +197,7 @@ class ProgressIndicator
}
return $matches[0];
}, $this->format));
}, $this->format ?? ''));
}
private function determineBestFormat(): string

View File

@ -561,7 +561,7 @@ class Table
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)));