getopts: substr in PHP7 has not the same result as PHP5.

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3807 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2017-07-12 07:55:09 +00:00
parent c3429858af
commit 583db6300e

View File

@@ -88,7 +88,8 @@ class getopts
else
$long = array ();
}
if (substr ($short, 0, 1) !== false && $short[0] === ":")
if (substr ($short, 0, 1) !== false && substr ($short, 0, 1) !== "" &&
$short[0] === ":")
throw new \Exception ("Short option can't start by semi-colon", 500);
if ((strpos ($short, ":") !== false ||
strpos (implode ($long), ":") !== false) &&
@@ -109,7 +110,8 @@ class getopts
$short = $matches[0];
foreach ($short as $key=>$s)
{
if (substr ($s, 1) !== false && substr ($s, 1) !== ":")
if (substr ($s, 1) !== false && substr ($s, 1) !== ":" &&
substr ($s, 1) !== "")
throw new \Exception (
"Short parameter is invalid : only one letter allowed", 500);
$short[$key] = "-".$s;