fixed various exception docblocks

This commit is contained in:
Dennis Eichhorn 2023-08-06 20:17:43 +00:00
parent e91e5fd405
commit d36e96cb85
94 changed files with 597 additions and 178 deletions

View File

@ -77,6 +77,8 @@ final class BasicOcr
*
* @return array
*
* @throws PathException
*
* @since 1.0.0
*/
private function readImages(string $path, int $limit = 0) : array
@ -145,6 +147,8 @@ final class BasicOcr
*
* @return array
*
* @throws PathException
*
* @since 1.0.0
*/
private function readLabels(string $path, int $limit = 0) : array

View File

@ -503,6 +503,8 @@ final class JumpPointSearch implements PathFinderInterface
*
* @return null|JumpPointNode
*
* @throws \Exception
*
* @since 1.0.0
*/
private static function jumpStraight(?JumpPointNode $node, ?JumpPointNode $pNode, JumpPointNode $endNode, Grid $grid) : ?JumpPointNode

View File

@ -96,6 +96,8 @@ final class ApplicationInfo
*
* @return void
*
* @throws PathException
*
* @since 1.0.0
*/
public function update() : void
@ -116,6 +118,8 @@ final class ApplicationInfo
*
* @return void
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public function set(string $path, mixed $data, string $delim = '/') : void

View File

@ -66,6 +66,8 @@ final class ApplicationManager
*
* @return ApplicationInfo
*
* @throws PathException
*
* @since 1.0.0
*/
private function loadInfo(string $appPath) : ApplicationInfo
@ -117,7 +119,7 @@ final class ApplicationManager
$classPath = \substr($path . '/Admin/Installer', (int) \strlen((string) \realpath(__DIR__ . '/../../')));
// @var class-string<InstallerAbstract> $class
$class = \str_replace('/', '\\', $classPath);
$class = \strtr($classPath, '/', '\\');
$class::install($this->app, $info, $this->app->appSettings);
return true;
@ -149,7 +151,7 @@ final class ApplicationManager
$classPath = \substr($path . '/Admin/Uninstaller', (int) \strlen((string) \realpath(__DIR__ . '/../../')));
// @var class-string<UninstallerAbstract> $class
$class = \str_replace('/', '\\', $classPath);
$class = \strtr($classPath, '/', '\\');
$class::uninstall($this->app->dbPool, $info, $this->app->appSettings);
$this->uninstallFiles($source);
@ -182,7 +184,7 @@ final class ApplicationManager
// @var class-string<InstallerAbstract> $class
$classPath = \substr($path . '/Admin/Installer', (int) \strlen((string) \realpath(__DIR__ . '/../../')));
$class = \str_replace('/', '\\', $classPath);
$class = \strtr($classPath, '/', '\\');
/** @var $class InstallerAbstract */
$class::reInit($info);

View File

