From: Guilhem Moulin <guilhem@debian.org>
Date: Tue, 11 Jan 2022 19:27:23 +0100
Subject: Avoid deprecation messages under PHP8.1.

As of php 2:8.1+91 and phpunit 9.5.11-1, `phpunit ./tests` fails with a bunch of

  Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated in /<<PKGBUILDDIR>>/Console/CommandLine.php on line …
---
 Console/CommandLine.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Console/CommandLine.php b/Console/CommandLine.php
index 9871666..cb426b7 100644
--- a/Console/CommandLine.php
+++ b/Console/CommandLine.php
@@ -1012,7 +1012,7 @@ class Console_CommandLine
     {
         $last  = $argc === 0;
         if (!$this->_stopflag && $this->_lastopt) {
-            if (strlen($token) > ($this->avoid_reading_stdin ? 1 : 0) &&
+            if ($token !== null && strlen($token) > ($this->avoid_reading_stdin ? 1 : 0) &&
                 substr($token, 0, 1) == '-') {
                 if ($this->_lastopt->argument_optional) {
                     $this->_dispatchAction($this->_lastopt, '', $result);
@@ -1053,7 +1053,7 @@ class Console_CommandLine
                 return;
             }
         }
-        if (!$this->_stopflag && substr($token, 0, 2) == '--') {
+        if (!$this->_stopflag && $token !== null && substr($token, 0, 2) == '--') {
             // a long option
             $optkv = explode('=', $token, 2);
             if (trim($optkv[0]) == '--') {
@@ -1099,7 +1099,7 @@ class Console_CommandLine
                 $this->_lastopt = $opt;
             }
             $this->_dispatchAction($opt, $value, $result);
-        } else if (!$this->_stopflag &&
+        } else if (!$this->_stopflag && $token !== null &&
                    strlen($token) > ($this->avoid_reading_stdin ? 1 : 0) &&
                    substr($token, 0, 1) == '-') {
             // a short option
