This commit is contained in:
Dennis Eichhorn 2023-07-09 02:32:02 +00:00
parent acf9a247f0
commit ebbc08fe9b
19 changed files with 2506 additions and 1473 deletions

View File

@ -95,6 +95,8 @@ final class BasicOcr
}
// $magicNumber = $unpack[1];
// 2051 === image data (should always be this)
// 2049 === label data
if (($read = \fread($fp, 4)) === false || ($unpack = \unpack('N', $read)) === false) {
return []; // @codeCoverageIgnore
@ -159,7 +161,10 @@ final class BasicOcr
if (($read = \fread($fp, 4)) === false || ($unpack = \unpack('N', $read)) === false) {
return []; // @codeCoverageIgnore
}
$magicNumber = $unpack[1];
// $magicNumber = $unpack[1];
// 2051 === image data
// 2049 === label data (should always be this)
if (($read = \fread($fp, 4)) === false || ($unpack = \unpack('N', $read)) === false) {
return []; // @codeCoverageIgnore
@ -258,7 +263,7 @@ final class BasicOcr
}
\fwrite($out, \pack('N', 2051));
\fwrite($out, \pack('N', 1));
\fwrite($out, \pack('N', \count($images)));
\fwrite($out, \pack('N', $resolution));
\fwrite($out, \pack('N', $resolution));
@ -299,7 +304,7 @@ final class BasicOcr
}
for ($i = 0; $i < $size; ++$i) {
\fwrite($out, \pack('C', \round($mnist[$i] * 255)));
\fwrite($out, \pack('C', (int) \round($mnist[$i] * 255)));
}
}
@ -325,7 +330,7 @@ final class BasicOcr
}
\fwrite($out, \pack('N', 2049));
\fwrite($out, \pack('N', 1));
\fwrite($out, \pack('N', \count($data)));
foreach ($data as $e) {
\fwrite($out, \pack('C', $e));

View File

@ -81,7 +81,7 @@ final class EUVATBffOnline implements EUVATInterface
}
$result['status'] = 0;
} catch (\Throwable $t) {
} catch (\Throwable $_) {
return $result;
}
@ -151,7 +151,7 @@ final class EUVATBffOnline implements EUVATInterface
$result['name'] = $matches[1] ?? 'B';
$result['status'] = 0;
} catch (\Throwable $t) {
} catch (\Throwable $_) {
return $result;
}

View File

@ -80,7 +80,7 @@ final class EUVATVies implements EUVATInterface
$result = \array_merge($result, self::parseResponse($json));
$result['status'] = $json['userError'] === 'VALID' ? 0 : -1;
} catch (\Throwable $t) {
} catch (\Throwable $_) {
return $result;
}
@ -182,7 +182,7 @@ final class EUVATVies implements EUVATInterface
}
$result['status'] = $json['userError'] === 'VALID' ? 0 : -1;
} catch (\Throwable $t) {
} catch (\Throwable $_) {
return $result;
}

View File

@ -121,7 +121,7 @@ final class ApplicationManager
$class::install($this->app, $info, $this->app->appSettings);
return true;
} catch (\Throwable $t) {
} catch (\Throwable $_) {
return false; // @codeCoverageIgnore
}
}
@ -155,7 +155,7 @@ final class ApplicationManager
$this->uninstallFiles($source);
return true;
} catch (\Throwable $t) {
} catch (\Throwable $_) {
return false; // @codeCoverageIgnore
}
}

View File

@ -877,6 +877,9 @@ final class ReadMapper extends DataMapperAbstract
}
$objects = $objectMapper->execute();
if (empty($objects) || (!\is_array($objects) && $objects->id === 0)) {
continue;
}
if ($refClass === null) {
$refClass = new \ReflectionClass($obj);

View File

@ -1115,7 +1115,7 @@ class Email implements MessageInterface
\PKCS7_DETACHED,
$this->signExtracertFiles
);
} catch (\Throwable $t) {
} catch (\Throwable $_) {
$sign = false;
}

View File

