Merge branch 'develop' of https://github.com/Orange-Management/phpOMS into develop

This commit is contained in:
Dennis Eichhorn 2021-02-06 13:47:19 +01:00
commit 244672c64e
65 changed files with 280 additions and 281 deletions

View File

@ -90,7 +90,6 @@ final class BasicOcr
throw new PathException($path); // @codeCoverageIgnore throw new PathException($path); // @codeCoverageIgnore
} }
if (($read = \fread($fp, 4)) === false || ($unpack = \unpack('N', $read)) === false) { if (($read = \fread($fp, 4)) === false || ($unpack = \unpack('N', $read)) === false) {
return []; // @codeCoverageIgnore return []; // @codeCoverageIgnore
} }
@ -105,7 +104,6 @@ final class BasicOcr
$numberOfImages = \min($numberOfImages, $limit); $numberOfImages = \min($numberOfImages, $limit);
} }
if (($read = \fread($fp, 4)) === false || ($unpack = \unpack('N', $read)) === false) { if (($read = \fread($fp, 4)) === false || ($unpack = \unpack('N', $read)) === false) {
return []; // @codeCoverageIgnore return []; // @codeCoverageIgnore
} }
@ -118,7 +116,6 @@ final class BasicOcr
$images = []; $images = [];
for ($i = 0; $i < $numberOfImages; ++$i) { for ($i = 0; $i < $numberOfImages; ++$i) {
if (($read = \fread($fp, $numberOfRows * $numberOfColumns)) === false if (($read = \fread($fp, $numberOfRows * $numberOfColumns)) === false
|| ($unpack = \unpack('C*', $read)) === false || ($unpack = \unpack('C*', $read)) === false
) { ) {
@ -153,7 +150,6 @@ final class BasicOcr
throw new PathException($path); // @codeCoverageIgnore throw new PathException($path); // @codeCoverageIgnore
} }
if (($read = \fread($fp, 4)) === false || ($unpack = \unpack('N', $read)) === false) { if (($read = \fread($fp, 4)) === false || ($unpack = \unpack('N', $read)) === false) {
return []; // @codeCoverageIgnore return []; // @codeCoverageIgnore
} }
@ -170,7 +166,6 @@ final class BasicOcr
$labels = []; $labels = [];
for ($i = 0; $i < $numberOfLabels; ++$i) { for ($i = 0; $i < $numberOfLabels; ++$i) {
if (($read = \fread($fp, 1)) === false || ($unpack = \unpack('C', $read)) === false) { if (($read = \fread($fp, 1)) === false || ($unpack = \unpack('C', $read)) === false) {
return []; // @codeCoverageIgnore return []; // @codeCoverageIgnore
} }

View File

@ -1413,7 +1413,7 @@ class Builder extends BuilderAbstract
$sth->execute(); $sth->execute();
} catch (\Throwable $t) { } catch (\Throwable $t) {
var_dump($this->toSql()); \var_dump($this->toSql());
} }
return $sth; return $sth;

View File

@ -20,11 +20,11 @@ declare(strict_types=1);
namespace phpOMS\Message\Mail; namespace phpOMS\Message\Mail;
use phpOMS\System\CharsetType; use phpOMS\System\CharsetType;
use phpOMS\System\MimeType;
use phpOMS\Validation\Network\Email as EmailValidator;
use phpOMS\System\File\FileUtils; use phpOMS\System\File\FileUtils;
use phpOMS\Utils\MbStringUtils; use phpOMS\System\MimeType;
use phpOMS\System\SystemUtils; use phpOMS\System\SystemUtils;
use phpOMS\Utils\MbStringUtils;
use phpOMS\Validation\Network\Email as EmailValidator;
/** /**
* Mail class. * Mail class.
@ -591,7 +591,7 @@ class Email implements MessageInterface
$list = \explode(',', $addrstr); $list = \explode(',', $addrstr);
foreach ($list as $address) { foreach ($list as $address) {
$address = trim($address); $address = \trim($address);
if (\strpos($address, '<') === false) { if (\strpos($address, '<') === false) {
if (EmailValidator::isValid($address)) { if (EmailValidator::isValid($address)) {
$addresses[] = [ $addresses[] = [
@ -670,7 +670,7 @@ class Email implements MessageInterface
$this->bodyMime $this->bodyMime
); );
$this->headerMime = rtrim($this->headerMime, " \r\n\t") . self::$LE . $this->headerMime = \rtrim($this->headerMime, " \r\n\t") . self::$LE .
self::normalizeBreaks($headerDkim, self::$LE) . self::$LE; self::normalizeBreaks($headerDkim, self::$LE) . self::$LE;
} }
@ -876,7 +876,7 @@ class Email implements MessageInterface
$domain = \mb_convert_encoding($domain, 'UTF-8', $charset); $domain = \mb_convert_encoding($domain, 'UTF-8', $charset);
$errorcode = 0; $errorcode = 0;
if (defined('INTL_IDNA_VARIANT_UTS46')) { if (\defined('INTL_IDNA_VARIANT_UTS46')) {
$punycode = \idn_to_ascii($domain, $errorcode, \INTL_IDNA_VARIANT_UTS46); $punycode = \idn_to_ascii($domain, $errorcode, \INTL_IDNA_VARIANT_UTS46);
} else { } else {
$punycode = \idn_to_ascii($domain, $errorcode); $punycode = \idn_to_ascii($domain, $errorcode);
@ -1085,7 +1085,7 @@ class Email implements MessageInterface
} }
if (!empty($this->signKeyFile)) { if (!empty($this->signKeyFile)) {
if (!defined('PKCS7_TEXT')) { if (!\defined('PKCS7_TEXT')) {
return ''; return '';
} }
@ -1104,7 +1104,7 @@ class Email implements MessageInterface
'file://' . \realpath($this->signCertFile), 'file://' . \realpath($this->signCertFile),
['file://' . \realpath($this->signKeyFile), $this->signKeyPass], ['file://' . \realpath($this->signKeyFile), $this->signKeyPass],
[], [],
PKCS7_DETACHED, \PKCS7_DETACHED,
$this->signExtracertFiles $this->signExtracertFiles
); );
@ -1317,7 +1317,7 @@ class Email implements MessageInterface
private function encodeString(string $str, string $encoding = EncodingType::E_BASE64) : string private function encodeString(string $str, string $encoding = EncodingType::E_BASE64) : string
{ {
$encoded = ''; $encoded = '';
switch (strtolower($encoding)) { switch (\strtolower($encoding)) {
case EncodingType::E_BASE64: case EncodingType::E_BASE64:
$encoded = \chunk_split(\base64_encode($str), self::STD_LINE_LENGTH, self::$LE); $encoded = \chunk_split(\base64_encode($str), self::STD_LINE_LENGTH, self::$LE);
break; break;
@ -1406,7 +1406,6 @@ class Email implements MessageInterface
return false; return false;
} }
/** /**
* Create address list * Create address list
* *
@ -1424,7 +1423,7 @@ class Email implements MessageInterface
$addresses[] = $this->addrFormat($address); $addresses[] = $this->addrFormat($address);
} }
return $type . ': ' . implode(', ', $addresses) . static::$LE; return $type . ': ' . \implode(', ', $addresses) . static::$LE;
} }
/** /**
@ -1582,7 +1581,7 @@ class Email implements MessageInterface
return $str === $encoded && !\preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str) return $str === $encoded && !\preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)
? $encoded ? $encoded
: "\"$encoded\""; : "\"${encoded}\"";
} }
$matchcount = \preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); $matchcount = \preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
@ -1628,13 +1627,13 @@ class Email implements MessageInterface
$maxLen -= $maxLen % 4; $maxLen -= $maxLen % 4;
$encoded = \trim(\chunk_split($encoded, $maxLen, "\n")); $encoded = \trim(\chunk_split($encoded, $maxLen, "\n"));
} }
$encoded = \preg_replace('/^(.*)$/m', ' =?' . $charset . "?$encoding?\\1?=", $encoded); $encoded = \preg_replace('/^(.*)$/m', ' =?' . $charset . "?${encoding}?\\1?=", $encoded);
break; break;
case 'Q': case 'Q':
$encoded = $this->encodeQ($str, $position); $encoded = $this->encodeQ($str, $position);
$encoded = $this->wrapText($encoded, $maxLen, true); $encoded = $this->wrapText($encoded, $maxLen, true);
$encoded = \str_replace('=' . self::$LE, "\n", \trim($encoded)); $encoded = \str_replace('=' . self::$LE, "\n", \trim($encoded));
$encoded = \preg_replace('/^(.*)$/m', ' =?' . $charset . "?$encoding?\\1?=", $encoded); $encoded = \preg_replace('/^(.*)$/m', ' =?' . $charset . "?${encoding}?\\1?=", $encoded);
break; break;
default: default:
return $str; return $str;
@ -1732,7 +1731,6 @@ class Email implements MessageInterface
return \substr($encoded, 0, -\strlen($linebreak)); return \substr($encoded, 0, -\strlen($linebreak));
} }
/** /**
* Add an attachment from a path on the filesystem. * Add an attachment from a path on the filesystem.
* *
@ -2181,7 +2179,7 @@ class Email implements MessageInterface
*/ */
public function dkimSign(string $signHeader) : string public function dkimSign(string $signHeader) : string
{ {
if (!defined('PKCS7_TEXT')) { if (!\defined('PKCS7_TEXT')) {
return ''; return '';
} }

View File

@ -18,10 +18,10 @@ declare(strict_types=1);
namespace phpOMS\Message\Mail; namespace phpOMS\Message\Mail;
use phpOMS\Validation\Network\Email as EmailValidator;
use phpOMS\Utils\StringUtils;
use phpOMS\Validation\Network\Hostname;
use phpOMS\System\SystemUtils; use phpOMS\System\SystemUtils;
use phpOMS\Utils\StringUtils;
use phpOMS\Validation\Network\Email as EmailValidator;
use phpOMS\Validation\Network\Hostname;
/** /**
* Mail class. * Mail class.
@ -540,7 +540,7 @@ class MailHandler
} }
//Do we need the OpenSSL extension? //Do we need the OpenSSL extension?
$sslExt = defined('OPENSSL_ALGO_SHA256'); $sslExt = \defined('OPENSSL_ALGO_SHA256');
if (($secure === EncryptionType::TLS || $secure === EncryptionType::SMTPS) if (($secure === EncryptionType::TLS || $secure === EncryptionType::SMTPS)
&& !$sslExt && !$sslExt
) { ) {

View File

@ -210,7 +210,7 @@ class Smtp
} }
$crypto_method = \STREAM_CRYPTO_METHOD_TLS_CLIENT; $crypto_method = \STREAM_CRYPTO_METHOD_TLS_CLIENT;
if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { if (\defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
$crypto_method |= \STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; $crypto_method |= \STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
$crypto_method |= \STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; $crypto_method |= \STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
} }
@ -342,7 +342,7 @@ class Smtp
// Creates an md5 HMAC. // Creates an md5 HMAC.
// by Lance Rushing // by Lance Rushing
$byteLen = 64; $byteLen = 64;
if (strlen($key) > $byteLen) { if (\strlen($key) > $byteLen) {
$key = \pack('H*', \md5($key)); $key = \pack('H*', \md5($key));
} }
@ -392,7 +392,7 @@ class Smtp
$this->heloRply = ''; $this->heloRply = '';
if (\is_resource($this->con)) { if (\is_resource($this->con)) {
fclose($this->con); \fclose($this->con);
$this->con = null; $this->con = null;
} }
} }
@ -703,7 +703,7 @@ class Smtp
*/ */
public function sendAndMail(string $from) : bool public function sendAndMail(string $from) : bool
{ {
return $this->sendCommand('SAML', "SAML FROM:$from", 250); return $this->sendCommand('SAML', "SAML FROM:${from}", 250);
} }
/** /**
@ -717,7 +717,7 @@ class Smtp
*/ */
public function verify(string $name) : bool public function verify(string $name) : bool
{ {
return $this->sendCommand('VRFY', "VRFY $name", [250, 251]); return $this->sendCommand('VRFY', "VRFY ${name}", [250, 251]);
} }
/** /**

View File

@ -14,15 +14,15 @@ declare(strict_types=1);
namespace phpOMS\Module; namespace phpOMS\Module;
use phpOMS\Application\ApplicationInfo;
use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\System\File\Local\Directory; use phpOMS\System\File\Local\Directory;
use phpOMS\System\File\Local\File; use phpOMS\System\File\Local\File;
use phpOMS\System\File\PathException; use phpOMS\System\File\PathException;
use phpOMS\System\File\PermissionException; use phpOMS\System\File\PermissionException;
use phpOMS\Utils\Parser\Php\ArrayParser;
use phpOMS\Application\ApplicationInfo;
use phpOMS\Utils\ArrayUtils; use phpOMS\Utils\ArrayUtils;
use phpOMS\Utils\Parser\Php\ArrayParser;
/** /**
* Status abstract class. * Status abstract class.

View File

@ -694,7 +694,7 @@ class Directory extends FileAbstract implements DirectoryInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function next() public function next() : void
{ {
$next = \next($this->nodes); $next = \next($this->nodes);
if ($next instanceof self) { if ($next instanceof self) {

View File

@ -517,7 +517,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function next() public function next() : void
{ {
$next = \next($this->nodes); $next = \next($this->nodes);
if ($next instanceof self) { if ($next instanceof self) {

View File

@ -138,7 +138,7 @@ final class SystemUtils
{ {
if (isset($_SERVER['SERVER_NAME'])) { if (isset($_SERVER['SERVER_NAME'])) {
return $_SERVER['SERVER_NAME']; return $_SERVER['SERVER_NAME'];
} elseif (($result = gethostname()) !== false) { } elseif (($result = \gethostname()) !== false) {
return $result; return $result;
} elseif (\php_uname('n') !== false) { } elseif (\php_uname('n') !== false) {
return \php_uname('n'); return \php_uname('n');

View File

@ -412,7 +412,7 @@ final class StringUtils
public static function isShellSafe(string $string) public static function isShellSafe(string $string)
{ {
if (\escapeshellcmd($string) !== $string if (\escapeshellcmd($string) !== $string
|| !\in_array(\escapeshellarg($string), ["'$string'", "\"$string\""]) || !\in_array(\escapeshellarg($string), ["'${string}'", "\"${string}\""])
) { ) {
return false; return false;
} }

View File

@ -21,7 +21,9 @@ require_once __DIR__ . '/../../Autoloader.php';
class NumericElement implements SortableInterface class NumericElement implements SortableInterface
{ {
public int|float $value = 0; public int |
float $value = 0;
public function __construct(int | float $value) public function __construct(int | float $value)
{ {

View File

@ -44,7 +44,7 @@ class ApplicationManagerTest extends \PHPUnit\Framework\TestCase
$app->dbPool = $GLOBALS['dbpool']; $app->dbPool = $GLOBALS['dbpool'];
$app->router = new WebRouter(); $app->router = new WebRouter();
$app->dispatcher = new Dispatcher($app); $app->dispatcher = new Dispatcher($app);
$app->appSettings = new class implements SettingsInterface { $app->appSettings = new class() implements SettingsInterface {
use OptionsTrait; use OptionsTrait;
public function get( public function get(

View File

@ -14,8 +14,8 @@ declare(strict_types=1);
namespace phpOMS\tests\DataStorage\Cache\Connection; namespace phpOMS\tests\DataStorage\Cache\Connection;
use phpOMS\DataStorage\Cache\CacheType;
use phpOMS\DataStorage\Cache\CacheStatus; use phpOMS\DataStorage\Cache\CacheStatus;
use phpOMS\DataStorage\Cache\CacheType;
use phpOMS\DataStorage\Cache\Connection\NullCache; use phpOMS\DataStorage\Cache\Connection\NullCache;
/** /**

View File

@ -19,9 +19,9 @@ use phpOMS\Dispatcher\Dispatcher;
use phpOMS\Localization\Localization; use phpOMS\Localization\Localization;
use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\HttpResponse;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Router\WebRouter; use phpOMS\Router\WebRouter;
use phpOMS\Uri\HttpUri; use phpOMS\Uri\HttpUri;
use phpOMS\Module\ModuleAbstract;
require_once __DIR__ . '/../Autoloader.php'; require_once __DIR__ . '/../Autoloader.php';
@ -56,7 +56,11 @@ class DispatcherTest extends \PHPUnit\Framework\TestCase
public function testControllerInputOutput() : void public function testControllerInputOutput() : void
{ {
$this->app->dispatcher->set(new class extends ModuleAbstract { public string $name = 'test'; public function testFunction() { return $this->name; } }, 'test'); $this->app->dispatcher->set(new class() extends ModuleAbstract {
public string $name = 'test';
public function testFunction() { return $this->name; }
}, 'test');
$localization = new Localization(); $localization = new Localization();

View File

@ -28,7 +28,7 @@ class EmailTestTest extends \PHPUnit\Framework\TestCase
{ {
protected Email $mail; protected Email $mail;
public function setUp() : void protected function setUp() : void
{ {
$this->mail = new Email(); $this->mail = new Email();
} }

View File

@ -16,10 +16,10 @@ namespace phpOMS\tests\Message;
require_once __DIR__ . '/../../Autoloader.php'; require_once __DIR__ . '/../../Autoloader.php';
use phpOMS\Message\Mail\MailHandler;
use phpOMS\Message\Mail\SubmitType;
use phpOMS\Message\Mail\Email; use phpOMS\Message\Mail\Email;
use phpOMS\Message\Mail\Imap; use phpOMS\Message\Mail\Imap;
use phpOMS\Message\Mail\MailHandler;
use phpOMS\Message\Mail\SubmitType;
use phpOMS\System\CharsetType; use phpOMS\System\CharsetType;
/** /**
@ -31,7 +31,7 @@ class MailHandlerTest extends \PHPUnit\Framework\TestCase
{ {
protected MailHandler $handler; protected MailHandler $handler;
public function setUp() : void protected function setUp() : void
{ {
$this->handler = new MailHandler(); $this->handler = new MailHandler();
} }