@ -134,6 +134,8 @@ abstract class InstallerAbstract
*
* @return void
*
* @throws \UnexpectedValueException
*
* @since 1.0.0
*/
protected static function activate(ApplicationAbstract $app, ApplicationInfo $info) : void
@ -145,7 +147,7 @@ abstract class InstallerAbstract
$classPath = \substr($path . '/Status', (int) \strlen((string) \realpath(__DIR__ . '/../../')));
// @var class-string<StatusAbstract> $class
$class = \str_replace('/', '\\', $classPath);
$class = \strtr($classPath, '/', '\\');
if (!Autoloader::exists($class)) {
throw new \UnexpectedValueException($class); // @codeCoverageIgnore
@ -161,6 +163,8 @@ abstract class InstallerAbstract
*
* @return void
*
* @throws \UnexpectedValueException
*
* @since 1.0.0
*/
public static function reInit(ApplicationInfo $info) : void
@ -172,7 +176,7 @@ abstract class InstallerAbstract
$classPath = \substr($path . '/Status', (int) \strlen((string) \realpath(__DIR__ . '/../../')));
// @var class-string<StatusAbstract> $class
$class = \str_replace('/', '\\', $classPath);
$class = \strtr($classPath, '/', '\\');
if (!Autoloader::exists($class)) {
throw new \UnexpectedValueException($class); // @codeCoverageIgnore

View File

@ -61,8 +61,6 @@ abstract class StatusAbstract
*
* @return void
*
* @throws PermissionException
*
* @since 1.0.0
*/
public static function activateRoutes(ApplicationInfo $appInfo = null) : void
@ -77,8 +75,6 @@ abstract class StatusAbstract
*
* @return void
*
* @throws PermissionException
*
* @since 1.0.0
*/
public static function activateHooks(ApplicationInfo $appInfo = null) : void
@ -94,6 +90,7 @@ abstract class StatusAbstract
*
* @return void
*
* @throws PathException
* @throws PermissionException
*
* @since 1.0.0
@ -131,9 +128,6 @@ abstract class StatusAbstract
*
* @return void
*
* @throws PathException
* @throws PermissionException
*
* @since 1.0.0
*/
public static function clearRoutes() : void
@ -146,9 +140,6 @@ abstract class StatusAbstract
*
* @return void
*
* @throws PathException
* @throws PermissionException
*
* @since 1.0.0
*/
public static function clearHooks() : void

View File

@ -68,7 +68,7 @@ abstract class UninstallerAbstract
{
$classPath = \substr(\realpath(static::PATH) . '/Status', \strlen(\realpath(__DIR__ . '/../../')));
$class = \str_replace('/', '\\', $classPath);
$class = \strtr($classPath, '/', '\\');
$class::deactivate($dbPool, $info);
}*/

View File

@ -87,7 +87,7 @@ final class Autoloader
{
$found = [];
$class = \ltrim($class, '\\');
$class = \str_replace(['_', '\\'], '/', $class);
$class = \strtr($class, '_\\', '//');
foreach (self::$paths as $path) {
if (\is_file($file = $path . $class . '.php')) {
@ -107,14 +107,12 @@ final class Autoloader
*
* @return void
*
* @throws AutoloadException Throws this exception if the class to autoload doesn't exist. This could also be related to a wrong namespace/file path correlation.
*
* @since 1.0.0
*/
public static function defaultAutoloader(string $class) : void
{
$class = \ltrim($class, '\\');
$class = \str_replace(['_', '\\'], '/', $class);
$class = \strtr($class, '_\\', '//');
foreach (self::$paths as $path) {
if (\is_file($file = $path . $class . '.php')) {
@ -139,7 +137,7 @@ final class Autoloader
public static function exists(string $class) : bool
{
$class = \ltrim($class, '\\');
$class = \str_replace(['_', '\\'], '/', $class);
$class = \strtr($class, '_\\', '//');
foreach (self::$paths as $path) {
if (\is_file($path . $class . '.php')) {

View File

@ -87,6 +87,12 @@ final class FileCache extends ConnectionAbstract
* Connect to cache
*
* @param null|array{0:string} $data Cache data (path to cache directory)
*
* @return void
*
* @throws InvalidConnectionConfigException
*
* @since 1.0.0
*/
public function connect(array $data = null) : void
{

View File

@ -70,6 +70,8 @@ final class MemCached extends ConnectionAbstract
*
* @return void
*
* @throws InvalidConnectionConfigException
*
* @since 1.0.0
*/
public function connect(array $data = null) : void
@ -88,6 +90,8 @@ final class MemCached extends ConnectionAbstract
/**
* {@inheritdoc}
*
* @throws \InvalidArgumentException
*/
public function set(int | string $key, mixed $value, int $expire = -1) : void
{
@ -104,6 +108,8 @@ final class MemCached extends ConnectionAbstract
/**
* {@inheritdoc}
*
* @throws \InvalidArgumentException
*/
public function add(int | string $key, mixed $value, int $expire = -1) : bool
{

View File

@ -62,6 +62,8 @@ final class RedisCache extends ConnectionAbstract
*
* @return void
*
* @throws InvalidConnectionConfigException
*
* @since 1.0.0
*/
public function connect(array $data = null) : void

View File

@ -80,7 +80,7 @@ final class MysqlConnection extends ConnectionAbstract
$this->con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$this->status = DatabaseStatus::OK;
} catch (\PDOException $e) {
} catch (\PDOException $_) {
$this->con = new NullPDO();
$this->status = DatabaseStatus::MISSING_DATABASE;
} finally {

View File

@ -80,7 +80,7 @@ final class PostgresConnection extends ConnectionAbstract
$this->con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$this->status = DatabaseStatus::OK;
} catch (\PDOException $e) {
} catch (\PDOException $_) {
$this->con = new NullPDO();
$this->status = DatabaseStatus::MISSING_DATABASE;
} finally {

View File

@ -62,6 +62,8 @@ final class SQLiteConnection extends ConnectionAbstract
*
* @return void
*
* @throws \PDOException
*
* @since 1.0.0
*/
public function connect(array $dbdata = null) : void
@ -90,7 +92,7 @@ final class SQLiteConnection extends ConnectionAbstract
$this->con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$this->status = DatabaseStatus::OK;
} catch (\PDOException $e) {
} catch (\PDOException $_) {
$this->con = new NullPDO();
$this->status = DatabaseStatus::MISSING_DATABASE;
} finally {

View File

@ -80,7 +80,7 @@ final class SqlServerConnection extends ConnectionAbstract
$this->con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$this->status = DatabaseStatus::OK;
} catch (\PDOException $e) {
} catch (\PDOException $_) {
$this->con = new NullPDO();
$this->status = DatabaseStatus::MISSING_DATABASE;
} finally {

View File

@ -186,6 +186,8 @@ abstract class GrammarAbstract
*
* @return string
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
protected function expressionizeTableColumn(array $elements, bool $column = true) : string

View File

@ -220,6 +220,8 @@ final class UpdateMapper extends DataMapperAbstract
*
* @return void
*
* @throws InvalidMapperException
*
* @since 1.0.0
*/
private function updateHasMany(\ReflectionClass $refClass, object $obj, mixed $objId) : void

View File

@ -254,6 +254,8 @@ final class WriteMapper extends DataMapperAbstract
*
* @return void
*
* @throws InvalidMapperException
*
* @since 1.0.0
*/
private function createHasMany(\ReflectionClass $refClass, object $obj, mixed $objId) : void

View File

@ -269,6 +269,8 @@ class Builder extends BuilderAbstract
*
* @return Builder
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public function select(mixed ...$columns) : self
@ -488,6 +490,8 @@ class Builder extends BuilderAbstract
*
* @return Builder
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public function from(mixed ...$tables) : self
@ -655,6 +659,8 @@ class Builder extends BuilderAbstract
*
* @return Builder
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public function groupBy(mixed ...$columns) : self
@ -1026,6 +1032,7 @@ class Builder extends BuilderAbstract
* @return Builder
*
* @throws \Exception
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
@ -1296,6 +1303,8 @@ class Builder extends BuilderAbstract
*
* @return Builder
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public function on(string | array $columns, string | array $operator = null, mixed $values = null, string | array $boolean = 'and', string $table = null) : self

View File

@ -37,6 +37,8 @@ class Grammar extends GrammarAbstract
{
/**
* {@inheritdoc}
*
* @throws \InvalidArgumentException
*/
protected function compileComponents(BuilderAbstract $query) : array
{

View File

@ -16,6 +16,8 @@ namespace phpOMS\DataStorage\Session;
use phpOMS\DataStorage\LockException;
use phpOMS\Log\FileLogger;
use phpOMS\Message\RequestAbstract;
use phpOMS\Session\JWT;
use phpOMS\Uri\UriFactory;
/**
@ -69,8 +71,6 @@ final class HttpSession implements SessionInterface
* @param string $sid Session id
* @param int $inactivityInterval Interval for session activity
*
* @throws LockException throws this exception if the session is alrady locked for further interaction
*
* @since 1.0.0
*/
public function __construct(int $liftetime = 3600, string $sid = '', int $inactivityInterval = 0)
@ -141,6 +141,29 @@ final class HttpSession implements SessionInterface
UriFactory::setQuery('$CSRF', $csrf); /* @phpstan-ignore-line */
}
public function populateFromRequest(string $secret, RequestAbstract $request) : void
{
$authentication = $request->header->get('Authorization');
if (\count($authentication) !== 1) {
return;
}
$explode = \explode(' ', $authentication[0]);
if (\count($explode) !== 2) {
return;
}
$token = \trim($explode[1]);
$header = JWT::getHeader($token);
if (($header['typ'] ?? '') !== 'jwt' || !JWT::validateJWT($secret, $token)) {
return;
}
$payload = JWT::getPayload($token);
$this->set('UID', (int) ($payload['uid'] ?? 0));
}
/**
* {@inheritdoc}
*/

134
DataStorage/Session/JWT.php Normal file
View File

@ -0,0 +1,134 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package phpOMS\Auth
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace phpOMS\Session;
use phpOMS\Utils\Encoding\Base64Url;
/**
* JWT class.
*
* Creates, parses and validates JWT tokens.
*
* Header: base64url([algo: ..., typ: jwt])
* Payload: base64url([...])
* Signature: hmac(Header . Payload, secret)
*
* @package phpOMS\Auth
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class JWT
{
/**
* Create JWT signature part
*
* @param string $secret Secret (at least 256 bit)
* @var array{alg:string, typ:string} $header Header
* @var array{sub:string, ?uid:string, ?name:string, iat:string} $payload Payload
*
* @return string hmac(Header64 . Payload64, secret)
*
* @since 1.0.0
*/
private static function createSignature(string $secret, array $header, array $payload) : string
{
$header64 = Base64Url::encode(\json_encode($header));
$payload64 = Base64Url::encode(\json_encode($payload));
$algorithm = '';
switch (\strtolower($header['alg'])) {
default:
$algorithm = 'sha256';
}
return \hash_hmac($algorithm, $header64 . '.' . $payload64, $secret, false);
}
/**
* Create JWT token
*
* @param string $secret Secret (at least 256 bit)
* @var array{alg:string, typ:string} $header Header
* @var array{sub:string, ?uid:string, ?name:string, iat:string} $payload Payload
*
* @return string Header64 . Payload64 . hmac(Header64 . Payload64, secret)
*/
public static function createJWT(string $secret, array $header = [], array $payload = []) : string
{
$header64 = Base64Url::encode(\json_encode($header));
$payload64 = Base64Url::encode(\json_encode($payload));
$signature = self::createSignature($secret, $header, $payload);
return $header64 . $payload64 . Base64Url::encode($signature);
}
public static function getHeader(string $jwt) : array
{
$explode = \explode('.', $jwt);
if ($explode !== 3) {
return [];
}
try {
return \json_decode(Base64Url::decode($explode[0]), true);
} catch (\Throwable $_) {
return [];
}
}
public static function getPayload(string $jwt) : array
{
$explode = \explode('.', $jwt);
if ($explode !== 3) {
return [];
}
try {
return \json_decode(Base64Url::decode($explode[1]), true);
} catch (\Throwable $_) {
return [];
}
}
/**
* Validate JWT token integrity
*
* @param string $secret Secret (at least 256 bit)
* @param string $jwt JWT token [Header64 . Payload64 . hmac(Header64 . Payload64, secret)]
*
* @return bool
*/
public static function validateJWT(string $secret, string $jwt) : bool
{
$explode = \explode('.', $jwt);
if ($explode !== 3) {
return false;
}
try {
$header = \json_decode(Base64Url::decode($explode[0]), true);
$payload = \json_decode(Base64Url::decode($explode[1]), true);
$signature = self::createSignature($secret, $header, $payload);
return \hash_equals($signature, $explode[2]);
} catch (\Throwable $_) {
return false;
}
}
}

View File

@ -63,8 +63,6 @@ final class L11nManager
*
* @return void
*
* @throws \UnexpectedValueException this exception is thrown when no language definitions for the defined source `$from` exist
*
* @since 1.0.0
*/
public function loadLanguage(string $language, string $from, array $translation) : void

View File

@ -38,6 +38,8 @@ class Language extends NgramParser
* @param array $lang List of ISO 639-1 codes, that should be used in the detection phase
* @param string $dirname Name of the directory where the translations files are located
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public function __construct(array $lang = [], string $dirname = '')

View File

@ -31,6 +31,8 @@ class Trainer extends NgramParser
*
* @return void
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public function learn(string $dirname = '') : void

View File

@ -606,6 +606,8 @@ class Localization implements \JsonSerializable
*
* @return void
*
* @throws InvalidEnumValue
*
* @since 1.0.0
*/
public function setTemperature(string $temperature) : void

View File

@ -355,6 +355,8 @@ final class FileLogger implements LoggerInterface
/**
* {@inheritdoc}
*
* @throws InvalidEnumValue
*/
public function log(string $level, string $message, array $context = []) : void
{

View File

@ -239,6 +239,9 @@ final class LUDecomposition
*
* @return Matrix
*
* @throws InvalidDimensionException
* @throws \Exception
*
* @since 1.0.0
*/
public function solve(Matrix $B) : Matrix

View File

@ -368,8 +368,6 @@ class Matrix implements \ArrayAccess, \Iterator
*
* @return Matrix
*
* @throws \Exception
*
* @since 1.0.0
*/
public function setMatrix(array $matrix) : self
@ -424,6 +422,8 @@ class Matrix implements \ArrayAccess, \Iterator
*
* @return Matrix
*
* @throws InvalidDimensionException
*
* @since 1.0.0
*/
private function addMatrix(self $matrix) : self
@ -521,6 +521,8 @@ class Matrix implements \ArrayAccess, \Iterator
*
* @return Matrix
*
* @throws InvalidDimensionException
*
* @since 1.0.0
*/
private function multMatrix(self $matrix) : self

View File

@ -206,6 +206,9 @@ final class QRDecomposition
*
* @return Matrix
*
* @throws InvalidDimensionException
* @throws \Exception
*
* @since 1.0.0
*/
public function solve(Matrix $B) : Matrix

View File

@ -376,8 +376,6 @@ final class Complex
*
* @return Complex
*
* @throws \InvalidArgumentException This exception is thrown if the argument has an invalid type
*
* @since 1.0.0
*/
public function div(int | float | self $value) : self

View File

@ -148,7 +148,7 @@ final class Integer
*
* @return int[]
*
* @throws \Exception This exception is thrown if the value is not odd
* @throws \InvalidArgumentException This exception is thrown if the value is not odd
*
* @since 1.0.0
*/

View File

@ -31,8 +31,6 @@ final class Evaluator
*
* @return null|float
*
* @throws \Exception
*
* @since 1.0.0
*/
public static function evaluate(string $equation) : ?float

View File

@ -337,6 +337,8 @@ final class Average
*
* @return float
*
* @throws ZeroDivisionException
*
* @since 1.0.0
*/
public static function angleMean(array $angles, int $offset = 0) : float
@ -376,6 +378,8 @@ final class Average
*
* @return float
*
* @throws ZeroDivisionException
*
* @since 1.0.0
*/
public static function angleMean2(array $angles, int $offset = 0) : float

View File

@ -28,6 +28,8 @@ final class LevelLogRegression extends RegressionAbstract
{
/**
* {@inheritdoc}
*
* @throws InvalidDimensionException
*/
public static function getRegression(array $x, array $y) : array
{

View File

@ -28,6 +28,8 @@ final class LogLevelRegression extends RegressionAbstract
{
/**
* {@inheritdoc}
*
* @throws InvalidDimensionException
*/
public static function getRegression(array $x, array $y) : array
{

View File

@ -28,6 +28,8 @@ final class LogLogRegression extends RegressionAbstract
{
/**
* {@inheritdoc}
*
* @throws InvalidDimensionException
*/
public static function getRegression(array $x, array $y) : array
{

View File

@ -265,7 +265,6 @@ final class MeasureOfDispersion
* @return float
*
* @throws ZeroDivisionException This exception is thrown if the size of the x array is less than 2
* @throws InvalidDimensionException This exception is thrown if x and y have different dimensions
*
* @since 1.0.0
*/

View File

@ -201,6 +201,8 @@ final class Metrics2D
*
* @return int
*
* @throws InvalidDimensionException
*
* @since 1.0.0
*/
public static function hamming(array $a, array $b) : int
@ -231,6 +233,8 @@ final class Metrics2D
*
* @return int
*
* @throws InvalidDimensionException
*
* @since 1.0.0
*/
public static function ulam(array $a, array $b) : int

View File

@ -47,6 +47,8 @@ final class MetricsND
*
* @return float
*
* @throws InvalidDimensionException
*
* @since 1.0.0
*/
public static function manhattan(array $a, array $b) : float
@ -73,6 +75,8 @@ final class MetricsND
*
* @return float
*
* @throws InvalidDimensionException
*
* @since 1.0.0
*/
public static function euclidean(array $a, array $b) : float
@ -99,6 +103,8 @@ final class MetricsND
*
* @return float
*
* @throws InvalidDimensionException
*
* @since 1.0.0
*/
public static function chebyshev(array $a, array $b) : float
@ -126,6 +132,8 @@ final class MetricsND
*
* @return float
*
* @throws InvalidDimensionException
*
* @since 1.0.0
*/
public static function minkowski(array $a, array $b, int $lambda) : float
@ -152,6 +160,8 @@ final class MetricsND
*
* @return float
*
* @throws InvalidDimensionException
*
* @since 1.0.0
*/
public static function canberra(array $a, array $b) : float
@ -178,6 +188,8 @@ final class MetricsND
*
* @return float
*
* @throws InvalidDimensionException
*
* @since 1.0.0
*/
public static function brayCurtis(array $a, array $b) : float
@ -206,6 +218,8 @@ final class MetricsND
*
* @return float
*
* @throws InvalidDimensionException
*
* @since 1.0.0
*/
public static function angularSeparation(array $a, array $b) : float
@ -236,6 +250,8 @@ final class MetricsND
*
* @return int
*
* @throws InvalidDimensionException
*
* @since 1.0.0
*/
public static function hamming(array $a, array $b) : int

View File

@ -383,6 +383,8 @@ final class CliRequest extends RequestAbstract
*
* @return int
*
* @throws \Exception
*
* @since 1.0.0
*/
public function getRouteVerb() : int

View File

@ -168,12 +168,12 @@ final class HttpHeader extends HeaderAbstract
$part = \substr($name, 0, 5);
if ($part === 'HTTP_') {
self::$serverHeaders[
\str_replace(
' ',
'-',
\strtr(
\strtolower(
\str_replace('_', ' ', \substr($name, 5))
)
\strtr(\substr($name, 5), '_', ' ')
),
' ',
'-'
)
] = $value;
}
@ -252,6 +252,8 @@ final class HttpHeader extends HeaderAbstract
*
* @return void
*
* @throws \Exception
*
* @since 1.0.0
* @codeCoverageIgnore
*/

View File

@ -418,7 +418,7 @@ final class HttpRequest extends RequestAbstract
: $components;
// @codeCoverageIgnoreEnd
$this->locale = \str_replace('-', '_', $locals[0]); // @codeCoverageIgnore
$this->locale = \strtr($locals[0], '-', '_'); // @codeCoverageIgnore
return $this->locale;
}
@ -661,6 +661,8 @@ final class HttpRequest extends RequestAbstract
*
* @return int
*
* @throws \Exception
*
* @since 1.0.0
*/
public function getRouteVerb() : int

View File

@ -136,8 +136,6 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface
*
* @return string
*
* @throws \Exception
*
* @since 1.0.0
*/
private function getRaw(bool $optimize = false) : string

View File

@ -1677,7 +1677,7 @@ class Email implements MessageInterface
}
if (\preg_match_all("/[{$pattern}]/", $encoded, $matches) !== false) {
return \str_replace(' ', '_', $encoded);
return \strtr($encoded, ' ', '_');
}
$matches = [];
@ -1696,7 +1696,7 @@ class Email implements MessageInterface
// Replace spaces with _ (more readable than =20)
// RFC 2047 section 4.2(2)
return \str_replace(' ', '_', $encoded);
return \strtr($encoded, ' ', '_');
}
/**

View File

@ -110,8 +110,6 @@ final class SocketResponse extends ResponseAbstract implements RenderableInterfa
*
* @return string
*
* @throws \Exception
*
* @since 1.0.0
*/
private function getRaw(bool $optimize = false) : string

View File

@ -98,6 +98,8 @@ abstract class InstallerAbstract
*
* @return void
*
* @throws \UnexpectedValueException
*
* @since 1.0.0
*/
protected static function activate(ApplicationAbstract $app, ModuleInfo $info) : void
@ -109,7 +111,7 @@ abstract class InstallerAbstract
$classPath = \substr($path . '/Status', (int) \strlen((string) \realpath(__DIR__ . '/../../')));
/** @var class-string<StatusAbstract> $class */
$class = \str_replace('/', '\\', $classPath);
$class = \strtr($classPath, '/', '\\');
if (!Autoloader::exists($class)) {
throw new \UnexpectedValueException($class); // @codeCoverageIgnore
@ -126,6 +128,8 @@ abstract class InstallerAbstract
*
* @return void
*
* @throws \UnexpectedValueException
*
* @since 1.0.0
*/
public static function reInit(ModuleInfo $info, ApplicationInfo $appInfo = null) : void
@ -137,7 +141,7 @@ abstract class InstallerAbstract
$classPath = \substr($path . '/Status', \strlen((string) \realpath(__DIR__ . '/../../')));
/** @var class-string<StatusAbstract> $class */
$class = \str_replace('/', '\\', $classPath);
$class = \strtr($classPath, '/', '\\');
if (!Autoloader::exists($class)) {
throw new \UnexpectedValueException($class); // @codeCoverageIgnore

View File

@ -96,6 +96,8 @@ final class ModuleInfo
*
* @return void
*
* @throws PathException
*
* @since 1.0.0
*/
public function update() : void
@ -116,6 +118,8 @@ final class ModuleInfo
*
* @return void
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public function set(string $path, $data, string $delim = '/') : void

View File

@ -547,6 +547,8 @@ final class ModuleManager
*
* @return bool
*
* @throws InvalidModuleException
*
* @since 1.0.0
*/
public function uninstall(string $module) : bool
@ -638,7 +640,7 @@ final class ModuleManager
return;
}
$from = \str_replace('/', '\\', $from);
$from = \strtr($from, '/', '\\');
$class = $from . '\\Admin\\Install\\' . $for;
$class::install($this->app, $this->modulePath);
@ -654,8 +656,6 @@ final class ModuleManager
*
* @return object|\phpOMS\Module\ModuleAbstract
*
* @throws \Exception
*
* @todo Remove docblock type hint hack "object".
* The return type object is only used to stop the annoying warning that a method doesn't exist
* if you chain call the methods part of the returned ModuleAbstract implementation.
@ -685,8 +685,6 @@ final class ModuleManager
*
* @return void
*
* @throws \Exception
*
* @since 1.0.0
*/
private function initModuleController(string $module, string $ctlName = null) : void

View File

@ -148,6 +148,8 @@ final class PackageManager
*
* @return string Hash value of files
*
* @throws \Exception
*
* @since 1.0.0
*/
private function hashFiles() : string

View File

@ -67,8 +67,6 @@ abstract class StatusAbstract
*
* @return void
*
* @throws PermissionException
*
* @since 1.0.0
*/
public static function activateRoutes(ModuleInfo $info, ApplicationInfo $appInfo = null) : void
@ -84,6 +82,7 @@ abstract class StatusAbstract
*
* @return void
*
* @throws PathException
* @throws PermissionException
*
* @since 1.0.0
@ -124,8 +123,6 @@ abstract class StatusAbstract
*
* @return void
*
* @throws PermissionException
*
* @since 1.0.0
*/
public static function activateHooks(ModuleInfo $info, ApplicationInfo $appInfo = null) : void
@ -141,8 +138,6 @@ abstract class StatusAbstract
*
* @return void
*
* @throws PermissionException
*
* @since 1.0.0
*/
public static function activateRoutesHooks(ModuleInfo $info, ApplicationInfo $appInfo = null, string $type) : void

View File

@ -74,7 +74,7 @@ abstract class UninstallerAbstract
$classPath = \substr($path . '/Status', \strlen((string) \realpath(__DIR__ . '/../../')));
/** @var StatusAbstract $class */
$class = \str_replace('/', '\\', $classPath);
$class = \strtr($classPath, '/', '\\');
$class::deactivate($app, $info);
}

View File

@ -85,7 +85,7 @@ abstract class EnumArray
*
* @return mixed
*
* @throws \Exception
* @throws \OutOfBoundsException
*
* @since 1.0.0
*/

View File

@ -54,6 +54,8 @@ class Iban implements SerializableInterface
*
* @return void
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
private function parse(string $iban) : void

View File

@ -323,6 +323,8 @@ class Directory extends FileAbstract implements DirectoryInterface
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function changed(\FTP\Connection $con, string $path) : \DateTime
{
@ -340,6 +342,8 @@ class Directory extends FileAbstract implements DirectoryInterface
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function owner(\FTP\Connection $con, string $path) : string
{

View File

@ -256,6 +256,8 @@ class File extends FileAbstract implements FileInterface
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function changed(\FTP\Connection $con, string $path) : \DateTime
{
@ -285,6 +287,8 @@ class File extends FileAbstract implements FileInterface
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function owner(\FTP\Connection $con, string $path) : string
{

View File

@ -63,6 +63,8 @@ class FtpStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function put(string $path, string $content, int $mode = 0) : bool
{
@ -75,6 +77,8 @@ class FtpStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function get(string $path) : string
{
@ -97,6 +101,8 @@ class FtpStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function list(string $path, string $filter = '*', bool $recursive = false) : array
{
@ -109,6 +115,8 @@ class FtpStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function set(string $path, string $content) : bool
{
@ -121,6 +129,8 @@ class FtpStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function append(string $path, string $content) : bool
{
@ -133,6 +143,8 @@ class FtpStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function prepend(string $path, string $content) : bool
{
@ -145,6 +157,8 @@ class FtpStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function extension(string $path) : string
{

View File

@ -102,7 +102,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
continue;
}
$list[] = \substr(\str_replace('\\', '/', $iterator->getPathname()), \strlen($path) + 1);
$list[] = \substr(\strtr($iterator->getPathname(), '\\', '/'), \strlen($path) + 1);
}
/** @var string[] $list */
@ -147,7 +147,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
if ((empty($extension) || $item->getExtension() === $extension)
&& (empty($exclude) || (!(bool) \preg_match('/' . $exclude . '/', $subPath)))
) {
$list[] = \str_replace('\\', '/', $subPath);
$list[] = \strtr($subPath, '\\', '/');
}
}
@ -329,7 +329,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
*/
public static function parent(string $path) : string
{
$path = \explode('/', \str_replace('\\', '/', $path));
$path = \explode('/', \strtr($path, '\\', '/'));
\array_pop($path);
return \implode('/', $path);
@ -337,6 +337,8 @@ final class Directory extends FileAbstract implements DirectoryInterface
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function owner(string $path) : int
{

View File

@ -107,6 +107,8 @@ final class File extends FileAbstract implements FileInterface
*
* @return string Content of file
*
* @throws PathException
*
* @since 1.0.0
*/
public static function get(string $path) : string
@ -217,6 +219,8 @@ final class File extends FileAbstract implements FileInterface
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function owner(string $path) : int
{

View File

@ -118,6 +118,8 @@ abstract class FileAbstract implements LocalContainerInterface
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function created(string $path) : \DateTime
{
@ -132,6 +134,8 @@ abstract class FileAbstract implements LocalContainerInterface
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function changed(string $path) : \DateTime
{

View File

@ -39,6 +39,8 @@ class LocalStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function put(string $path, string $content, int $mode = 0) : bool
{
@ -51,6 +53,8 @@ class LocalStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function get(string $path) : string
{
@ -63,6 +67,8 @@ class LocalStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function list(string $path, string $filter = '*', bool $recursive = false) : array
{
@ -85,6 +91,8 @@ class LocalStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function set(string $path, string $content) : bool
{
@ -97,6 +105,8 @@ class LocalStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function append(string $path, string $content) : bool
{
@ -109,6 +119,8 @@ class LocalStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function prepend(string $path, string $content) : bool
{
@ -121,6 +133,8 @@ class LocalStorage extends StorageAbstract
/**
* {@inheritdoc}
*
* @throws PathException
*/
public static function extension(string $path) : string
{

View File

@ -153,6 +153,12 @@ final class SystemUtils
* @param string $executable Path or name of the executable
* @param string $cmd Command to execute
* @param bool $async Execute async
*
* @return array
*
* @throws \Exception
*
* @since 1.0.0
*/
public static function runProc(string $executable, string $cmd, bool $async = false) : array
{

View File

@ -172,6 +172,8 @@ final class HttpUri implements UriInterface
/**
* {@inheritdoc}
*
* @throws \Exception
*/
public function set(string $uri) : void
{

View File

@ -45,6 +45,8 @@ final class ArrayUtils
*
* @return array
*
* @throws \Exception
*
* @since 1.0.0
*/
public static function unsetArray(string $path, array $data, string $delim = '/') : array
@ -506,6 +508,9 @@ final class ArrayUtils
*
* @return array
*
* @throws InvalidDimensionException
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function dot(array $value1, array $value2) : int|float|array

View File

@ -133,6 +133,8 @@ abstract class BarAbstract extends CodeAbstract
*
* @return \GdImage
*
* @throws \Exception
*
* @since 1.0.0
*/
protected function createImage(string $codeString) : mixed

View File

@ -124,6 +124,8 @@ abstract class CodeAbstract
*
* @return void
*
* @throws \OutOfBoundsException
*
* @since 1.0.0
*/
public function setDimension(int $width, int $height) : void
@ -161,6 +163,8 @@ abstract class CodeAbstract
*
* @return void
*
* @throws InvalidEnumValue
*
* @since 1.0.0
*/
public function setOrientation(int $orientation) : void

View File

@ -51,6 +51,8 @@ abstract class TwoDAbstract extends CodeAbstract
*
* @return \GdImage
*
* @throws \Exception
*
* @since 1.0.0
*/
protected function createImage(array $codeArray) : mixed

View File

@ -61,6 +61,8 @@ class LZW implements CompressionInterface
/**
* {@inheritdoc}
*
* @throws \Exception
*/
public function decompress(string $compressed) : string
{

View File

@ -70,8 +70,6 @@ final class Currency
*
* @return float
*
* @throws \InvalidArgumentException This exception is thrown if the currency to convert to doesn't exist
*
* @since 1.0.0
*/
public static function fromEurTo(float $value, string $to) : float
@ -137,8 +135,6 @@ final class Currency
*
* @return float
*
* @throws \InvalidArgumentException This exception is thrown if the currency to convert from doesn't exist
*
* @since 1.0.0
*/
public static function fromToEur(float $value, string $from) : float
@ -162,8 +158,6 @@ final class Currency
*
* @return float
*
* @throws \InvalidArgumentException This exception is thrown if either the from or to currency doesn't exist
*
* @since 1.0.0
*/
public static function convertCurrency(float $value, string $from, string $to) : float

View File

@ -43,6 +43,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function convertTemperature(float $value, string $from = TemperatureType::FAHRENHEIT, string $to = TemperatureType::CELSIUS) : float
@ -89,6 +91,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
private static function normalizeTemperature(float $value, string $from) : float
@ -133,6 +137,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function convertWeight(float $value, string $from = WeightType::GRAM, string $to = WeightType::KILOGRAM) : float
@ -197,6 +203,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
private static function normalizeWeight(float $value, string $from) : float
@ -259,6 +267,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function convertLength(float $value, string $from = LengthType::METERS, string $to = LengthType::KILOMETERS) : float
@ -347,6 +357,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
private static function normalizeLength(float $value, string $from) : float
@ -433,6 +445,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function convertArea(float $value, string $from = AreaType::SQUARE_METERS, string $to = AreaType::SQUARE_KILOMETERS) : float
@ -494,6 +508,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
private static function normalizeArea(float $value, string $from) : float
@ -553,6 +569,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function convertVolume(float $value, string $from = VolumeType::LITER, string $to = VolumeType::LITER) : float
@ -689,6 +707,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
private static function normalizeVolume(float $value, string $from) : float
@ -823,6 +843,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function convertSpeed(float $value, string $from = SpeedType::KILOMETERS_PER_HOUR, string $to = SpeedType::KILOMETERS_PER_HOUR) : float
@ -947,6 +969,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
private static function normalizeSpeed(float $value, string $from) : float
@ -1069,6 +1093,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function convertTime(float $value, string $from = TimeType::SECONDS, string $to = TimeType::HOURS) : float
@ -1118,6 +1144,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
private static function normalizeTime(float $value, string $from) : float
@ -1165,6 +1193,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function convertAngle(float $value, string $from = AngleType::DEGREE, string $to = AngleType::DEGREE) : float
@ -1217,6 +1247,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
private static function normalizeAngle(float $value, string $from) : float
@ -1267,6 +1299,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function convertPressure(float $value, string $from = PressureType::PASCALS, string $to = PressureType::BAR) : float
@ -1327,6 +1361,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
private static function normalizePressure(float $value, string $from) : float
@ -1385,6 +1421,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function convertEnergy(float $value, string $from = EnergyPowerType::JOULS, string $to = EnergyPowerType::KILOWATT_HOUERS) : float
@ -1432,6 +1470,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
private static function normalizeEnergy(float $value, string $from) : float
@ -1478,6 +1518,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function convertFileSize(float $value, string $from = FileSizeType::BYTE, string $to = FileSizeType::MEGABYTE) : float
@ -1530,6 +1572,8 @@ final class Measurement
*
* @return float
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
private static function normalizeFileSize(float $value, string $from) : float

View File

@ -55,8 +55,6 @@ final class Numeric
*
* @return string
*
* @throws \Exception This exception is thrown if one of the bases or the number is invalid
*
* @since 1.0.0
*/
public static function convertBase(string $numberInput, string $fromBaseInput, string $toBaseInput) : string

View File

@ -0,0 +1,59 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package phpOMS\Utils\Encoding
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace phpOMS\Utils\Encoding;
/**
* Base64Url encoding class
*
* @package phpOMS\Utils\Encoding
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class Base64Url
{
/**
* Encode source text
*
* @param string $source Source to encode
*
* @return string
*
* @since 1.0.0
*/
public static function encode(string $source) : string
{
$data64 = \base64_encode($source);
$data64Url = \strtr($data64, '+/', '-_');
return \rtrim($data64Url, '=');
}
/**
* Dedecodes text
*
* @param string $b64 Encoded value to dedecode
*
* @return string
*
* @since 1.0.0
*/
public static function decode(string $b64) : string
{
$data = \strtr($b64, '-_', '+/');
return \base64_decode($data, false);
}
}

View File

@ -131,7 +131,7 @@ final class Dictionary
*
* @return void
*
* @throws \Exception
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
@ -169,7 +169,7 @@ final class Dictionary
*
* @return string
*
* @throws \Exception
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/

View File

@ -107,6 +107,8 @@ final class Huffman
*
* @return string
*
* @throws \Exception
*
* @since 1.0.0
*/
public function decode(string $raw) : string

View File

@ -288,8 +288,6 @@ class Repository
*
* @return string
*
* @throws \Exception
*
* @since 1.0.0
*/
public function add(string | array $files = '*') : string
@ -446,7 +444,7 @@ class Repository
{
if (empty($this->name)) {
$path = $this->getDirectoryPath();
$path = \str_replace('\\', '/', $path);
$path = \strtr($path, '\\', '/');
$path = \explode('/', $path);
$this->name = $path[\count($path) - ($this->bare ? 1 : 2)];
}
@ -633,8 +631,6 @@ class Repository
*
* @return int
*
* @throws \Exception
*
* @since 1.0.0
*/
public function countFiles() : int
@ -651,8 +647,6 @@ class Repository
*
* @return int
*
* @throws \Exception
*
* @since 1.0.0
*/
public function getLoc(array $extensions = ['*']) : int

View File

@ -31,7 +31,7 @@ class Gz implements ArchiveInterface
*/
public static function pack(string | array $source, string $destination, bool $overwrite = false) : bool
{
$destination = \str_replace('\\', '/', $destination);
$destination = \strtr($destination, '\\', '/');
if ($destination === false
|| \is_array($source)
|| (!$overwrite && \is_file($destination))
@ -61,7 +61,7 @@ class Gz implements ArchiveInterface
*/
public static function unpack(string $source, string $destination) : bool
{
$destination = \str_replace('\\', '/', $destination);
$destination = \strtr($destination, '\\', '/');
if (\is_file($destination) || !\is_file($source)) {
return false;
}

View File

@ -38,7 +38,7 @@ class Tar implements ArchiveInterface
*/
public static function pack(string | array $sources, string $destination, bool $overwrite = false) : bool
{
$destination = FileUtils::absolute(\str_replace('\\', '/', $destination));
$destination = FileUtils::absolute(\strtr($destination, '\\', '/'));
if ((!$overwrite && \is_file($destination))
|| \is_dir($destination)
) {
@ -59,8 +59,8 @@ class Tar implements ArchiveInterface
$source = $relative;
}
$source = FileUtils::absolute(\str_replace('\\', '/', $source));
$relative = \str_replace('\\', '/', $relative);
$source = FileUtils::absolute(\strtr($source, '\\', '/'));
$relative = \strtr($relative, '\\', '/');
if (\is_dir($source)) {
/** @var string[] $files */
@ -70,7 +70,7 @@ class Tar implements ArchiveInterface
);
foreach ($files as $file) {
$file = \str_replace('\\', '/', $file);
$file = \strtr($file, '\\', '/');
/* Ignore . and .. */
if (($pos = \mb_strrpos($file, '/')) === false
@ -113,7 +113,7 @@ class Tar implements ArchiveInterface
}
try {
$destination = \str_replace('\\', '/', $destination);
$destination = \strtr($destination, '\\', '/');
$destination = \rtrim($destination, '/');
$tar = new \PharData($source);

View File

@ -33,7 +33,7 @@ class TarGz implements ArchiveInterface
*/
public static function pack(string | array $source, string $destination, bool $overwrite = false) : bool
{
$destination = \str_replace('\\', '/', $destination);
$destination = \strtr($destination, '\\', '/');
if (!$overwrite && \is_file($destination)) {
return false;
}
@ -56,7 +56,7 @@ class TarGz implements ArchiveInterface
*/
public static function unpack(string $source, string $destination) : bool
{
$destination = \str_replace('\\', '/', $destination);
$destination = \strtr($destination, '\\', '/');
if (!\is_dir($destination) || !\is_file($source)) {
return false;
}

View File

@ -34,7 +34,7 @@ class Zip implements ArchiveInterface
*/
public static function pack(string | array $sources, string $destination, bool $overwrite = false) : bool
{
$destination = FileUtils::absolute(\str_replace('\\', '/', $destination));
$destination = FileUtils::absolute(\strtr($destination, '\\', '/'));
if ((!$overwrite && \is_file($destination))
|| \is_dir($destination)
) {
@ -58,8 +58,8 @@ class Zip implements ArchiveInterface
$source = $relative;
}
$source = FileUtils::absolute(\str_replace('\\', '/', $source));
$relative = \str_replace('\\', '/', $relative);
$source = FileUtils::absolute(\strtr($source, '\\', '/'));
$relative = \strtr($relative, '\\', '/');
if (\is_dir($source)) {
/** @var string[] $files */
@ -69,7 +69,7 @@ class Zip implements ArchiveInterface
);
foreach ($files as $file) {
$file = \str_replace('\\', '/', $file);
$file = \strtr($file, '\\', '/');
/* Ignore . and .. */
if (($pos = \mb_strrpos($file, '/')) === false
@ -111,7 +111,7 @@ class Zip implements ArchiveInterface
Directory::create($destination, recursive: true);
}
$destination = \str_replace('\\', '/', $destination);
$destination = \strtr($destination, '\\', '/');
$destination = \rtrim($destination, '/');
try {

View File

@ -108,6 +108,9 @@ final class ImageUtils
* @param bool $crop Crop image
*
* @return void
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function resize(string $srcPath, string $dstPath, int $width, int $height, bool $crop = false) : void

View File

@ -44,7 +44,7 @@ class PresentationWriter
/**
* Presentation object
*
* @var Presentation
* @var PhpPresentation
* @since 1.0.0
*/
protected PhpPresentation $oPhpPresentation;
@ -213,7 +213,6 @@ class PresentationWriter
$this->append('<div class="infoBlk" id="div' . $oSlide->getHashCode() . 'Info">');
$this->append('<dl>');
$this->append('<dt>HashCode</dt><dd>' . $oSlide->getHashCode() . '</dd>');
$this->append('<dt>Slide Layout</dt><dd>Layout::' . $this->getConstantName('\PhpOffice\PhpPresentation\Slide\Layout', $oSlide->getSlideLayout()) . '</dd>');
$this->append('<dt>Offset X</dt><dd>' . $oSlide->getOffsetX() . '</dd>');
$this->append('<dt>Offset Y</dt><dd>' . $oSlide->getOffsetY() . '</dd>');

View File

@ -58,6 +58,8 @@ class SpreadsheetParser
$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
IOFactory::registerWriter('custom', \phpOMS\Utils\Parser\Spreadsheet\SpreadsheetWriter::class);
/** @var \phpOMS\Utils\Parser\Spreadsheet\SpreadsheetWriter $writer */
$writer = IOFactory::createWriter($spreadsheet, 'custom');
return $writer->toPdfString();
@ -65,6 +67,7 @@ class SpreadsheetParser
$spreadsheet = IOFactory::load($path);
IOFactory::registerWriter('custom', \phpOMS\Utils\Parser\Spreadsheet\SpreadsheetWriter::class);
/** @var \phpOMS\Utils\Parser\Spreadsheet\SpreadsheetWriter $writer */
$writer = IOFactory::createWriter($spreadsheet, 'custom');
return $writer->generateHtmlAll();

View File

@ -30,6 +30,9 @@ final class UUID
* @param int<8, max> $length Result length in bytes
*
* @return string
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
*/
public static function default(int $length = 16) : string

View File

@ -29,6 +29,8 @@ class Cron extends SchedulerAbstract
{
/**
* {@inheritdoc}
*
* @throws \Exception
*/
public function create(TaskAbstract $task) : void
{
@ -51,6 +53,8 @@ class Cron extends SchedulerAbstract
/**
* {@inheritdoc}
*
* @throws \Exception
*/
public function update(TaskAbstract $task) : void
{
@ -94,6 +98,8 @@ class Cron extends SchedulerAbstract
/**
* {@inheritdoc}
*
* @throws \Exception
*/
public function deleteByName(string $name) : void
{
@ -129,6 +135,8 @@ class Cron extends SchedulerAbstract
/**
* {@inheritdoc}
*
* @throws \Exception
*/
public function getAll() : array
{
@ -172,6 +180,8 @@ class Cron extends SchedulerAbstract
/**
* {@inheritdoc}
*
* @throws \Exception
*/
public function getAllByName(string $name, bool $exact = true) : array
{

View File

@ -40,7 +40,7 @@ class Autoloader
public static function defaultAutoloader(string $class) : void
{
$class = \ltrim($class, '\\');
$class = \str_replace(['_', '\\'], '/', $class);
$class = \strtr($class, '_\\', '//');
if (!\is_file($path = __DIR__ . '/../../' . $class . '.php')) {
return;
@ -64,7 +64,7 @@ class Autoloader
public static function exists(string $class) : bool
{
$class = \ltrim($class, '\\');
$class = \str_replace(['_', '\\'], '/', $class);
$class = \strtr($class, '_\\', '//');
return \is_file(__DIR__ . '/../../' . $class . '.php');
}

View File

@ -63,34 +63,34 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] as t FROM [a] as b WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->selectAs('a.test', 't')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT DISTINCT [a].[test] FROM [a] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->distinct()->from('a')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test], [b].[test] FROM [a], [b] WHERE [a].[test] = \'abc\';';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test', 'b.test')->from('a', 'b')->where('a.test', '=', 'abc')->toSql());
$query = new Builder($con);
$datetime = new \DateTime('now');
$sql = 'SELECT [a].[test], [b].[test] FROM [a], [b] WHERE [a].[test] = \'' . $datetime->format('Y-m-d H:i:s')
. '\';';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test', 'b.test')->from('a', 'b')->where('a.test', '=', $datetime)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test], [b].[test] FROM [a], [b] WHERE [a].[test] = \'abc\' ORDER BY [a].[test] ASC, [b].[test] DESC;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql,
$query->select('a.test', 'b.test')
->from('a', 'b')
@ -101,7 +101,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT [a].[test], [b].[test] FROM [a], [b] WHERE [a].[test] = :abcValue ORDER BY [a].[test] ASC, [b].[test] DESC;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql,
$query->select('a.test', 'b.test')
->from('a', 'b')
@ -122,7 +122,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] as b WHERE [a].[test] = 1 ORDER BY \rand() LIMIT 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
}
@ -135,7 +135,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] as b ORDER BY RANDOM() LIMIT 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
}
@ -148,7 +148,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] as b ORDER BY RANDOM() LIMIT 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
}
@ -161,7 +161,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT TOP 1 [a].[test] FROM [a] as b ORDER BY IDX FETCH FIRST 1 ROWS ONLY;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
}
@ -183,32 +183,32 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 ORDER BY [a].[test] DESC;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->newest('a.test')->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 ORDER BY [a].[test] ASC;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->oldest('a.test')->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 ORDER BY [a].[test] DESC;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->orderBy('a.test', 'DESC')->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 ORDER BY [a].[test] ASC;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->orderBy('a.test', 'ASC')->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 ORDER BY [a].[test] DESC, [a].[test2] DESC;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->orderBy(['a.test', 'a.test2'], ['DESC', 'DESC'])->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 ORDER BY [a].[test] ASC, [a].[test2] ASC;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->orderBy(['a.test', 'a.test2'], 'ASC')->toSql());
}
@ -230,12 +230,12 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 LIMIT 3;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->limit(3)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 OFFSET 3;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->offset(3)->toSql());
}
@ -257,12 +257,12 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 GROUP BY [a];';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->groupBy('a')->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 GROUP BY [a], [b];';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->groupBy('a')->groupBy('b')->toSql());
$query = new Builder($con);
@ -270,7 +270,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = :test GROUP BY [a], [b];';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', new Parameter('test'))->groupBy('a', 'b')->toSql());
}
@ -292,72 +292,72 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 0;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', false)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', true)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = \'string\';';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 'string')->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1.23;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1.23)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 AND [a].[test2] = 2;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->where('a.test2', '=', 2, 'and')->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 AND [a].[test2] = 2;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->andWhere('a.test2', '=', 2)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 OR [a].[test2] = 2;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->where('a.test2', '=', 2, 'or')->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 OR [a].[test2] = 2;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->orWhere('a.test2', '=', 2)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 OR [a].[test2] IS NULL;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->whereNull('a.test2', 'or')->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 OR [a].[test2] IS NOT NULL;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->whereNotNull('a.test2', 'or')->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 OR [a].[test2] IN (1, 2, 3);';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->whereIn('a.test2', [1, 2, 3], 'or')->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = 1 OR [a].[test2] IN (\'a\', \'b\', \'c\');';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->whereIn('a.test2', ['a', 'b', 'c'], 'or')->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] WHERE [a].[test] = :testWhere OR [a].[test2] IN (\'a\', :bValue, \'c\');';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', new Parameter('testWhere'))->whereIn('a.test2', ['a', new Parameter('bValue'), 'c'], 'or')->toSql());
}
@ -379,72 +379,72 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] JOIN [b] ON [a].[id] = [b].[id] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->join('b')->on('a.id', '=', 'b.id')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] JOIN [b] ON [a].[id] = [b].[id] OR [a].[id2] = [b].[id2] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->join('b')->on('a.id', '=', 'b.id')->orOn('a.id2', '=', 'b.id2')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] JOIN [b] ON [a].[id] = [b].[id] AND [a].[id2] = [b].[id2] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->join('b')->on('a.id', '=', 'b.id')->andOn('a.id2', '=', 'b.id2')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] LEFT JOIN [b] ON [a].[id] = [b].[id] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->leftJoin('b')->on('a.id', '=', 'b.id')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] LEFT OUTER JOIN [b] ON [a].[id] = [b].[id] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->leftOuterJoin('b')->on('a.id', '=', 'b.id')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] LEFT INNER JOIN [b] ON [a].[id] = [b].[id] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->leftInnerJoin('b')->on('a.id', '=', 'b.id')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] RIGHT JOIN [b] ON [a].[id] = [b].[id] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->rightJoin('b')->on('a.id', '=', 'b.id')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] RIGHT OUTER JOIN [b] ON [a].[id] = [b].[id] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->rightOuterJoin('b')->on('a.id', '=', 'b.id')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] RIGHT INNER JOIN [b] ON [a].[id] = [b].[id] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->rightInnerJoin('b')->on('a.id', '=', 'b.id')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] OUTER JOIN [b] ON [a].[id] = [b].[id] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->outerJoin('b')->on('a.id', '=', 'b.id')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] INNER JOIN [b] ON [a].[id] = [b].[id] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->innerJoin('b')->on('a.id', '=', 'b.id')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] CROSS JOIN [b] ON [a].[id] = [b].[id] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->crossJoin('b')->on('a.id', '=', 'b.id')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] FULL JOIN [b] ON [a].[id] = [b].[id] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->fullJoin('b')->on('a.id', '=', 'b.id')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] FULL OUTER JOIN [b] ON [a].[id] = [b].[id] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->select('a.test')->from('a')->fullOuterJoin('b')->on('a.id', '=', 'b.id')->where('a.test', '=', 1)->toSql());
}
@ -466,28 +466,28 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'INSERT INTO [a] VALUES (1, \'test\');';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->insert()->into('a')->values(1, 'test')->toSql());
$query = new Builder($con);
$sql = 'INSERT INTO [a] VALUES (1, \'test\');';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->insert()->into('a')->value([1, 'test'])->toSql());
$query = new Builder($con);
$sql = 'INSERT INTO [a] ([test], [test2]) VALUES (1, \'test\');';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->insert('test', 'test2')->into('a')->values(1, 'test')->toSql());
self::assertEquals([[1, 'test']], $query->getValues());
$query = new Builder($con);
$sql = 'INSERT INTO [a] ([test], [test2]) VALUES (1, \'test\'), (2, \'test2\');';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->insert('test', 'test2')->into('a')->values(1, 'test')->values(2, 'test2')->toSql());
$query = new Builder($con);
$sql = 'INSERT INTO [a] ([test], [test2]) VALUES (:test, :test2);';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->insert('test', 'test2')->into('a')->values(new Parameter('test'), new Parameter('test2'))->toSql());
}
@ -509,12 +509,12 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'DELETE FROM [a] WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->delete()->from('a')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'DELETE FROM [a] WHERE [a].[test] = :testVal;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->delete()->from('a')->where('a.test', '=', new Parameter('testVal'))->toSql());
}
@ -536,17 +536,17 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'UPDATE [a] SET [a].[test] = 1, [a].[test2] = 2 WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->update('a')->set(['a.test' => 1])->set(['a.test2' => 2])->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'UPDATE [a] SET [a].[test] = 1, [a].[test2] = 2 WHERE [a].[test] = 1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->update('a')->sets('a.test', 1)->sets('a.test2', 2)->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'UPDATE [a] SET [a].[test] = 1, [a].[test2] = :test2 WHERE [a].[test] = :test3;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->update('a')->set(['a.test' => 1])->set(['a.test2' => new Parameter('test2')])->where('a.test', '=', new Parameter('test3'))->toSql());
}

View File

@ -62,7 +62,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'DROP DATABASE [test];';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->dropDatabase('test')->toSql());
}
@ -84,7 +84,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'DROP TABLE [test];';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->dropTable('test')->toSql());
}
@ -106,7 +106,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT [table_name] FROM [information_schema].[tables] WHERE [table_schema] = \'' . $GLOBALS['CONFIG']['db']['core']['masters']['admin']['database']. '\';';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->selectTables()->toSql());
}
@ -128,7 +128,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'SELECT * FROM [information_schema].[columns] WHERE [table_schema] = \'' . $GLOBALS['CONFIG']['db']['core']['masters']['admin']['database']. '\' AND table_name = \'test\';';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->selectFields('test')->toSql());
}
@ -150,7 +150,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'CREATE TABLE IF NOT EXISTS [user_roles] (user_id INT AUTO_INCREMENT, role_id VARCHAR(10) DEFAULT \'1\' NULL, PRIMARY KEY (user_id), FOREIGN KEY (user_id) REFERENCES users (ext1_id), FOREIGN KEY (role_id) REFERENCES roles (ext2_id)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals(
$sql,
$query->createTable('user_roles')
@ -174,7 +174,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'CREATE TABLE IF NOT EXISTS user_roles (user_id INT NOT NULL AUTO_INCREMENT, role_id VARCHAR(10) DEFAULT \'1\' NULL, PRIMARY KEY (user_id), FOREIGN KEY (user_id) REFERENCES users (ext1_id), FOREIGN KEY (role_id) REFERENCES roles (ext2_id)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals(
$sql,
$query->createTable('user_roles')
@ -204,7 +204,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$query = new Builder($con);
$sql = 'DROP TABLE [test], [test_foreign];';
$sql = \str_replace(['[', ']'], [$iS, $iE], $sql);
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals(
$sql,

View File

@ -199,7 +199,7 @@ final class DirectoryTest extends \PHPUnit\Framework\TestCase
{
$dirPath = __DIR__ . '/test';
self::assertEquals(\str_replace('\\', '/', \realpath(__DIR__)), Directory::parent($dirPath));
self::assertEquals(\strtr(\realpath(__DIR__), '\\', '/'), Directory::parent($dirPath));
}
/**

View File

@ -302,7 +302,7 @@ final class FileTest extends \PHPUnit\Framework\TestCase
{
$testFile = __DIR__ . '/test.txt';
self::assertEquals(\str_replace('\\', '/', \realpath(__DIR__ . '/../')), File::parent($testFile));
self::assertEquals(\strtr(\realpath(__DIR__ . '/../'), '\\', '/'), File::parent($testFile));
}
/**

View File

@ -180,7 +180,7 @@ final class FtpStorageTest extends \PHPUnit\Framework\TestCase
{
$dirPath = __DIR__ . '/test';
self::assertEquals(\str_replace('\\', '/', \realpath(__DIR__)), FtpStorage::parent($dirPath));
self::assertEquals(\strtr(\realpath(__DIR__), '\\', '/'), FtpStorage::parent($dirPath));
}
/**
@ -664,7 +664,7 @@ final class FtpStorageTest extends \PHPUnit\Framework\TestCase
{
$testFile = __DIR__ . '/test.txt';
self::assertEquals(\str_replace('\\', '/', \realpath(__DIR__ . '/../')), FtpStorage::parent($testFile));
self::assertEquals(\strtr(\realpath(__DIR__ . '/../'), '\\', '/'), FtpStorage::parent($testFile));
}
/**

View File

@ -133,7 +133,7 @@ final class DirectoryTest extends \PHPUnit\Framework\TestCase
{
$dirPath = __DIR__ . '/test';
self::assertEquals(\str_replace('\\', '/', \realpath(__DIR__)), Directory::parent($dirPath));
self::assertEquals(\strtr(\realpath(__DIR__), '\\', '/'), Directory::parent($dirPath));
}
/**

View File

@ -297,7 +297,7 @@ final class FileTest extends \PHPUnit\Framework\TestCase
{
$testFile = __DIR__ . '/test.txt';
self::assertEquals(\str_replace('\\', '/', \realpath(__DIR__ . '/../')), File::parent($testFile));
self::assertEquals(\strtr(\realpath(__DIR__ . '/../'), '\\', '/'), File::parent($testFile));
}
/**

View File

@ -124,7 +124,7 @@ final class LocalStorageTest extends \PHPUnit\Framework\TestCase
{
$dirPath = __DIR__ . '/test';
self::assertEquals(\str_replace('\\', '/', \realpath(__DIR__)), LocalStorage::parent($dirPath));
self::assertEquals(\strtr(\realpath(__DIR__), '\\', '/'), LocalStorage::parent($dirPath));
}
/**
@ -604,7 +604,7 @@ final class LocalStorageTest extends \PHPUnit\Framework\TestCase
{
$testFile = __DIR__ . '/test.txt';
self::assertEquals(\str_replace('\\', '/', \realpath(__DIR__ . '/../')), LocalStorage::parent($testFile));
self::assertEquals(\strtr(\realpath(__DIR__ . '/../'), '\\', '/'), LocalStorage::parent($testFile));
}
/**

View File

@ -32,7 +32,7 @@ final class RepositoryTest extends \PHPUnit\Framework\TestCase
{
$repo = new Repository(\realpath(__DIR__ . '/../../../'));
self::assertTrue($repo->getName() === 'phpOMS' || $repo->getName() === 'build');
self::assertEquals(\str_replace('\\', '/', \realpath(__DIR__ . '/../../../.git')), \str_replace('\\', '/', $repo->getDirectoryPath()));
self::assertEquals(\strtr(\realpath(__DIR__ . '/../../../.git'), '\\', '/'), \strtr($repo->getDirectoryPath(), '\\', '/'));
self::assertEquals(\realpath(__DIR__ . '/../../../'), $repo->getPath());
}
}