@ -523,19 +523,19 @@ final class ModuleManager
/* Install providing but only if receiving module is already installed */
$providing = $info->getProviding();
foreach ($providing as $key => $version) {
foreach ($providing as $key => $_) {
if (isset($installed[$key])) {
$this->installProviding('/Modules/' . $module, $key);
}
}
/* Install receiving and applications */
foreach ($this->installed as $key => $value) {
foreach ($this->installed as $key => $_) {
$this->installProviding('/Modules/' . $key, $module);
}
return true;
} catch (\Throwable $t) {
} catch (\Throwable $_) {
return false; // @codeCoverageIgnore
}
}
@ -593,7 +593,7 @@ final class ModuleManager
}
return true;
} catch (\Throwable $t) {
} catch (\Throwable $_) {
return false; // @codeCoverageIgnore
}
}

View File

@ -280,4 +280,14 @@ final class FileUtils
{
return !\preg_match('#^[a-z][a-z\d+.-]*://#i', $path);
}
public static function makeSafeFileName(string $name) : string
{
$name = \preg_replace("/[^A-Za-z0-9\-_.]/", '_', $name);
$name = \preg_replace("/_+/", '_', $name);
$name = \trim($name, '_');
$name = \strtolower($name);
return $name;
}
}

View File

@ -490,7 +490,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
try {
\mkdir($path, $permission, $recursive);
} catch (\Throwable $t) {
} catch (\Throwable $_) {
return false; // @codeCoverageIgnore
}

View File

@ -2023,8 +2023,28 @@ abstract class MimeType extends Enum
{
try {
return (string) (self::getByName('M_' . \strtoupper($extension)) ?? 'application/octet-stream');
} catch (\Throwable $t) {
} catch (\Throwable $_) {
return 'application/octet-stream';
}
}
public static function mimeToExtension(string $mime) : ?string
{
switch($mime) {
case self::M_PDF:
return 'pdf';
case self::M_JPEG:
case self::M_JPG:
return 'jpg';
case self::M_BMP:
return 'bmp';
case self::M_GIF:
return 'gif';
case self::M_HTML:
case self::M_HTM:
return 'htm';
default:
return null;
}
}
}

View File

@ -122,7 +122,7 @@ final class Currency
self::$ecbCurrencies[\strtoupper((string) ($attributes['currency']))] = (float) ($attributes['rate']);
}
} catch (\Throwable $t) {
} catch (\Throwable $_) {
self::$ecbCurrencies = []; // @codeCoverageIgnore
}

View File

@ -120,7 +120,7 @@ class Tar implements ArchiveInterface
$tar->extractTo($destination . '/');
return true;
} catch (\Throwable $t) {
} catch (\Throwable $_) {
return false;
}
}

View File

@ -123,7 +123,7 @@ class Zip implements ArchiveInterface
$zip->extractTo($destination . '/');
return $zip->close();
} catch (\Throwable $t) {
} catch (\Throwable $_) {
return false;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -386,7 +386,7 @@ final class EigenvalueDecompositionTest extends \PHPUnit\Framework\TestCase
$eig = new EigenvalueDecomposition($A);
++$c;
} while (true);
} catch (\Throwable $t) {
} catch (\Throwable $_) {
var_dump($c);
var_dump($array);
}

View File

@ -54,7 +54,7 @@ final class DirectoryTest extends \PHPUnit\Framework\TestCase
if (!$mkdir || !$put) {
throw new \Exception();
}
} catch (\Throwable $t) {
} catch (\Throwable $_) {
self::$con = null;
}
}

View File

@ -56,7 +56,7 @@ final class FileTest extends \PHPUnit\Framework\TestCase
if (!$mkdir || !$put) {
throw new \Exception();
}
} catch (\Throwable $t) {
} catch (\Throwable $_) {
self::$con = null;
}
}

View File

@ -57,7 +57,7 @@ final class FtpStorageTest extends \PHPUnit\Framework\TestCase
if (!$mkdir || !$put) {
throw new \Exception();
}
} catch (\Throwable $t) {
} catch (\Throwable $_) {
self::$con = null;
}

View File

@ -42,7 +42,7 @@ final class CurrencyTest extends \PHPUnit\Framework\TestCase
Rest::request($request)->getBody();
self::$reachable = true;
} catch (\Throwable $t) {
} catch (\Throwable $_) {
self::$reachable = false;
}
}