diff --git a/Account/Account.php b/Account/Account.php index 5471d1c5f..a55bbf6fe 100755 --- a/Account/Account.php +++ b/Account/Account.php @@ -15,7 +15,6 @@ declare(strict_types=1); namespace phpOMS\Account; use phpOMS\Localization\Localization; -use phpOMS\Stdlib\Base\Exception\InvalidEnumValue; use phpOMS\Validation\Network\Email; /** @@ -164,12 +163,12 @@ class Account implements \JsonSerializable */ public function hasPermission( int $permission, - int $unit = null, - int $app = null, - string $module = null, - int $category = null, - int $element = null, - int $component = null + ?int $unit = null, + ?int $app = null, + ?string $module = null, + ?int $category = null, + ?int $element = null, + ?int $component = null ) : bool { foreach ($this->groups as $group) { @@ -317,70 +316,6 @@ class Account implements \JsonSerializable $this->email = \mb_strtolower($email); } - /** - * Get status. - * - * @return int Returns the status (AccountStatus) - * - * @since 1.0.0 - */ - public function getStatus() : int - { - return $this->status; - } - - /** - * Get status. - * - * @param int $status Status - * - * @return void - * - * @throws InvalidEnumValue This exception is thrown if a invalid status is used - * - * @since 1.0.0 - */ - public function setStatus(int $status) : void - { - if (!AccountStatus::isValidValue($status)) { - throw new InvalidEnumValue($status); - } - - $this->status = $status; - } - - /** - * Get type. - * - * @return int Returns the type (AccountType) - * - * @since 1.0.0 - */ - public function getType() : int - { - return $this->type; - } - - /** - * Get type. - * - * @param int $type Type - * - * @return void - * - * @throws InvalidEnumValue This exception is thrown if an invalid type is used - * - * @since 1.0.0 - */ - public function setType(int $type) : void - { - if (!AccountType::isValidValue($type)) { - throw new InvalidEnumValue($type); - } - - $this->type = $type; - } - /** * Get last activity. * @@ -445,8 +380,8 @@ class Account implements \JsonSerializable public function toArray() : array { return [ - 'id' => $this->id, - 'name' => [ + 'id' => $this->id, + 'name' => [ $this->name1, $this->name2, $this->name3, diff --git a/Account/AccountManager.php b/Account/AccountManager.php index 454cf9124..5942c9013 100755 --- a/Account/AccountManager.php +++ b/Account/AccountManager.php @@ -71,8 +71,8 @@ final class AccountManager implements \Countable if ($id === 0) { $account = new Account(Auth::authenticate($this->session)); - if (!isset($this->accounts[$account->getId()])) { - $this->accounts[$account->getId()] = $account; + if (!isset($this->accounts[$account->id])) { + $this->accounts[$account->id] = $account; } return $account; @@ -92,8 +92,8 @@ final class AccountManager implements \Countable */ public function add(Account $account) : bool { - if (!isset($this->accounts[$account->getId()])) { - $this->accounts[$account->getId()] = $account; + if (!isset($this->accounts[$account->id])) { + $this->accounts[$account->id] = $account; return true; } diff --git a/Account/Group.php b/Account/Group.php index 0049793a2..9f7405d8b 100755 --- a/Account/Group.php +++ b/Account/Group.php @@ -14,8 +14,6 @@ declare(strict_types=1); namespace phpOMS\Account; -use phpOMS\Stdlib\Base\Exception\InvalidEnumValue; - /** * Account group class. * @@ -88,38 +86,6 @@ class Group implements \JsonSerializable return $this->id; } - /** - * Get group status. - * - * @return int Group status - * - * @since 1.0.0 - */ - public function getStatus() : int - { - return $this->status; - } - - /** - * Set group status. - * - * @param int $status Group status - * - * @return void - * - * @throws InvalidEnumValue This exception is thrown if an invalid status is used - * - * @since 1.0.0 - */ - public function setStatus(int $status) : void - { - if (!GroupStatus::isValidValue($status)) { - throw new InvalidEnumValue($status); - } - - $this->status = $status; - } - /** * Get string representation. * diff --git a/Account/NullAccount.php b/Account/NullAccount.php index 1f8cf59f1..1bf4d5630 100755 --- a/Account/NullAccount.php +++ b/Account/NullAccount.php @@ -24,6 +24,18 @@ namespace phpOMS\Account; */ final class NullAccount extends Account { + /** + * Constructor + * + * @param int $id Model id + * + * @since 1.0.0 + */ + public function __construct(int $id = 0) + { + $this->id = $id; + } + /** * {@inheritdoc} */ diff --git a/Account/PermissionAbstract.php b/Account/PermissionAbstract.php index a70a7c63b..5f677810f 100755 --- a/Account/PermissionAbstract.php +++ b/Account/PermissionAbstract.php @@ -169,13 +169,13 @@ class PermissionAbstract implements \JsonSerializable * @since 1.0.0 */ public function __construct( - int $unit = null, - int $app = null, - string $module = null, - string $from = null, - int $category = null, - int $element = null, - int $component = null, + ?int $unit = null, + ?int $app = null, + ?string $module = null, + ?string $from = null, + ?int $category = null, + ?int $element = null, + ?int $component = null, int $permission = PermissionType::NONE ) { $this->unit = $unit; @@ -308,12 +308,12 @@ class PermissionAbstract implements \JsonSerializable */ public function hasPermission( int $permission, - int $unit = null, - int $app = null, - string $module = null, - int $category = null, - int $element = null, - int $component = null + ?int $unit = null, + ?int $app = null, + ?string $module = null, + ?int $category = null, + ?int $element = null, + ?int $component = null ) : bool { return $permission === PermissionType::NONE || @@ -352,15 +352,15 @@ class PermissionAbstract implements \JsonSerializable public function jsonSerialize() : mixed { return [ - 'id' => $this->id, - 'unit' => $this->unit, - 'app' => $this->app, - 'module' => $this->module, - 'from' => $this->from, - 'category' => $this->category, - 'element' => $this->element, - 'component' => $this->component, - 'permission' => $this->getPermission(), + 'id' => $this->id, + 'unit' => $this->unit, + 'app' => $this->app, + 'module' => $this->module, + 'from' => $this->from, + 'category' => $this->category, + 'element' => $this->element, + 'component' => $this->component, + 'permission' => $this->getPermission(), ]; } } diff --git a/Account/PermissionHandlingTrait.php b/Account/PermissionHandlingTrait.php index a4facc4ac..725d92f9c 100755 --- a/Account/PermissionHandlingTrait.php +++ b/Account/PermissionHandlingTrait.php @@ -135,12 +135,12 @@ trait PermissionHandlingTrait */ public function hasPermission( int $permission, - int $unit = null, - int $app = null, - string $module = null, - int $category = null, - int $element = null, - int $component = null + ?int $unit = null, + ?int $app = null, + ?string $module = null, + ?int $category = null, + ?int $element = null, + ?int $component = null ) : bool { foreach ($this->permissions as $p) { diff --git a/Algorithm/Clustering/AffinityPropagation.php b/Algorithm/Clustering/AffinityPropagation.php index 3f0d5b897..0b03a7c4c 100644 --- a/Algorithm/Clustering/AffinityPropagation.php +++ b/Algorithm/Clustering/AffinityPropagation.php @@ -148,7 +148,7 @@ final class AffinityPropagation implements ClusteringInterface $sum += \max(0.0, $this->responsibilityMatrix[$j][$k]); } - for ($j += 1; $j < $n; ++$j) { + for (++$j; $j < $n; ++$j) { $sum += \max(0.0, $this->responsibilityMatrix[$j][$k]); } @@ -189,7 +189,7 @@ final class AffinityPropagation implements ClusteringInterface * Find the nearest group for a point * * @param array $similarityMatrix Similarity matrix - * @param int $point Point id in the similarity matrix to compare + * @param int $point Point id in the similarity matrix to compare * * @return int * diff --git a/Algorithm/Clustering/AgglomerativeClustering.php b/Algorithm/Clustering/AgglomerativeClustering.php index 428be189d..10002ffdb 100644 --- a/Algorithm/Clustering/AgglomerativeClustering.php +++ b/Algorithm/Clustering/AgglomerativeClustering.php @@ -59,7 +59,7 @@ final class AgglomerativeClustering implements ClusteringInterface * * @since 1.0.0 */ - public function __construct(\Closure $metric = null, \Closure $linkage = null) + public function __construct(?\Closure $metric = null, ?\Closure $linkage = null) { $this->metric = $metric ?? function (PointInterface $a, PointInterface $b) { $aCoordinates = $a->coordinates; diff --git a/Algorithm/Clustering/DBSCAN.php b/Algorithm/Clustering/DBSCAN.php index 9d5357f36..ea38eb5f7 100644 --- a/Algorithm/Clustering/DBSCAN.php +++ b/Algorithm/Clustering/DBSCAN.php @@ -116,7 +116,7 @@ final class DBSCAN implements ClusteringInterface * * @since 1.0.0 */ - public function __construct(\Closure $metric = null) + public function __construct(?\Closure $metric = null) { $this->metric = $metric ?? function (PointInterface $a, PointInterface $b) { $aCoordinates = $a->coordinates; diff --git a/Algorithm/Clustering/Kmeans.php b/Algorithm/Clustering/Kmeans.php index dd85d1d8a..f78032e81 100755 --- a/Algorithm/Clustering/Kmeans.php +++ b/Algorithm/Clustering/Kmeans.php @@ -74,7 +74,7 @@ final class Kmeans implements ClusteringInterface * * @since 1.0.0 */ - public function __construct(\Closure $metric = null) + public function __construct(?\Closure $metric = null) { $this->metric = $metric ?? function (PointInterface $a, PointInterface $b) { $aCoordinates = $a->coordinates; @@ -228,7 +228,7 @@ final class Kmeans implements ClusteringInterface foreach ($points as $key => $point) { $d[$key] = $this->nearestClusterCenter($point, $clusters)[1]; - $sum += $d[$key]; + $sum += $d[$key]; } $sum *= \mt_rand(0, \mt_getrandmax()) / \mt_getrandmax(); diff --git a/Algorithm/Clustering/MeanShift.php b/Algorithm/Clustering/MeanShift.php index b8346f686..c549dd267 100644 --- a/Algorithm/Clustering/MeanShift.php +++ b/Algorithm/Clustering/MeanShift.php @@ -102,7 +102,7 @@ final class MeanShift implements ClusteringInterface * * @since 1.0.0 */ - public function __construct(\Closure $metric = null, \Closure $kernel = null) + public function __construct(?\Closure $metric = null, ?\Closure $kernel = null) { $this->metric = $metric ?? function (PointInterface $a, PointInterface $b) { $aCoordinates = $a->coordinates; diff --git a/Algorithm/Clustering/Point.php b/Algorithm/Clustering/Point.php index 0157da8a6..d9c62f2fc 100755 --- a/Algorithm/Clustering/Point.php +++ b/Algorithm/Clustering/Point.php @@ -28,7 +28,7 @@ class Point implements PointInterface * Coordinates of the point * * @var array - * @sicne 1.0.0 + * @since 1.0.0 */ public array $coordinates = []; diff --git a/Algorithm/Frequency/Apriori.php b/Algorithm/Frequency/Apriori.php index 3a2063c0f..33ba7751f 100644 --- a/Algorithm/Frequency/Apriori.php +++ b/Algorithm/Frequency/Apriori.php @@ -17,7 +17,7 @@ namespace phpOMS\Algorithm\Frequency; /** * Apriori algorithm. * - * The algorithm cheks how often a set exists in a given set of sets. + * The algorithm checks how often a set exists in a given set of sets. * * @package phpOMS\Algorithm\Frequency * @license OMS License 2.0 @@ -39,7 +39,7 @@ final class Apriori /** * Generate all possible subsets * - * @param array $arr Array of eleements + * @param array $arr Array of elements * * @return array * diff --git a/Algorithm/Graph/MarkovChain.php b/Algorithm/Graph/MarkovChain.php index ea74bc960..93f50cde2 100644 --- a/Algorithm/Graph/MarkovChain.php +++ b/Algorithm/Graph/MarkovChain.php @@ -117,7 +117,7 @@ final class MarkovChain * * @since 1.0.0 */ - public function generate(int $length, array $start = null) : array + public function generate(int $length, ?array $start = null) : array { $orderKeys = \array_keys($this->data); $orderValues = \array_keys(\reset($this->data)); diff --git a/Algorithm/JobScheduling/Weighted.php b/Algorithm/JobScheduling/Weighted.php index f348f6346..d3770ed64 100755 --- a/Algorithm/JobScheduling/Weighted.php +++ b/Algorithm/JobScheduling/Weighted.php @@ -62,7 +62,7 @@ final class Weighted } /** - * Search for a none-conflicting job that comes befor a defined job + * Search for a none-conflicting job that comes before a defined job * * @param JobInterface[] $jobs List of jobs * @param int $pivot Job to find the previous job to @@ -130,7 +130,7 @@ final class Weighted if ($l != -1) { $value += $valueTable[$l]; - $jList = \array_merge($resultTable[$l], $jList); + $jList = \array_merge($resultTable[$l], $jList); } if ($value > $valueTable[$i - 1]) { diff --git a/Algorithm/Knapsack/Backpack.php b/Algorithm/Knapsack/Backpack.php index d0d72e478..1ea278ab9 100755 --- a/Algorithm/Knapsack/Backpack.php +++ b/Algorithm/Knapsack/Backpack.php @@ -106,7 +106,7 @@ class Backpack implements BackpackInterface public function addItem(ItemInterface $item, int | float $quantity = 1) : void { $this->items[] = ['item' => $item, 'quantity' => $quantity]; - $this->value += $item->getValue() * $quantity; - $this->cost += $item->getCost() * $quantity; + $this->value += $item->getValue() * $quantity; + $this->cost += $item->getCost() * $quantity; } } diff --git a/Algorithm/Optimization/GeneticOptimization.php b/Algorithm/Optimization/GeneticOptimization.php index 6c7fdccc1..e8495ddb5 100644 --- a/Algorithm/Optimization/GeneticOptimization.php +++ b/Algorithm/Optimization/GeneticOptimization.php @@ -80,9 +80,9 @@ class GeneticOptimization * * @example See unit test for example use case * - * @param array $population List of all elements with ther parameters (i.e. list of "objects" as arrays). + * @param array $population List of all elements with their parameters (i.e. list of "objects" as arrays). * The constraints are defined as array values. - * @param \Closure $fitness Fitness function calculates score/feasability of solution + * @param \Closure $fitness Fitness function calculates score/feasibility of solution * @param \Closure $mutate Mutation function to change the parameters of an "object" * @param \Closure $crossover Crossover function to exchange parameter values between "objects". * Sometimes single parameters can be exchanged but sometimes interdependencies exist between parameters which is why this function is required. diff --git a/Algorithm/Optimization/SimulatedAnnealing.php b/Algorithm/Optimization/SimulatedAnnealing.php index 93136adcb..184d4bb74 100644 --- a/Algorithm/Optimization/SimulatedAnnealing.php +++ b/Algorithm/Optimization/SimulatedAnnealing.php @@ -40,7 +40,7 @@ class SimulatedAnnealing return $x; } - // can be many things, e.g. swapping parameters, increasing/decrising, random generation + // can be many things, e.g. swapping parameters, increasing/decreasing, random generation public static function neighbor(array $generation, $parameterCount) { $newGeneration = $generation; @@ -57,17 +57,17 @@ class SimulatedAnnealing */ // Simulated Annealing algorithm - // @todo allow to create a solution space (currently all soluctions need to be in space) + // @todo allow to create a solution space (currently all solutions need to be in space) // @todo currently only replacing generations, not altering them /** * Perform optimization * * @example See unit test for example use case * - * @param array $space List of all elements with ther parameters (i.e. list of "objects" as arrays). + * @param array $space List of all elements with their parameters (i.e. list of "objects" as arrays). * The constraints are defined as array values. * @param int $initialTemperature Starting temperature - * @param \Closure $costFunction Fitness function calculates score/feasability of solution + * @param \Closure $costFunction Fitness function calculates score/feasibility of solution * @param \Closure $neighbor Neighbor function to find a new solution/neighbor * @param float $coolingRate Rate at which cooling takes place * @param int $iterations Number of iterations diff --git a/Algorithm/PathFinding/Path.php b/Algorithm/PathFinding/Path.php index 92db7b5d7..80f0bc8d1 100755 --- a/Algorithm/PathFinding/Path.php +++ b/Algorithm/PathFinding/Path.php @@ -152,7 +152,7 @@ class Path } /** - * Find nodes in bettween two nodes. + * Find nodes in between two nodes. * * The path may only contain the jump points or pivot points. * In order to get every node it needs to be expanded. @@ -190,7 +190,7 @@ class Path if ($e2 > -$dy) { $err -= $dy; - $x0 += $sx; + $x0 += $sx; } if ($e2 < $dx) { diff --git a/Algorithm/Rating/Glicko2.php b/Algorithm/Rating/Glicko2.php index 8b19528ff..171ee9687 100644 --- a/Algorithm/Rating/Glicko2.php +++ b/Algorithm/Rating/Glicko2.php @@ -119,7 +119,7 @@ final class Glicko2 // Step 0: $rdOld /= self::Q; - $elo = ($elo - $this->DEFAULT_ELO) / self::Q; + $elo = ($elo - $this->DEFAULT_ELO) / self::Q; foreach ($oElo as $idx => $value) { $oElo[$idx] = ($value - $this->DEFAULT_ELO) / self::Q; diff --git a/Algorithm/Rating/TrueSkill.php b/Algorithm/Rating/TrueSkill.php index 852d1986e..96e50e92e 100644 --- a/Algorithm/Rating/TrueSkill.php +++ b/Algorithm/Rating/TrueSkill.php @@ -50,11 +50,11 @@ class TrueSkill private float $drawProbability = 0.0; public function __construct( - float $mu = null, - float $sigma = null, - float $beta = null, - float $tau = null, - float $drawProbability = null) + ?float $mu = null, + ?float $sigma = null, + ?float $beta = null, + ?float $tau = null, + ?float $drawProbability = null) { $this->mu = $mu ?? self::DEFAULT_MU; $this->sigma = $sigma ?? self::DEFAULT_SIGMA; diff --git a/Api/Shipping/DHL/DHLInternationalShipping.php b/Api/Shipping/DHL/DHLInternationalShipping.php index 90d2abd71..bafc1e4e1 100644 --- a/Api/Shipping/DHL/DHLInternationalShipping.php +++ b/Api/Shipping/DHL/DHLInternationalShipping.php @@ -179,8 +179,8 @@ final class DHLInternationalShipping implements ShippingInterface */ public function authLogin( string $login, string $password, - string $client = null, - string $payload = null + ?string $client = null, + ?string $payload = null ) : int { $this->client = $client ?? $this->client; @@ -230,7 +230,7 @@ final class DHLInternationalShipping implements ShippingInterface */ public function authRedirectLogin( string $client, - string $redirect = null, + ?string $redirect = null, array $payload = [] ) : HttpRequest { @@ -349,17 +349,17 @@ final class DHLInternationalShipping implements ShippingInterface } $packages[] = [ - 'status' => [ + 'status' => [ 'code' => $package['status']['statusCode'], 'statusCode' => $package['status']['statusCode'], 'description' => $package['status']['status'], ], - 'deliveryDate' => new \DateTime($package['estimatedTimeOfDelivery']), - 'count' => $package['details']['totalNumberOfPieces'], - 'weight' => $package['details']['weight']['weight'], - 'weight_unit' => 'g', - 'activities' => $activities, - 'received' => [ + 'deliveryDate' => new \DateTime($package['estimatedTimeOfDelivery']), + 'count' => $package['details']['totalNumberOfPieces'], + 'weight' => $package['details']['weight']['weight'], + 'weight_unit' => 'g', + 'activities' => $activities, + 'received' => [ 'by' => $package['details']['proofOfDelivery']['familyName'], 'signature' => $package['details']['proofOfDelivery']['signatureUrl'], 'location' => '', diff --git a/Api/Shipping/DHL/DHLParcelDEShipping.php b/Api/Shipping/DHL/DHLParcelDEShipping.php index c66f232c4..c2b226be9 100644 --- a/Api/Shipping/DHL/DHLParcelDEShipping.php +++ b/Api/Shipping/DHL/DHLParcelDEShipping.php @@ -175,8 +175,8 @@ final class DHLParcelDEShipping implements ShippingInterface */ public function authLogin( string $login, string $password, - string $client = null, - string $payload = null + ?string $client = null, + ?string $payload = null ) : int { $this->apiKey = $client ?? $this->client; @@ -221,7 +221,7 @@ final class DHLParcelDEShipping implements ShippingInterface */ public function authRedirectLogin( string $client, - string $redirect = null, + ?string $redirect = null, array $payload = [] ) : HttpRequest { @@ -562,17 +562,17 @@ final class DHLParcelDEShipping implements ShippingInterface } $packages[] = [ - 'status' => [ + 'status' => [ 'code' => $package['status']['statusCode'], 'statusCode' => $package['status']['statusCode'], 'description' => $package['status']['status'], ], - 'deliveryDate' => new \DateTime($package['estimatedTimeOfDelivery']), - 'count' => $package['details']['totalNumberOfPieces'], - 'weight' => $package['details']['weight']['weight'], - 'weight_unit' => 'g', - 'activities' => $activities, - 'received' => [ + 'deliveryDate' => new \DateTime($package['estimatedTimeOfDelivery']), + 'count' => $package['details']['totalNumberOfPieces'], + 'weight' => $package['details']['weight']['weight'], + 'weight_unit' => 'g', + 'activities' => $activities, + 'received' => [ 'by' => $package['details']['proofOfDelivery']['familyName'], 'signature' => $package['details']['proofOfDelivery']['signatureUrl'], 'location' => '', @@ -595,7 +595,7 @@ final class DHLParcelDEShipping implements ShippingInterface * * @since 1.0.0 */ - public function getManifest(\DateTime $date = null) : array + public function getManifest(?\DateTime $date = null) : array { $base = self::$ENV === 'live' ? self::LIVE_URL : self::SANDBOX_URL; $uri = $base . '/parcel/de/shipping/' . self::API_VERSION .'/manifest'; diff --git a/Api/Shipping/ShippingInterface.php b/Api/Shipping/ShippingInterface.php index 871f57c46..df96b2495 100644 --- a/Api/Shipping/ShippingInterface.php +++ b/Api/Shipping/ShippingInterface.php @@ -44,7 +44,7 @@ use phpOMS\Message\Http\HttpRequest; interface ShippingInterface { /** - * Create request for authentication using login and passowrd + * Create request for authentication using login and password * * @param string $login Login name/email * @param string $password Password @@ -57,8 +57,8 @@ interface ShippingInterface */ public function authLogin( string $login, string $password, - string $client = null, - string $payload = null + ?string $client = null, + ?string $payload = null ) : int; /** @@ -71,7 +71,7 @@ interface ShippingInterface * Use tokenFromRedirect() to parse the token from the redirect after successful login. * * @param string $client Client information (e.g. client id) - * @param null|string $redirect Redirect page after successfull login + * @param null|string $redirect Redirect page after successful login * @param array $payload Other payload data * * @return HttpRequest Request which should be used to create the redirect (e.g. header("Location: $request->uri")) @@ -83,7 +83,7 @@ interface ShippingInterface */ public function authRedirectLogin( string $client, - string $redirect = null, + ?string $redirect = null, array $payload = [] ) : HttpRequest; diff --git a/Api/Shipping/UPS/UPSShipping.php b/Api/Shipping/UPS/UPSShipping.php index ad1f9ef94..2c77eb0f3 100644 --- a/Api/Shipping/UPS/UPSShipping.php +++ b/Api/Shipping/UPS/UPSShipping.php @@ -164,8 +164,8 @@ final class UPSShipping implements ShippingInterface */ public function authLogin( string $login, string $password, - string $client = null, - string $payload = null + ?string $client = null, + ?string $payload = null ) : int { $this->client = $client ?? $this->client; @@ -215,7 +215,7 @@ final class UPSShipping implements ShippingInterface */ public function authRedirectLogin( string $client, - string $redirect = null, + ?string $redirect = null, array $payload = [] ) : HttpRequest { @@ -557,7 +557,7 @@ final class UPSShipping implements ShippingInterface // Only required if shipper != shipFrom (e.g. pickup location != shipper) if (!empty($shipFrom)) { - $body['Shipment']['ShipFrom'] = [ + $body['Shipment']['ShipFrom'] = [ 'Name' => \substr($shipFrom['name'], 0, 35), 'AttentionName' => \substr($shipFrom['fao'], 0, 35), 'CompanyDisplayableName' => \substr($shipFrom['name'], 0, 35), @@ -620,12 +620,12 @@ final class UPSShipping implements ShippingInterface $packages[] = [ 'id' => $package['TrackingNumber'], 'label' => [ - 'code' => $package['ShippingLabel']['ImageFormat']['Code'], - 'url' => '', - 'barcode' => $package['PDF417'], - 'image' => $package['ShippingLabel']['GraphicImage'], - 'browser' => $package['HTMLImage'], - 'data' => '', + 'code' => $package['ShippingLabel']['ImageFormat']['Code'], + 'url' => '', + 'barcode' => $package['PDF417'], + 'image' => $package['ShippingLabel']['GraphicImage'], + 'browser' => $package['HTMLImage'], + 'data' => '', ], 'receipt' => [ 'code' => $package['ShippingReceipt']['ImageFormat']['Code'], @@ -731,17 +731,17 @@ final class UPSShipping implements ShippingInterface } $packages[] = [ - 'status' => [ + 'status' => [ 'code' => $package['status']['code'], 'statusCode' => $package['status']['statusCode'], 'description' => $package['status']['description'], ], - 'deliveryDate' => new \DateTime($package['deliveryDate'] . ' ' . $package['deliveryTime']['endTime']), - 'count' => $package['packageCount'], - 'weight' => $package['weight']['weight'], - 'weight_unit' => $package['weight']['unitOfMeasurement'], - 'activities' => $activities, - 'received' => [ + 'deliveryDate' => new \DateTime($package['deliveryDate'] . ' ' . $package['deliveryTime']['endTime']), + 'count' => $package['packageCount'], + 'weight' => $package['weight']['weight'], + 'weight_unit' => $package['weight']['unitOfMeasurement'], + 'activities' => $activities, + 'received' => [ 'by' => $package['deliveryInformation']['receivedBy'], 'signature' => $package['deliveryInformation']['signature'], 'location' => $package['deliveryInformation']['location'], diff --git a/Application/StatusAbstract.php b/Application/StatusAbstract.php index 2d41ba886..ca59221fd 100755 --- a/Application/StatusAbstract.php +++ b/Application/StatusAbstract.php @@ -63,7 +63,7 @@ abstract class StatusAbstract * * @since 1.0.0 */ - public static function activateRoutes(ApplicationInfo $appInfo = null) : void + public static function activateRoutes(?ApplicationInfo $appInfo = null) : void { self::installRoutesHooks(static::PATH . '/../Routes.php', static::PATH . '/../Admin/Install/Application/Routes.php'); } @@ -77,7 +77,7 @@ abstract class StatusAbstract * * @since 1.0.0 */ - public static function activateHooks(ApplicationInfo $appInfo = null) : void + public static function activateHooks(?ApplicationInfo $appInfo = null) : void { self::installRoutesHooks(static::PATH . '/../Hooks.php', static::PATH . '/../Admin/Install/Application/Hooks.php'); } diff --git a/Auth/LoginReturnType.php b/Auth/LoginReturnType.php index 5c7fca4eb..33f28487a 100755 --- a/Auth/LoginReturnType.php +++ b/Auth/LoginReturnType.php @@ -28,7 +28,7 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class LoginReturnType extends Enum { - public const OK = 0; /* Everything is ok and the user got authed */ + public const OK = 0; /* Everything is ok and the user got authenticated */ public const FAILURE = -1; /* Authentication resulted in a unexpected failure */ diff --git a/AutoloadException.php b/AutoloadException.php index 2a0ba5335..1c3f3c0fc 100755 --- a/AutoloadException.php +++ b/AutoloadException.php @@ -35,7 +35,7 @@ final class AutoloadException extends \RuntimeException * * @since 1.0.0 */ - public function __construct(string $message, int $code = 0, \Exception $previous = null) + public function __construct(string $message, int $code = 0, ?\Exception $previous = null) { parent::__construct('File "' . $message . '" could not get loaded.', $code, $previous); } diff --git a/Business/Finance/FinanceFormulas.php b/Business/Finance/FinanceFormulas.php index b3638498e..e1559078c 100755 --- a/Business/Finance/FinanceFormulas.php +++ b/Business/Finance/FinanceFormulas.php @@ -278,7 +278,7 @@ final class FinanceFormulas * * @since 1.0.0 */ - public static function getAnnutiyPaymentFactorPV(float $r, int $n) : float + public static function getAnnuityPaymentFactorPV(float $r, int $n) : float { return $r / (1 - \pow(1 + $r, -$n)); } @@ -561,7 +561,7 @@ final class FinanceFormulas * * @since 1.0.0 */ - public static function getPrincipalOfCompundInterest(float $C, float $r, int $n) : float + public static function getPrincipalOfCompoundInterest(float $C, float $r, int $n) : float { return $C / (\pow(1 + $r, $n) - 1); } @@ -577,7 +577,7 @@ final class FinanceFormulas * * @since 1.0.0 */ - public static function getPeriodsOfCompundInterest(float $P, float $C, float $r) : float + public static function getPeriodsOfCompoundInterest(float $P, float $C, float $r) : float { return \log($C / $P + 1) / \log(1 + $r); } diff --git a/Business/Marketing/NetPromoterScore.php b/Business/Marketing/NetPromoterScore.php index 2157b7799..660111cc7 100755 --- a/Business/Marketing/NetPromoterScore.php +++ b/Business/Marketing/NetPromoterScore.php @@ -127,7 +127,7 @@ final class NetPromoterScore /** * Count promoters * - * Promotoers are all ratings larger 8 + * Promoters are all ratings larger 8 * * @return int Returns the amount of promoters (>= 0) * diff --git a/Business/Marketing/PageRank.php b/Business/Marketing/PageRank.php index 7e0757650..641649b8a 100755 --- a/Business/Marketing/PageRank.php +++ b/Business/Marketing/PageRank.php @@ -106,7 +106,7 @@ final class PageRank * * @since 1.0.0 */ - public function calculateRanks(int $iterations = 20, array $startRank = null) : array + public function calculateRanks(int $iterations = 20, ?array $startRank = null) : array { if ($startRank !== null) { $this->pageRanks = $startRank; diff --git a/Business/Recommendation/BayesianPersonalizedRanking.php b/Business/Recommendation/BayesianPersonalizedRanking.php index 93d5e6d33..95e7a9894 100644 --- a/Business/Recommendation/BayesianPersonalizedRanking.php +++ b/Business/Recommendation/BayesianPersonalizedRanking.php @@ -39,7 +39,7 @@ final class BayesianPersonalizedRanking // num_factors determines the dimensionality of the latent factor space. // learning_rate controls the step size for updating the latent factors during optimization. - // regularization prevents overfitting by adding a penalty for large parameter values. + // regularization prevents over-fitting by adding a penalty for large parameter values. public function __construct(int $numFactors, float $learningRate, float $regularization) { $this->numFactors = $numFactors; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f4653b71..88c5d9ca5 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,12 +1,16 @@ -# Development - ## Development environment - The setup and configuration of the development environment is in the hands of every developer themselves. However, it is recommended to follow the setup instructions in the [Developer-Guide](https://github.com/Karaka-Management/Developer-Guide/blob/develop/general/setup.md). +The setup and configuration of the development environment is in the hands of every developer themselves. However, it is recommended to follow the setup instructions in the [Developer-Guide](https://github.com/Karaka-Management/Developer-Guide/blob/develop/general/setup.md). ## Code of conduct -Every organization member and contributor to the organization must follow the [code of conduct](../Policies & Guidelines/Code of conduct.md). +Every organization member and contributor to the organization must follow the [Code of Conduct](../Policies%20&%20Guidelines/Code%20of%20Conduct.md). + +## Becoming a contributor + +For public repositories you can immediately start by creating forks and pull requests. For private repositories which are necessary to setup the complete developer environment, feel free to request access. Please not that we may not immediately give you access to private repositories and instead will give you smaller tasks regarding public repositories. Please contact info@jingga.app for more details. (**R1**) + +For all contributions our [Contributor License Agreement "CLA"](https://github.com/Karaka-Management/Organization-Guide/blob/master/Processes/HR/Hiring/Individual%20Contributor%20License%20Agreement.md) comes into effect. (**R2**) ## Code changes @@ -14,58 +18,106 @@ Every organization member and contributor to the organization must follow the [c Generally, the development philosophy is result orientated. This means that anyone can propose tasks, pick up existing tasks or right away implement their code changes. However, implementing code changes without consulting with a senior developer in advance has a much higher risk of code changes not getting admitted. The easiest way to discuss a code change idea in advance are the github [issues](https://github.com/Karaka-Management/Karaka/issues) or [discussions](https://github.com/Karaka-Management/Karaka/discussions). -Developers are encouraged to pick open tasks with high priorities according to their own skill level. Senior developers may directly assign tasks to developers based on their importance. New developers may find it easier to start with a task that has a low priority as they often also have a lower difficulty. +Developers are encouraged to pick open tasks with high priorities according to their own skill level. Senior developers may directly assign tasks to developers based on their importance. New developers may find it easier to start with a task that has a low priority as they often also have a lower difficulty. -Open tasks can be found in the project overview: [PROJECT.md](https://github.com/orgs/Karaka-Management/projects/10) +Open tasks can be found in the project overview: [Todos](https://github.com/orgs/Karaka-Management/projects/10) -Tasks currently in development are prefixed in the priority column with an asterisk `*` and a name tag in the task description of the developer who is working on the task. +Tasks currently in development are prefixed in the priority column with an asterisk `*` and a name tag in the task description of the developer who is working on the task. -The open tasks are reviewed once a month by a senior developer. The senior developer updates the project overview if necessary and requests feedback regarding development status of important tasks under development. During this process important tasks may also get directly assigned to developers. This review is performed on a judgmental bases of the senior basis. +The open tasks are reviewed once a month by a senior developer. The senior developer updates the project overview if necessary and requests feedback regarding development status of important tasks under development. During this process important tasks may also get directly assigned to developers. This review is performed on a judgmental bases of the senior basis. -### Code style +### Quality -Code changes must follow the [style guidelines](https://github.com/Karaka-Management/Developer-Guide/tree/develop/standards). Additionally, the automatic code style inspection tools must return no errors, failures or warnings. Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review. +#### Code style -In rare cases errors, failures or warnings during the automatic inspection are acceptable. Reasons can be changes in the programming language, special cases which cannot, are difficult or must be individually configured in the inspection settings. If this is the case for a code change and if inspection configuration changes are necessary are decided by the senior developer performing the code review. +Code changes must follow the [style guidelines](https://github.com/Karaka-Management/Developer-Guide/tree/develop/standards) (**R3**). Additionally, the automatic code style inspection tools must return no errors, failures or warnings. Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review. (**R4**) -Automated checks which are run during the review process: +In rare cases errors, failures or warnings during the automatic inspection are acceptable. Reasons can be for example special cases which are difficult automatize or must be individually configured in the inspection settings. If this is the case for a code change and if inspection configuration changes are necessary are decided by the senior developer performing the code review. (**R5**) + +Automated checks which are run during the review process (**R4**): ```sh -php ./vendor/bin/phpcs --severity=1 ./ --standard="Build/Config/phpcs.xml" +php ./vendor/bin/phpcs ./ --standard="Build/Config/phpcs.xml" +php ./vendor/bin/php-cs-fixer fix ./ --config=Build/Config/.php-cs-fixer.php --allow-risky=yes +php ./vendor/bin/phpcbf --standard=Build/Config/phpcs.xml ./ +php ./vendor/bin/rector process --dry-run --config Build/Config/rector.php ./ npx eslint ./ -c ./Build/Config/.eslintrc.json ``` -### Tests +#### Tests -Code changes must follow the inspection guidelines (i.e. code coverage) mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md). Developers should check if the code changes comply with the inspection guidelines before submitting them. +Code changes must follow the inspection guidelines (i.e. code coverage) mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) (**R6**). Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review. (**R7**) -In rare cases it might be not possible to follow the inspection guidelines. In such cases the senior developer performing the code review may decide if the code change still gets accepted. +In rare cases it might be not possible to follow the inspection guidelines. In such cases the senior developer performing the code review may decide if the code change still gets accepted. (**R8**) -Automated tests which are run during the review process: +Automated tests which are run during the review process (**R7**): ```sh php ./vendor/bin/phpunit -c tests/PHPUnit/phpunit_default.xml -php ./vendor/bin/phpstan analyse --autoload-file=phpOMS/Autoloader.php -l 9 -c Build/Config/phpstan.neon ./ +php ./vendor/bin/phpstan analyse --no-progress -l 9 -c Build/Config/phpstan.neon ./ npx jasmine-node ./ ./cOMS/tests/test.sh ``` -Additional inspections which are run but might be ignored during the review depending on the use case are mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) as other checks. +Additional inspections which are run but might be ignored during the review depending on the use case are mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) as other checks. (**R7**) -### Demo +#### Performance -Some code changes may also require changes or extensions in the demo setup scripts. The demo setup script try to simulate a real world use case by generating and modifying mostly random data. This is also a good way to setup and “manually” test the code changes in a larger picture. The demo setup script can be found in the [demoSetup](https://github.com/Karaka-Management/demoSetup) repository. The demo setup script takes a long time due to the large amount of user input simulated data which is generated. Therefore it is recommended to run this only sporadically. +Developers should occasionaly check performance statistics. At this point no target metrics are defined. -### Code review +Since the primary application is a web based application a similar tool as the Google lighthouse tool can be used to inspect the application for best practicies which can significantly improve the application performance. The sitespeed.io tool shows potential performance improvements and slow pages. With the php trace and profiler enabled in the `php.ini` file the VM automatically generates profiling and trace reports for every web request. These can be found in the webgrind logs directory and inspected in webgrind and dropped into the trace visualizer for a flame chart visualization. With mysqldumpslow you can inspect slow sql queries which may need optimization. + +1. Automatic trace and benchmark generation with every web request in `/var/www/html/webgrind/Logs` +2. Webgrind view `http://vm_ip:82` +3. Trace visualization `http://vm_ip:81` + 1. Download the latest trace from `http://vm_ip:82/Logs` + 2. Drag and drop that downloaded `*.xt` file in the trace visualizer +4. `sitespeed.io ./Build/Helper/Scripts/sitespeedDemoUrls.txt -b chrome --outputFolder /var/www/html/sitespeed` +5. Slow query inspection. + +```sh +mysqldumpslow -t 10 /var/log/mysql/mysql-slow.log +mysqldumpslow -t 10 -s l /var/log/mysql/mysql-slow.log +``` + +#### Code review In addition to the automatic code review performed by the various inspection tools such as (phpcs, phpstan, phpunit, eslint and custom scripts) a senior developer must check the proposed code change before it is merged with the respective `develop` branch. Only upon the approval by the reviewer a code change requests gets merged as no other developers have permission in the software to make such code merges. In case a code change request is not approved the reviewer states the reason for the decision, this may include some tips and requests which will allow the contributor to make improvements so that the code change may get approved. -If the code reviewer only finds minor issues with the proposed code change the reviewer may make small changes to the proposed code change and inform the contributor to speed up the implementation process. Code reviewers are encouraged to do this with new contributors to avoid long iteration processes and to not discourage new developers. However, communication is key and severe issues with code change requests or if the contributor already made multiple code change requests in the past the reviewer should not implement the improvements by himself and rather decline the code change requests with his reasoning. +If the code reviewer only finds minor issues with the proposed code change the reviewer may make small changes to the proposed code change and inform the contributor to speed up the implementation process. Code reviewers are encouraged to do this with new contributors to avoid long iteration processes and to not discourage new developers. However, communication is key and severe issues with code change requests or if the contributor already made multiple code change requests in the past the reviewer should not implement the improvements by himself and rather decline the code change requests with his reasoning. (**R5**+**R8**) + +#### Demo + +Some code changes may also require changes or extensions in the demo setup scripts. The demo setup script try to simulate a real world use case by generating and modifying mostly random data. This is also a good way to setup and “manually” test the code changes in a larger picture. The demo setup script can be found in the [demoSetup](https://github.com/Karaka-Management/demoSetup) repository. The demo setup script takes a long time due to the large amount of user input simulated data which is generated. Therefore it is recommended to run this only sporadically. (**R9**) + +```sh +sudo -u www-data php -dxdebug.remote_enable=1 -dxdebug.start_with_request=yes -dxdebug.mode=coverage,develop,debug demoSetup/setup.php +``` + +#### Documentation + +Occasionally new code or code changes also require new documentation or documentation changes. Developers should make sure that the new code is also reflected in the existing documentation ([Developer-Guide](), [User-Guide]() and/or module documentation) or if additional documentation is necessary. + +#### Improvements, features, bugs + +If a developer (or employee in general) has an idea for an improvement, feature or finds a potential bug it should be reported at https://github.com/Karaka-Management/Karaka/issues. A senior developer has to check these issues and decide how to proceed with them. The decision how to proceed with the issue must be explained by the senior developer as a response in the issue. Possible steps are: + +* Accept the issue and put the task into the [Todos](https://github.com/orgs/Karaka-Management/projects/10) +* Dismiss the issue with an explanation ### Release flow +In case SCSS/CSS or JS files got changed they must get re-built locally before comitting the code change: + +```sh +npx esbuild Web/Backend/js/backend.js --bundle --outfile=Install/Application/Backend/js/backend.min.js --minify +scss cssOMS/styles.scss > cssOMS/styles.css +``` + +For JS you may also use the shorthand command `npm run build`. + Code changes must be performed in a new branch. A new branch can be created with: ```sh @@ -75,8 +127,70 @@ git checkout -b new-branch-name The name of the branch can be chosen freely however it is recommended to follow the following branch naming conventions: * `feature-*` for feature implementations +* `hotfix-*` for security related fixes/improvements * `bug-*` for bug fixes * `security-*` for security related fixes/improvements -* `general-*` for general improvements (i.e. code documentation improvements, code style improvements) +* `general-*` for general improvements (i.e. documentation, code style & performance improvements) -The senior developer who performs the code review merges the change request into the `develop` branch upon approval. \ No newline at end of file +```mermaid +%%{init: { 'gitGraph': {'mainBranchName': 'master'}} }%% + gitGraph + commit + branch hotfix-xxx + commit + checkout master + branch develop + checkout master + merge hotfix-xxx + checkout develop + branch bug-xxx + commit + commit + checkout hotfix-xxx + commit + checkout master + merge hotfix-xxx + checkout develop + merge bug-xxx + commit + checkout develop + branch feature-xxx + commit + commit + commit + checkout develop + merge feature-xxx + checkout master + merge develop + checkout develop + branch general-xxx + commit + checkout develop + merge general-xxx + branch security-xxx + commit + commit + checkout develop + merge security-xxx + checkout master + merge develop + +``` + +The senior developer who performs the code review merges the change request into the `develop` branch after their successful code review. Unsuccessful reviews lead to change requests by the original developer, other developers who can make the requested changes, changes by the senior developer who performed the review, or dismissal of the changed code. (**R10**) + +## Approved dependencies + +### Customer dependencies + +Developers may only rely on the dependencies defined in [Approved Customer Software]() when developing a solution. If new software should be added to this list or a different version is required developers should make a request with their team leader/head of department who forwards this requests if appropriate to the CTO and explain the reasoning for the different dependency needs. The CTO can decide if the dependency will be accepted. (**R11**) + +### Developer dependencies + +Developers may only rely on the dependencies defined in [IT Equipment & Software](). If new software should be added to this list or a different version is required developers should make a request with their team leader/head of department who forwards this requests if appropriate to the CTO and explain the reasoning for the different dependency needs. The CTO can decide if the dependency will be accepted. Changing the package managers such as `composer.json` or `package.json` is not allowed by anyone else than the CTO. (**R12**) + +## Other related documents + +* [Confidentiality Policy](../Policies%20&%20Guidelines/Confidentiality%20Policy.md) +* [Organization Activity Policy](../Policies%20&%20Guidelines/Organization%20Activity%20Policy.md) +* [Tutorials](./Development/Tutorials) \ No newline at end of file diff --git a/Config/SettingsInterface.php b/Config/SettingsInterface.php index 0e2b32536..d5c66caad 100755 --- a/Config/SettingsInterface.php +++ b/Config/SettingsInterface.php @@ -45,12 +45,12 @@ interface SettingsInterface extends OptionsInterface */ public function get( mixed $ids = null, - string | array $names = null, - int $unit = null, - int $app = null, - string $module = null, - int $group = null, - int $account = null + string | array|null $names = null, + ?int $unit = null, + ?int $app = null, + ?string $module = null, + ?int $group = null, + ?int $account = null ) : mixed; /** diff --git a/Contract/StreamInterface.php b/Contract/StreamInterface.php index 3233d2e33..21a64771a 100755 --- a/Contract/StreamInterface.php +++ b/Contract/StreamInterface.php @@ -51,7 +51,7 @@ interface StreamInterface * * @since 1.0.0 */ - public function getMetaData(string $key = null); + public function getMetaData(?string $key = null); /** * Get the stream resource @@ -72,7 +72,7 @@ interface StreamInterface * * @since 1.0.0 */ - public function setStream($stream, int $size = null) : self; + public function setStream($stream, ?int $size = null) : self; /** * Detach the current stream resource @@ -264,7 +264,7 @@ interface StreamInterface * * @since 1.0.0 */ - public function readLine(int $maxLength = null) : ?string; + public function readLine(?int $maxLength = null) : ?string; /** * Set custom data on the stream diff --git a/DataStorage/Cache/Connection/FileCache.php b/DataStorage/Cache/Connection/FileCache.php index e5c210295..1c4394631 100755 --- a/DataStorage/Cache/Connection/FileCache.php +++ b/DataStorage/Cache/Connection/FileCache.php @@ -94,7 +94,7 @@ final class FileCache extends ConnectionAbstract * * @since 1.0.0 */ - public function connect(array $data = null) : void + public function connect(?array $data = null) : void { $this->dbdata = $data; diff --git a/DataStorage/Cache/Connection/MemCached.php b/DataStorage/Cache/Connection/MemCached.php index 5051eafb6..16a5e3051 100755 --- a/DataStorage/Cache/Connection/MemCached.php +++ b/DataStorage/Cache/Connection/MemCached.php @@ -74,7 +74,7 @@ final class MemCached extends ConnectionAbstract * * @since 1.0.0 */ - public function connect(array $data = null) : void + public function connect(?array $data = null) : void { $this->dbdata = isset($data) ? $data : $this->dbdata; diff --git a/DataStorage/Cache/Connection/NullCache.php b/DataStorage/Cache/Connection/NullCache.php index f185cb45c..17900cb46 100755 --- a/DataStorage/Cache/Connection/NullCache.php +++ b/DataStorage/Cache/Connection/NullCache.php @@ -27,7 +27,7 @@ final class NullCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function connect(array $data = null) : void + public function connect(?array $data = null) : void { } diff --git a/DataStorage/Cache/Connection/RedisCache.php b/DataStorage/Cache/Connection/RedisCache.php index 6d5f66f10..2fad593b0 100755 --- a/DataStorage/Cache/Connection/RedisCache.php +++ b/DataStorage/Cache/Connection/RedisCache.php @@ -66,7 +66,7 @@ final class RedisCache extends ConnectionAbstract * * @since 1.0.0 */ - public function connect(array $data = null) : void + public function connect(?array $data = null) : void { $this->dbdata = isset($data) ? $data : $this->dbdata; diff --git a/DataStorage/Cache/Exception/InvalidConnectionConfigException.php b/DataStorage/Cache/Exception/InvalidConnectionConfigException.php index 6de40a997..109b47a15 100755 --- a/DataStorage/Cache/Exception/InvalidConnectionConfigException.php +++ b/DataStorage/Cache/Exception/InvalidConnectionConfigException.php @@ -33,7 +33,7 @@ final class InvalidConnectionConfigException extends \InvalidArgumentException * * @since 1.0.0 */ - public function __construct(string $message = '', int $code = 0, \Exception $previous = null) + public function __construct(string $message = '', int $code = 0, ?\Exception $previous = null) { parent::__construct('Invalid/missing config value for "' . $message . '".', $code, $previous); } diff --git a/DataStorage/Cookie/CookieJar.php b/DataStorage/Cookie/CookieJar.php index 96998654a..2e0f022a1 100755 --- a/DataStorage/Cookie/CookieJar.php +++ b/DataStorage/Cookie/CookieJar.php @@ -99,7 +99,7 @@ final class CookieJar mixed $value, int $expire = 86400, string $path = '/', - string $domain = null, + ?string $domain = null, bool $secure = false, bool $httpOnly = true, bool $overwrite = true diff --git a/DataStorage/DataStorageConnectionInterface.php b/DataStorage/DataStorageConnectionInterface.php index ef821fe67..4fa4d10ea 100755 --- a/DataStorage/DataStorageConnectionInterface.php +++ b/DataStorage/DataStorageConnectionInterface.php @@ -35,7 +35,7 @@ interface DataStorageConnectionInterface * * @since 1.0.0 */ - public function connect(array $data = null) : void; + public function connect(?array $data = null) : void; /** * Get the datastorage type. diff --git a/DataStorage/Database/Connection/ConnectionAbstract.php b/DataStorage/Database/Connection/ConnectionAbstract.php index 10a53f8e3..e28f57c44 100755 --- a/DataStorage/Database/Connection/ConnectionAbstract.php +++ b/DataStorage/Database/Connection/ConnectionAbstract.php @@ -161,7 +161,7 @@ abstract class ConnectionAbstract implements ConnectionInterface * * @since 1.0.0 */ - abstract public function connect(array $dbdata = null) : void; + abstract public function connect(?array $dbdata = null) : void; /** * Object destructor. diff --git a/DataStorage/Database/Connection/MysqlConnection.php b/DataStorage/Database/Connection/MysqlConnection.php index 7788b320e..a7671ccdc 100755 --- a/DataStorage/Database/Connection/MysqlConnection.php +++ b/DataStorage/Database/Connection/MysqlConnection.php @@ -58,7 +58,7 @@ final class MysqlConnection extends ConnectionAbstract /** * {@inheritdoc} */ - public function connect(array $dbdata = null) : void + public function connect(?array $dbdata = null) : void { if ($this->status === DatabaseStatus::OK) { return; diff --git a/DataStorage/Database/Connection/NullConnection.php b/DataStorage/Database/Connection/NullConnection.php index dc69cb11a..6194a1671 100755 --- a/DataStorage/Database/Connection/NullConnection.php +++ b/DataStorage/Database/Connection/NullConnection.php @@ -27,7 +27,7 @@ final class NullConnection extends ConnectionAbstract /** * {@inheritdoc} */ - public function connect(array $dbdata = null) : void + public function connect(?array $dbdata = null) : void { } diff --git a/DataStorage/Database/Connection/PostgresConnection.php b/DataStorage/Database/Connection/PostgresConnection.php index a04a93bfe..5167db1fb 100755 --- a/DataStorage/Database/Connection/PostgresConnection.php +++ b/DataStorage/Database/Connection/PostgresConnection.php @@ -58,7 +58,7 @@ final class PostgresConnection extends ConnectionAbstract /** * {@inheritdoc} */ - public function connect(array $dbdata = null) : void + public function connect(?array $dbdata = null) : void { if ($this->status === DatabaseStatus::OK) { return; diff --git a/DataStorage/Database/Connection/SQLiteConnection.php b/DataStorage/Database/Connection/SQLiteConnection.php index 0fa2354c5..7a731e129 100755 --- a/DataStorage/Database/Connection/SQLiteConnection.php +++ b/DataStorage/Database/Connection/SQLiteConnection.php @@ -66,7 +66,7 @@ final class SQLiteConnection extends ConnectionAbstract * * @since 1.0.0 */ - public function connect(array $dbdata = null) : void + public function connect(?array $dbdata = null) : void { if ($this->status === DatabaseStatus::OK) { return; diff --git a/DataStorage/Database/Connection/SqlServerConnection.php b/DataStorage/Database/Connection/SqlServerConnection.php index f76a92173..8a172c17b 100755 --- a/DataStorage/Database/Connection/SqlServerConnection.php +++ b/DataStorage/Database/Connection/SqlServerConnection.php @@ -58,7 +58,7 @@ final class SqlServerConnection extends ConnectionAbstract /** * {@inheritdoc} */ - public function connect(array $dbdata = null) : void + public function connect(?array $dbdata = null) : void { if ($this->status === DatabaseStatus::OK) { return; diff --git a/DataStorage/Database/Exception/InvalidConnectionConfigException.php b/DataStorage/Database/Exception/InvalidConnectionConfigException.php index 40413a2ae..633e6e0b5 100755 --- a/DataStorage/Database/Exception/InvalidConnectionConfigException.php +++ b/DataStorage/Database/Exception/InvalidConnectionConfigException.php @@ -33,7 +33,7 @@ final class InvalidConnectionConfigException extends \InvalidArgumentException * * @since 1.0.0 */ - public function __construct(string $message = '', int $code = 0, \Exception $previous = null) + public function __construct(string $message = '', int $code = 0, ?\Exception $previous = null) { parent::__construct('Missing config value for "' . $message . '".', $code, $previous); } diff --git a/DataStorage/Database/Exception/InvalidDatabaseTypeException.php b/DataStorage/Database/Exception/InvalidDatabaseTypeException.php index 53644eae1..d5cdb235b 100755 --- a/DataStorage/Database/Exception/InvalidDatabaseTypeException.php +++ b/DataStorage/Database/Exception/InvalidDatabaseTypeException.php @@ -33,7 +33,7 @@ final class InvalidDatabaseTypeException extends \InvalidArgumentException * * @since 1.0.0 */ - public function __construct(string $message = '', int $code = 0, \Exception $previous = null) + public function __construct(string $message = '', int $code = 0, ?\Exception $previous = null) { parent::__construct('Invalid database type "' . $message . '".', $code, $previous); } diff --git a/DataStorage/Database/Exception/InvalidMapperException.php b/DataStorage/Database/Exception/InvalidMapperException.php index 6ac6ec381..5f086372e 100755 --- a/DataStorage/Database/Exception/InvalidMapperException.php +++ b/DataStorage/Database/Exception/InvalidMapperException.php @@ -33,7 +33,7 @@ final class InvalidMapperException extends \RuntimeException * * @since 1.0.0 */ - public function __construct(string $message = '', int $code = 0, \Exception $previous = null) + public function __construct(string $message = '', int $code = 0, ?\Exception $previous = null) { if ($message === '') { parent::__construct('Empty mapper.', $code, $previous); diff --git a/DataStorage/Database/Mapper/DataMapperAbstract.php b/DataStorage/Database/Mapper/DataMapperAbstract.php index ef2e963db..e9eb0b162 100755 --- a/DataStorage/Database/Mapper/DataMapperAbstract.php +++ b/DataStorage/Database/Mapper/DataMapperAbstract.php @@ -152,7 +152,7 @@ abstract class DataMapperAbstract * * @since 1.0.0 */ - public function query(Builder $query = null) : self + public function query(?Builder $query = null) : self { $this->query = $query; diff --git a/DataStorage/Database/Mapper/DataMapperFactory.php b/DataStorage/Database/Mapper/DataMapperFactory.php index c32dc686a..233ee50b2 100755 --- a/DataStorage/Database/Mapper/DataMapperFactory.php +++ b/DataStorage/Database/Mapper/DataMapperFactory.php @@ -179,7 +179,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function reader(ConnectionAbstract $db = null) : ReadMapper + public static function reader(?ConnectionAbstract $db = null) : ReadMapper { return new ReadMapper(new static(), $db ?? self::$db); } @@ -193,7 +193,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function get(ConnectionAbstract $db = null) : ReadMapper + public static function get(?ConnectionAbstract $db = null) : ReadMapper { /** @var ReadMapper $reader */ $reader = new ReadMapper(new static(), $db ?? self::$db); @@ -210,7 +210,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function yield(ConnectionAbstract $db = null) : ReadMapper + public static function yield(?ConnectionAbstract $db = null) : ReadMapper { /** @var ReadMapper $reader */ $reader = new ReadMapper(new static(), $db ?? self::$db); @@ -227,7 +227,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function getRaw(ConnectionAbstract $db = null) : ReadMapper + public static function getRaw(?ConnectionAbstract $db = null) : ReadMapper { /** @var ReadMapper $reader */ $reader = new ReadMapper(new static(), $db ?? self::$db); @@ -244,7 +244,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function getRandom(ConnectionAbstract $db = null) : ReadMapper + public static function getRandom(?ConnectionAbstract $db = null) : ReadMapper { return (new ReadMapper(new static(), $db ?? self::$db))->getRandom(); } @@ -258,7 +258,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function count(ConnectionAbstract $db = null) : ReadMapper + public static function count(?ConnectionAbstract $db = null) : ReadMapper { return (new ReadMapper(new static(), $db ?? self::$db))->count(); } @@ -272,7 +272,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function sum(ConnectionAbstract $db = null) : ReadMapper + public static function sum(?ConnectionAbstract $db = null) : ReadMapper { return (new ReadMapper(new static(), $db ?? self::$db))->sum(); } @@ -286,7 +286,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function exists(ConnectionAbstract $db = null) : ReadMapper + public static function exists(?ConnectionAbstract $db = null) : ReadMapper { return (new ReadMapper(new static(), $db ?? self::$db))->exists(); } @@ -300,7 +300,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function has(ConnectionAbstract $db = null) : ReadMapper + public static function has(?ConnectionAbstract $db = null) : ReadMapper { return (new ReadMapper(new static(), $db ?? self::$db))->has(); } @@ -314,7 +314,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function getQuery(ConnectionAbstract $db = null) : Builder + public static function getQuery(?ConnectionAbstract $db = null) : Builder { return (new ReadMapper(new static(), $db ?? self::$db))->getQuery(); } @@ -328,7 +328,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function getAll(ConnectionAbstract $db = null) : ReadMapper + public static function getAll(?ConnectionAbstract $db = null) : ReadMapper { /** @var ReadMapper $reader */ $reader = new ReadMapper(new static(), $db ?? self::$db); @@ -345,7 +345,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function writer(ConnectionAbstract $db = null) : WriteMapper + public static function writer(?ConnectionAbstract $db = null) : WriteMapper { return new WriteMapper(new static(), $db ?? self::$db); } @@ -359,7 +359,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function create(ConnectionAbstract $db = null) : WriteMapper + public static function create(?ConnectionAbstract $db = null) : WriteMapper { return (new WriteMapper(new static(), $db ?? self::$db))->create(); } @@ -373,7 +373,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function updater(ConnectionAbstract $db = null) : UpdateMapper + public static function updater(?ConnectionAbstract $db = null) : UpdateMapper { return new UpdateMapper(new static(), $db ?? self::$db); } @@ -387,7 +387,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function update(ConnectionAbstract $db = null) : UpdateMapper + public static function update(?ConnectionAbstract $db = null) : UpdateMapper { return (new UpdateMapper(new static(), $db ?? self::$db))->update(); } @@ -401,7 +401,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function remover(ConnectionAbstract $db = null) : DeleteMapper + public static function remover(?ConnectionAbstract $db = null) : DeleteMapper { return new DeleteMapper(new static(), $db ?? self::$db); } @@ -415,7 +415,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function delete(ConnectionAbstract $db = null) : DeleteMapper + public static function delete(?ConnectionAbstract $db = null) : DeleteMapper { return (new DeleteMapper(new static(), $db ?? self::$db))->delete(); } @@ -463,7 +463,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function createBaseModel(array $data = null) : object + public static function createBaseModel(?array $data = null) : object { if (empty(static::FACTORY)) { $class = empty(static::MODEL) ? \substr(static::class, 0, -6) : static::MODEL; @@ -485,7 +485,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function getObjectId(object $obj, string $member = null, \ReflectionClass &$refClass = null) : mixed + public static function getObjectId(object $obj, ?string $member = null, ?\ReflectionClass &$refClass = null) : mixed { $propertyName = $member ?? static::COLUMNS[static::PRIMARYFIELD]['internal']; @@ -513,7 +513,7 @@ class DataMapperFactory * * @since 1.0.0 */ - public static function setObjectId(object $obj, mixed $objId, \ReflectionClass &$refClass = null) : void + public static function setObjectId(object $obj, mixed $objId, ?\ReflectionClass &$refClass = null) : void { $propertyName = static::COLUMNS[static::PRIMARYFIELD]['internal']; \settype($objId, static::COLUMNS[static::PRIMARYFIELD]['type']); @@ -569,18 +569,18 @@ class DataMapperFactory * @since 1.0.0 */ public static function find( - string $search = null, - DataMapperAbstract $mapper = null, + ?string $search = null, + ?DataMapperAbstract $mapper = null, int $id = 0, string $secondaryId = '', - string $type = null, + ?string $type = null, int $pageLimit = 25, - string $sortBy = null, + ?string $sortBy = null, string $sortOrder = OrderType::DESC, array $searchFields = [], array $filters = [] ) : array { - $mapper ??= static::getAll(); + $mapper ??= static::getAll(); $sortOrder = \strtoupper($sortOrder); $data = []; @@ -680,7 +680,7 @@ class DataMapperFactory --$count; } } else { - if (\reset($data)->getId() === $id) { + if (\reset($data)->id === $id) { \array_shift($data); $hasNext = true; --$count; @@ -723,7 +723,7 @@ class DataMapperFactory ]; } - if (\reset($data)->getId() === $id) { + if (\reset($data)->id === $id) { \array_shift($data); $hasPrevious = true; --$count; diff --git a/DataStorage/Database/Mapper/DeleteMapper.php b/DataStorage/Database/Mapper/DeleteMapper.php index c68ab7877..7a79ec264 100755 --- a/DataStorage/Database/Mapper/DeleteMapper.php +++ b/DataStorage/Database/Mapper/DeleteMapper.php @@ -119,7 +119,7 @@ final class DeleteMapper extends DataMapperAbstract * * @since 1.0.0 */ - private function deleteSingleRelation(object $obj, array $relation, \ReflectionClass &$refClass = null) : void + private function deleteSingleRelation(object $obj, array $relation, ?\ReflectionClass &$refClass = null) : void { if (empty($relation)) { return; @@ -166,7 +166,7 @@ final class DeleteMapper extends DataMapperAbstract * * @since 1.0.0 */ - private function deleteHasMany(object $obj, mixed $objId, \ReflectionClass &$refClass = null) : void + private function deleteHasMany(object $obj, mixed $objId, ?\ReflectionClass &$refClass = null) : void { if (empty($this->mapper::HAS_MANY)) { return; @@ -237,7 +237,7 @@ final class DeleteMapper extends DataMapperAbstract * * @since 1.0.0 */ - public function deleteRelationTable(string $member, array $objIds = null, mixed $objId) : void + public function deleteRelationTable(string $member, ?array $objIds = null, mixed $objId) : void { if ((empty($objIds) && $objIds !== null) || $this->mapper::HAS_MANY[$member]['table'] === $this->mapper::TABLE diff --git a/DataStorage/Database/Mapper/ReadMapper.php b/DataStorage/Database/Mapper/ReadMapper.php index 4c7e54e8a..bc493f372 100755 --- a/DataStorage/Database/Mapper/ReadMapper.php +++ b/DataStorage/Database/Mapper/ReadMapper.php @@ -258,7 +258,7 @@ final class ReadMapper extends DataMapperAbstract * * @since 1.0.0 */ - public function executeGet(Builder $query = null) : mixed + public function executeGet(?Builder $query = null) : mixed { $primaryKeys = []; $memberOfPrimaryField = $this->mapper::COLUMNS[$this->mapper::PRIMARYFIELD]['internal']; @@ -293,7 +293,7 @@ final class ReadMapper extends DataMapperAbstract // it cannot get assigned to the correct parent object. // Other relation types are easy because either the parent or child object contain the relation info. // One solution could be to always pass an array - if (!empty($this->with)) { + if (!empty($this->with) && !empty($value)) { $this->loadHasManyRelations($obj[$value]); } } @@ -317,7 +317,7 @@ final class ReadMapper extends DataMapperAbstract * * @since 1.0.0 */ - public function executeGetYield(Builder $query = null) + public function executeGetYield(?Builder $query = null) { $primaryKeys = []; $memberOfPrimaryField = $this->mapper::COLUMNS[$this->mapper::PRIMARYFIELD]['internal']; @@ -350,7 +350,7 @@ final class ReadMapper extends DataMapperAbstract * * @since 1.0.0 */ - public function executeGetRaw(Builder $query = null) : array + public function executeGetRaw(?Builder $query = null) : array { $query ??= $this->getQuery(); $results = false; @@ -385,7 +385,7 @@ final class ReadMapper extends DataMapperAbstract * * @since 1.0.0 */ - public function executeGetRawYield(Builder $query = null) + public function executeGetRawYield(?Builder $query = null) { $query ??= $this->getQuery(); @@ -426,7 +426,7 @@ final class ReadMapper extends DataMapperAbstract * * @since 1.0.0 */ - public function executeGetAll(Builder $query = null) : array + public function executeGetAll(?Builder $query = null) : array { $result = $this->executeGet($query); @@ -537,7 +537,7 @@ final class ReadMapper extends DataMapperAbstract * * @since 1.0.0 */ - public function getQuery(Builder $query = null, array $columns = []) : Builder + public function getQuery(?Builder $query = null, array $columns = []) : Builder { $query ??= $this->query ?? new Builder($this->db, true); @@ -1243,7 +1243,7 @@ final class ReadMapper extends DataMapperAbstract $refClass = null; // @todo check if there are more cases where the relation is already loaded with joins etc. - // there can be pseudo hasMany elements like localizations. They are has manies but these are already loaded with joins! + // there can be pseudo hasMany elements like localizations. They are hasMany but these are already loaded with joins! foreach ($this->with as $member => $withData) { if (isset($this->mapper::HAS_MANY[$member])) { $many = $this->mapper::HAS_MANY[$member]; diff --git a/DataStorage/Database/Mapper/UpdateMapper.php b/DataStorage/Database/Mapper/UpdateMapper.php index 954d4ce96..2b1cb76b9 100755 --- a/DataStorage/Database/Mapper/UpdateMapper.php +++ b/DataStorage/Database/Mapper/UpdateMapper.php @@ -102,7 +102,7 @@ final class UpdateMapper extends DataMapperAbstract * * @since 1.0.0 */ - private function updateModel(object $obj, mixed $objId, \ReflectionClass &$refClass = null) : void + private function updateModel(object $obj, mixed $objId, ?\ReflectionClass &$refClass = null) : void { try { // Model doesn't have anything to update @@ -193,6 +193,14 @@ final class UpdateMapper extends DataMapperAbstract /** @var class-string $mapper */ $mapper = $this->mapper::BELONGS_TO[$propertyName]['mapper']; + if (!isset($this->with[$propertyName])) { + $id = $mapper::getObjectId($obj); + + return empty($id) && $mapper::isNullModel($obj) + ? null + : $id; + } + /** @var self $relMapper */ $relMapper = $this->createRelationMapper($mapper::update(db: $this->db), $propertyName); $relMapper->depth = $this->depth + 1; @@ -215,6 +223,14 @@ final class UpdateMapper extends DataMapperAbstract /** @var class-string $mapper */ $mapper = $this->mapper::OWNS_ONE[$propertyName]['mapper']; + if (!isset($this->with[$propertyName])) { + $id = $mapper::getObjectId($obj); + + return empty($id) && $mapper::isNullModel($obj) + ? null + : $id; + } + /** @var self $relMapper */ $relMapper = $this->createRelationMapper($mapper::update(db: $this->db), $propertyName); $relMapper->depth = $this->depth + 1; @@ -235,7 +251,7 @@ final class UpdateMapper extends DataMapperAbstract * * @since 1.0.0 */ - private function updateHasMany(object $obj, mixed $objId, \ReflectionClass &$refClass = null) : void + private function updateHasMany(object $obj, mixed $objId, ?\ReflectionClass &$refClass = null) : void { if (empty($this->with) || empty($this->mapper::HAS_MANY)) { return; diff --git a/DataStorage/Database/Mapper/WriteMapper.php b/DataStorage/Database/Mapper/WriteMapper.php index 24c38c968..0c12fda7a 100755 --- a/DataStorage/Database/Mapper/WriteMapper.php +++ b/DataStorage/Database/Mapper/WriteMapper.php @@ -74,20 +74,16 @@ final class WriteMapper extends DataMapperAbstract */ public function executeCreate(object $obj) : mixed { - $refClass = null; - - if ($this->mapper::isNullModel($obj)) { - $objId = $this->mapper::getObjectId($obj); - + $objId = $this->mapper::getObjectId($obj); + if ((!empty($objId) && $this->mapper::AUTOINCREMENT) + || $this->mapper::isNullModel($obj) + ) { return $objId === 0 ? null : $objId; } - if (!empty($id = $this->mapper::getObjectId($obj)) && $this->mapper::AUTOINCREMENT) { - $objId = $id; - } else { - $objId = $this->createModel($obj, $refClass); - $this->mapper::setObjectId($obj, $objId, $refClass); - } + $refClass = null; + $objId = $this->createModel($obj, $refClass); + $this->mapper::setObjectId($obj, $objId, $refClass); $this->createHasMany($obj, $objId, $refClass); @@ -104,7 +100,7 @@ final class WriteMapper extends DataMapperAbstract * * @since 1.0.0 */ - private function createModel(object $obj, \ReflectionClass &$refClass = null) : mixed + private function createModel(object $obj, ?\ReflectionClass &$refClass = null) : mixed { try { $query = new Builder($this->db); @@ -246,7 +242,9 @@ final class WriteMapper extends DataMapperAbstract $primaryKey = $mapper::getObjectId($obj); // @todo the $mapper::create() might cause a problem if 'by' is set. because we don't want to create this obj but the child obj. - return empty($primaryKey) ? $mapper::create(db: $this->db)->execute($obj) : $primaryKey; + return empty($primaryKey) + ? $mapper::create(db: $this->db)->execute($obj) + : $primaryKey; } /** @@ -262,7 +260,7 @@ final class WriteMapper extends DataMapperAbstract * * @since 1.0.0 */ - private function createHasMany(object $obj, mixed $objId, \ReflectionClass &$refClass = null) : void + private function createHasMany(object $obj, mixed $objId, ?\ReflectionClass &$refClass = null) : void { foreach ($this->mapper::HAS_MANY as $propertyName => $rel) { if (!isset($this->mapper::HAS_MANY[$propertyName]['mapper'])) { @@ -346,7 +344,7 @@ final class WriteMapper extends DataMapperAbstract if ($isRelPrivate) { $relProperty->setValue($value, $this->mapper::createNullModel($objId)); } else { - $value->{$internalName} = $this->mapper::createNullModel($objId); + $value->{$internalName} = $this->mapper::createNullModel($objId); } } elseif ($isRelPrivate) { $relProperty->setValue($value, $objId); diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index e4100081f..370083c68 100755 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -538,7 +538,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function where(string | array | self $columns, string | array $operator = null, mixed $values = null, string | array $boolean = 'and') : self + public function where(string | array | self $columns, string | array|null $operator = null, mixed $values = null, string | array $boolean = 'and') : self { if (!\is_array($columns)) { $columns = [$columns]; @@ -577,7 +577,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function andWhere(string | array | Where $where, string | array $operator = null, mixed $values = null) : self + public function andWhere(string | array | Where $where, string | array|null $operator = null, mixed $values = null) : self { return $this->where($where, $operator, $values, 'and'); } @@ -593,7 +593,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function orWhere(string | array | self $where, string | array $operator = null, mixed $values = null) : self + public function orWhere(string | array | self $where, string | array|null $operator = null, mixed $values = null) : self { return $this->where($where, $operator, $values, 'or'); } @@ -976,7 +976,7 @@ class Builder extends BuilderAbstract { \end($this->values); - $key = \key($this->values); + $key = \key($this->values); $key ??= 0; if (\is_array($value)) { @@ -1097,7 +1097,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function join(string | self $table, string $type = JoinType::JOIN, string $alias = null) : self + public function join(string | self $table, string $type = JoinType::JOIN, ?string $alias = null) : self { $this->joins[$alias ?? $table] = ['type' => $type, 'table' => $table, 'alias' => $alias]; @@ -1114,7 +1114,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function leftJoin(string | self $table, string $alias = null) : self + public function leftJoin(string | self $table, ?string $alias = null) : self { return $this->join($table, JoinType::LEFT_JOIN, $alias); } @@ -1129,7 +1129,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function leftOuterJoin(string | self $table, string $alias = null) : self + public function leftOuterJoin(string | self $table, ?string $alias = null) : self { return $this->join($table, JoinType::LEFT_OUTER_JOIN, $alias); } @@ -1144,7 +1144,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function leftInnerJoin(string | self $table, string $alias = null) : self + public function leftInnerJoin(string | self $table, ?string $alias = null) : self { return $this->join($table, JoinType::LEFT_INNER_JOIN, $alias); } @@ -1159,7 +1159,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function rightJoin(string | self $table, string $alias = null) : self + public function rightJoin(string | self $table, ?string $alias = null) : self { return $this->join($table, JoinType::RIGHT_JOIN, $alias); } @@ -1174,7 +1174,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function rightOuterJoin(string | self $table, string $alias = null) : self + public function rightOuterJoin(string | self $table, ?string $alias = null) : self { return $this->join($table, JoinType::RIGHT_OUTER_JOIN, $alias); } @@ -1189,7 +1189,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function rightInnerJoin(string | self $table, string $alias = null) : self + public function rightInnerJoin(string | self $table, ?string $alias = null) : self { return $this->join($table, JoinType::RIGHT_INNER_JOIN, $alias); } @@ -1204,7 +1204,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function outerJoin(string | self $table, string $alias = null) : self + public function outerJoin(string | self $table, ?string $alias = null) : self { return $this->join($table, JoinType::OUTER_JOIN, $alias); } @@ -1219,7 +1219,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function innerJoin(string | self $table, string $alias = null) : self + public function innerJoin(string | self $table, ?string $alias = null) : self { return $this->join($table, JoinType::INNER_JOIN, $alias); } @@ -1234,7 +1234,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function crossJoin(string | self $table, string $alias = null) : self + public function crossJoin(string | self $table, ?string $alias = null) : self { return $this->join($table, JoinType::CROSS_JOIN, $alias); } @@ -1249,7 +1249,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function fullJoin(string | self $table, string $alias = null) : self + public function fullJoin(string | self $table, ?string $alias = null) : self { return $this->join($table, JoinType::FULL_JOIN, $alias); } @@ -1264,7 +1264,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function fullOuterJoin(string | self $table, string $alias = null) : self + public function fullOuterJoin(string | self $table, ?string $alias = null) : self { return $this->join($table, JoinType::FULL_OUTER_JOIN, $alias); } @@ -1296,7 +1296,7 @@ class Builder extends BuilderAbstract * * @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 + public function on(string | array $columns, string | array|null $operator = null, mixed $values = null, string | array $boolean = 'and', ?string $table = null) : self { if (!\is_array($columns)) { $columns = [$columns]; @@ -1307,7 +1307,7 @@ class Builder extends BuilderAbstract $joinCount = \count($this->joins) - 1; $i = 0; - $table ??= \array_keys($this->joins)[$joinCount]; + $table ??= \array_keys($this->joins)[$joinCount]; foreach ($columns as $column) { if (isset($operator[$i]) && !\in_array(\strtolower($operator[$i]), self::OPERATORS)) { @@ -1338,7 +1338,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function orOn(string | array $columns, string | array $operator = null, string | array $values = null) : self + public function orOn(string | array $columns, string | array|null $operator = null, string | array|null $values = null) : self { return $this->on($columns, $operator, $values, 'or'); } @@ -1354,7 +1354,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function andOn(string | array $columns, string | array $operator = null, string | array $values = null) : self + public function andOn(string | array $columns, string | array|null $operator = null, string | array|null $values = null) : self { return $this->on($columns, $operator, $values, 'and'); } diff --git a/DataStorage/Database/Query/Grammar/Grammar.php b/DataStorage/Database/Query/Grammar/Grammar.php index 1fb68e702..1b7597bdd 100755 --- a/DataStorage/Database/Query/Grammar/Grammar.php +++ b/DataStorage/Database/Query/Grammar/Grammar.php @@ -245,7 +245,7 @@ class Grammar extends GrammarAbstract * * @param Builder $query Builder * @param array $wheres Where elmenets - * @param bool $first Is first element (usefull for nesting) + * @param bool $first Is first element (useful for nesting) * * @return string * @@ -258,7 +258,7 @@ class Grammar extends GrammarAbstract foreach ($wheres as $where) { foreach ($where as $element) { $expression .= $this->compileWhereElement($element, $query, $first); - $first = false; + $first = false; } } @@ -293,7 +293,7 @@ class Grammar extends GrammarAbstract } elseif ($element['column'] instanceof \Closure) { $expression .= $element['column'](); } elseif ($element['column'] instanceof Where) { - $where = \rtrim($this->compileWhereQuery($element['column']), ';'); + $where = \rtrim($this->compileWhereQuery($element['column']), ';'); $expression .= '(' . (\str_starts_with($where, 'WHERE ') ? \substr($where, 6) : $where) . ')'; } elseif ($element['column'] instanceof Builder) { $expression .= '(' . \rtrim($element['column']->toSql(), ';') . ')'; @@ -302,7 +302,7 @@ class Grammar extends GrammarAbstract if (isset($element['value']) && (!empty($element['value']) || !\is_array($element['value']))) { $expression .= ' ' . \strtoupper($element['operator']) . ' ' . $this->compileValue($query, $element['value']); } elseif ($element['value'] === null && !($element['column'] instanceof Builder)) { - $operator = $element['operator'] === '=' ? 'IS' : 'IS NOT'; + $operator = $element['operator'] === '=' ? 'IS' : 'IS NOT'; $expression .= ' ' . $operator . ' ' . $this->compileValue($query, $element['value']); } @@ -415,7 +415,7 @@ class Grammar extends GrammarAbstract foreach ($ons as $on) { $expression .= $this->compileOnElement($on, $query, $first); - $first = false; + $first = false; } if ($expression === '') { @@ -430,7 +430,7 @@ class Grammar extends GrammarAbstract * * @param array $element Element data * @param Builder $query Query builder - * @param bool $first Is first element (usefull for nesting) + * @param bool $first Is first element (useful for nesting) * * @return string * @@ -466,7 +466,7 @@ class Grammar extends GrammarAbstract $expression .= ' ' . \strtoupper($element['operator']) . ' ' . (\is_string($element['value']) ? $this->compileSystem($element['value']) : $element['value']); } else { - $operator = $element['operator'] === '=' ? 'IS' : 'IS NOT'; + $operator = $element['operator'] === '=' ? 'IS' : 'IS NOT'; $expression .= ' ' . $operator . ' ' . $this->compileValue($query, $element['value']); } diff --git a/DataStorage/Database/Schema/Builder.php b/DataStorage/Database/Schema/Builder.php index 29771d011..0d6a2bb59 100755 --- a/DataStorage/Database/Schema/Builder.php +++ b/DataStorage/Database/Schema/Builder.php @@ -272,7 +272,7 @@ class Builder extends BuilderAbstract public function field( string $name, string $type, $default = null, bool $isNullable = true, bool $isPrimary = false, bool $isUnique = false, bool $autoincrement = false, - string $foreignTable = null, string $foreignKey = null, array $meta = [] + ?string $foreignTable = null, ?string $foreignKey = null, array $meta = [] ) : self { $this->createFields[$name] = [ 'name' => $name, @@ -318,7 +318,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function addConstraint(string $key, string $foreignTable, string $foreignKey, string $constraint = null) : self + public function addConstraint(string $key, string $foreignTable, string $foreignKey, ?string $constraint = null) : self { $this->alterAdd['type'] = 'CONSTRAINT'; $this->alterAdd['key'] = $key; diff --git a/DataStorage/LockException.php b/DataStorage/LockException.php index 8a830d34d..abc9fa76f 100755 --- a/DataStorage/LockException.php +++ b/DataStorage/LockException.php @@ -36,7 +36,7 @@ final class LockException extends \RuntimeException * * @since 1.0.0 */ - public function __construct(string $message, int $code = 0, \Exception $previous = null) + public function __construct(string $message, int $code = 0, ?\Exception $previous = null) { parent::__construct('Interaction with "' . $message . '" already locked.', $code, $previous); } diff --git a/DataStorage/Session/HttpSession.php b/DataStorage/Session/HttpSession.php index ab5c88a21..4e6b688cc 100755 --- a/DataStorage/Session/HttpSession.php +++ b/DataStorage/Session/HttpSession.php @@ -66,13 +66,13 @@ final class HttpSession implements SessionInterface /** * Constructor. * - * @param int $liftetime Session life time + * @param int $lifetime Session life time * @param string $sid Session id * @param int $inactivityInterval Interval for session activity * * @since 1.0.0 */ - public function __construct(int $liftetime = 3600, string $sid = '', int $inactivityInterval = 0) + public function __construct(int $lifetime = 3600, string $sid = '', int $inactivityInterval = 0) { if (\session_id()) { \session_write_close(); // @codeCoverageIgnore @@ -86,8 +86,17 @@ final class HttpSession implements SessionInterface if (\session_status() !== \PHP_SESSION_ACTIVE && !\headers_sent()) { // @codeCoverageIgnoreStart + // samesite: Strict results in losing sessions in some situations when working with iframe + // This can happen when the iframe content uses relative links + // -> loads iframe page + // -> iframe page references relative resources (css, js, ...) + // -> client browser tries to load resources + // -> client browser loads current app based on relative link but without session cookie + // -> creates new session cookie for page (not authenticated yet) + // -> loses authentication on iframe parent + // samesite: None would solve that but is way too dangerous. \session_set_cookie_params([ - 'lifetime' => $liftetime, + 'lifetime' => $lifetime, 'path' => '/', 'domain' => '', 'secure' => false, @@ -97,8 +106,7 @@ final class HttpSession implements SessionInterface \session_start(); // @codeCoverageIgnoreEnd } else { - $logger = FileLogger::getInstance(); - $logger->error( + FileLogger::getInstance()->error( FileLogger::MSG_FULL, [ 'message' => 'Bad application flow.', 'line' => __LINE__, diff --git a/Dispatcher/Dispatcher.php b/Dispatcher/Dispatcher.php index e80ce2c9e..c256b69ff 100755 --- a/Dispatcher/Dispatcher.php +++ b/Dispatcher/Dispatcher.php @@ -53,7 +53,7 @@ final class Dispatcher implements DispatcherInterface * * @since 1.0.0 */ - public function __construct(ApplicationAbstract $app = null) + public function __construct(?ApplicationAbstract $app = null) { $this->app = $app; } @@ -112,7 +112,7 @@ final class Dispatcher implements DispatcherInterface * * @since 1.0.0 */ - private function dispatchString(string $controller, array $data = null) : array + private function dispatchString(string $controller, ?array $data = null) : array { $views = []; $dispatch = \explode(':', $controller); @@ -152,7 +152,7 @@ final class Dispatcher implements DispatcherInterface * * @since 1.0.0 */ - private function dispatchArray(array $controller, array $data = null) : array + private function dispatchArray(array $controller, ?array $data = null) : array { $views = []; foreach ($controller as $controllerSingle) { @@ -172,7 +172,7 @@ final class Dispatcher implements DispatcherInterface * * @since 1.0.0 */ - private function dispatchClosure(callable $controller, array $data = null) : mixed + private function dispatchClosure(callable $controller, ?array $data = null) : mixed { return $data === null ? $controller($this->app) : $controller($this->app, ...$data); } diff --git a/Event/EventManager.php b/Event/EventManager.php index bba4b3d73..c2ef3977a 100755 --- a/Event/EventManager.php +++ b/Event/EventManager.php @@ -21,7 +21,7 @@ use phpOMS\Dispatcher\DispatcherInterface; * EventManager class. * * The event manager allows to define events which can be triggered/executed in an application. - * This implementation allows to create sub-conditions which need to be met (triggered in advance) bevore the actual + * This implementation allows to create sub-conditions which need to be met (triggered in advance) before the actual * callback is getting executed. * * What happens after triggering an event (removing the callback, resetting the sub-conditions etc.) depends on the setup. @@ -64,7 +64,7 @@ final class EventManager implements \Countable * * @since 1.0.0 */ - public function __construct(Dispatcher $dispatcher = null) + public function __construct(?Dispatcher $dispatcher = null) { $this->dispatcher = $dispatcher ?? new class() implements DispatcherInterface { /** @@ -90,7 +90,7 @@ final class EventManager implements \Countable * return [ * '{EVENT_ID}' => [ * 'callback' => [ - * '{DESTINATION_NAMESPACE:method}', // can also be static by using :: between namespace and functio name + * '{DESTINATION_NAMESPACE:method}', // can also be static by using :: between namespace and function name * // more callbacks here * ], * ], @@ -159,7 +159,7 @@ final class EventManager implements \Countable /** * Trigger event based on regex for group and/or id. * - * This tigger function allows the group to be a regex in either this function call or in the definition of the group. + * This trigger function allows the group to be a regex in either this function call or in the definition of the group. * * @param string $group Name of the event (can be regex) * @param string $id Sub-requirement for event (can be regex) @@ -257,7 +257,7 @@ final class EventManager implements \Countable foreach ($this->callbacks[$group]['callbacks'] as $func) { if (\is_array($data)) { $data['@triggerGroup'] ??= $group; - $data['@triggerId'] = $id; + $data['@triggerId'] = $id; } else { $data = [ $data, diff --git a/Image/Kernel.php b/Image/Kernel.php index 924fc4388..37da68f93 100755 --- a/Image/Kernel.php +++ b/Image/Kernel.php @@ -169,7 +169,7 @@ final class Kernel for ($ky = 0; $ky < $kDim[0]; ++$ky) { for ($kx = 0; $kx < $kDim[1]; ++$kx) { - $pixel = \imagecolorat($im, + $pixel = \imagecolorat($im, \min(\max($x + $kx - $kWidthRadius, 0), $dim[0] - 1), \min(\max($y + $ky - $kHeightRadius, 0), $dim[1] - 1) ); diff --git a/Image/Skew.php b/Image/Skew.php index 246939649..6f4936ebc 100755 --- a/Image/Skew.php +++ b/Image/Skew.php @@ -72,7 +72,7 @@ final class Skew for ($i = $start[0]; $i < $end[0]; ++$i) { for ($j = $start[1]; $j < $end[1]; ++$j) { $imMatrix[$j - $start[1]][$i - $start[0]] = \imagecolorat($im, $i, $j) < 0.5 ? 1 : 0; - $avg += $imMatrix[$j - $start[1]][$i - $start[0]]; + $avg += $imMatrix[$j - $start[1]][$i - $start[0]]; } } diff --git a/LICENSE.txt b/LICENSE.txt index 18d430e7b..4ba0161ba 100755 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -27,7 +27,7 @@ Version 2.0 Subject to the terms and conditions of this License, each Contributor grants to You after purchase a perpetual, worldwide, non-exclusive, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform the Work and such Derivative Works in Source or Object form. You are not allowed to sublicense, reproduce, or distribute the Work and such Derivative Works in Source or Object form. -3. Redistribution. +3. Redistribution You may not reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form. diff --git a/Localization/BaseStringL11nType.php b/Localization/BaseStringL11nType.php index 551a4628b..3600e26c1 100644 --- a/Localization/BaseStringL11nType.php +++ b/Localization/BaseStringL11nType.php @@ -95,12 +95,12 @@ class BaseStringL11nType implements \JsonSerializable if ($l11n instanceof BaseStringL11n) { $this->l11n = $l11n; } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); + $this->l11n->content = $l11n; + $this->l11n->language = $lang; } else { - $this->l11n = new BaseStringL11n(); - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); + $this->l11n = new BaseStringL11n(); + $this->l11n->content = $l11n; + $this->l11n->language = $lang; } } diff --git a/Localization/Defaults/NullCity.php b/Localization/Defaults/NullCity.php index 4f74176ee..ce735c0d6 100755 --- a/Localization/Defaults/NullCity.php +++ b/Localization/Defaults/NullCity.php @@ -24,4 +24,15 @@ namespace phpOMS\Localization\Defaults; */ final class NullCity extends City { + /** + * Constructor + * + * @param int $id Model id + * + * @since 1.0.0 + */ + public function __construct(int $id = 0) + { + $this->id = $id; + } } diff --git a/Localization/Defaults/NullCountry.php b/Localization/Defaults/NullCountry.php index 2705484cc..918a7a44e 100755 --- a/Localization/Defaults/NullCountry.php +++ b/Localization/Defaults/NullCountry.php @@ -24,4 +24,15 @@ namespace phpOMS\Localization\Defaults; */ final class NullCountry extends Country { + /** + * Constructor + * + * @param int $id Model id + * + * @since 1.0.0 + */ + public function __construct(int $id = 0) + { + $this->id = $id; + } } diff --git a/Localization/Defaults/NullCurrency.php b/Localization/Defaults/NullCurrency.php index 13102f208..63e54fb33 100755 --- a/Localization/Defaults/NullCurrency.php +++ b/Localization/Defaults/NullCurrency.php @@ -24,4 +24,15 @@ namespace phpOMS\Localization\Defaults; */ final class NullCurrency extends Currency { + /** + * Constructor + * + * @param int $id Model id + * + * @since 1.0.0 + */ + public function __construct(int $id = 0) + { + $this->id = $id; + } } diff --git a/Localization/Defaults/NullIban.php b/Localization/Defaults/NullIban.php index 5a16e6916..29edc5d5d 100755 --- a/Localization/Defaults/NullIban.php +++ b/Localization/Defaults/NullIban.php @@ -24,4 +24,15 @@ namespace phpOMS\Localization\Defaults; */ final class NullIban extends Iban { + /** + * Constructor + * + * @param int $id Model id + * + * @since 1.0.0 + */ + public function __construct(int $id = 0) + { + $this->id = $id; + } } diff --git a/Localization/Defaults/NullLanguage.php b/Localization/Defaults/NullLanguage.php index 497c8a2c5..9fb9c5965 100755 --- a/Localization/Defaults/NullLanguage.php +++ b/Localization/Defaults/NullLanguage.php @@ -24,4 +24,15 @@ namespace phpOMS\Localization\Defaults; */ final class NullLanguage extends Language { + /** + * Constructor + * + * @param int $id Model id + * + * @since 1.0.0 + */ + public function __construct(int $id = 0) + { + $this->id = $id; + } } diff --git a/Localization/ISO3166Trait.php b/Localization/ISO3166Trait.php index 92c42706a..1a8ef9e09 100644 --- a/Localization/ISO3166Trait.php +++ b/Localization/ISO3166Trait.php @@ -135,6 +135,26 @@ trait ISO3166Trait self::getRegion('west-africa'), self::getRegion('central-africa') ); + case 'nato': + return [ + self::_ALB, self::_BEL, self::_BGR, self::_CAN, self::_HRV, + self::_CZE, self::_DNK, self::_EST, self::_FRA, self::_DEU, + self::_GRC, self::_HUN, self::_ISL, self::_ITA, self::_LVA, + self::_LTU, self::_LUX, self::_MNE, self::_NLD, self::_MKD, + self::_NOR, self::_POL, self::_PRT, self::_ROU, self::_SVK, + self::_SVN, self::_ESP, self::_TUR, self::_GBR, self::_USA, + self::_SWE, + ]; + case 'oecd': + return [ + self::_AUS, self::_NZL, self::_AUT, self::_NOR, self::_BEL, + self::_POL, self::_CAN, self::_PRT, self::_CHL, self::_SVK, + self::_DNK, self::_ESP, self::_EST, self::_SWE, self::_FIN, + self::_CHE, self::_FRA, self::_TUR, self::_DEU, self::_GBR, + self::_GRC, self::_USA, self::_HUN, self::_ISL, self::_IRL, + self::_ISR, self::_ITA, self::_JPN, self::_KOR, self::_LUX, + self::_MEX, self::_NLD, self::_CZE, self::_SVN, + ]; case 'eu': return [ self::_AUT, self::_BEL, self::_BGR, self::_HRV, self::_CYP, @@ -151,6 +171,16 @@ trait ISO3166Trait self::_ITA, self::_LVA, self::_LTU, self::_LUX, self::_MLT, self::_NLD, self::_PRT, self::_SVK, self::_SVN, self::_ESP, ]; + case 'schengen': + return [ + self::_AUT, self::_BEL, self::_HRV, + self::_CZE, self::_DNK, self::_EST, self::_FIN, self::_FRA, + self::_DEU, self::_GRC, self::_HUN, self::_ITA, + self::_LVA, self::_LTU, self::_LUX, self::_MLT, self::_NLD, + self::_POL, self::_PRT, self::_SVK, self::_SVN, + self::_ESP, self::_SWE, + self::_ISL, self::_NOR, self::_CHE, self::_LIE, + ]; case 'north-europe': return [ self::_ALA, self::_DNK, self::_EST, self::_FRO, self::_FIN, @@ -285,6 +315,19 @@ trait ISO3166Trait return [ self::_ATA, self::_ATF, ]; + case 'dach': + return [ + self::_DEU, self::_AUT, self::_CHE, + ]; + case 'g8': + return [ + self::_USA, self::_GBR, self::_FRA, self::_DEU, self::_ITA, + self::_CAN, self::_RUS, self::_JAP, + ]; + case 'p5': + return [ + self::_USA, self::_GBR, self::_FRA, self::_RUS, self::_CHN, + ]; default: return []; } diff --git a/Localization/L11nManager.php b/Localization/L11nManager.php index 05f2dbb04..4b6e49737 100755 --- a/Localization/L11nManager.php +++ b/Localization/L11nManager.php @@ -135,7 +135,7 @@ final class L11nManager * * @since 1.0.0 */ - public function getModuleLanguage(string $language, string $module = null) : array + public function getModuleLanguage(string $language, ?string $module = null) : array { if ($module === null && isset($this->language[$language])) { return $this->language[$language]; @@ -213,7 +213,7 @@ final class L11nManager * * @since 1.0.0 */ - public function getNumeric(Localization $l11n, int | float | FloatInt $numeric, string $format = null) : string + public function getNumeric(Localization $l11n, int | float | FloatInt $numeric, ?string $format = null) : string { if (!($numeric instanceof FloatInt)) { return \number_format( @@ -243,7 +243,7 @@ final class L11nManager * * @since 1.0.0 */ - public function getPercentage(Localization $l11n, float $percentage, string $format = null) : string + public function getPercentage(Localization $l11n, float $percentage, ?string $format = null) : string { return \number_format( $percentage, $l11n->getPrecision()[$format ?? 'medium'], @@ -268,13 +268,13 @@ final class L11nManager public function getCurrency( Localization $l11n, int | float | Money | FloatInt $currency, - string $symbol = null, - string $format = null, + ?string $symbol = null, + ?string $format = null, int $divide = 1 ) : string { $language = $l11n->language; - $symbol ??= $l11n->getCurrency(); + $symbol ??= $l11n->currency; if (\is_float($currency)) { $currency = (int) ($currency * \pow(10, Money::MAX_DECIMALS)); @@ -320,7 +320,7 @@ final class L11nManager * * @since 1.0.0 */ - public function getDateTime(Localization $l11n, \DateTimeInterface $datetime = null, string $format = null) : string + public function getDateTime(Localization $l11n, ?\DateTimeInterface $datetime = null, ?string $format = null) : string { return $datetime === null ? '' diff --git a/Localization/LanguageDetection/Language.php b/Localization/LanguageDetection/Language.php index f47d6286a..0a4662e9f 100755 --- a/Localization/LanguageDetection/Language.php +++ b/Localization/LanguageDetection/Language.php @@ -49,7 +49,7 @@ class Language extends NgramParser } elseif (!\is_dir($dirname) || !\is_readable($dirname)) { throw new \InvalidArgumentException('Provided directory could not be found or is not readable'); } else { - $dirname = \rtrim($dirname, '/'); + $dirname = \rtrim($dirname, '/'); $dirname .= '/*/*.php'; } @@ -93,8 +93,8 @@ class Language extends NgramParser foreach ($samples as $v) { if (isset($value[$v])) { - $x = $index++ - $value[$v]; - $y = $x >> (\PHP_INT_SIZE * 8); + $x = $index++ - $value[$v]; + $y = $x >> (\PHP_INT_SIZE * 8); $sum += ($x + $y) ^ $y; continue; diff --git a/Localization/LanguageDetection/LanguageResult.php b/Localization/LanguageDetection/LanguageResult.php index dc54b8c20..6495bf822 100755 --- a/Localization/LanguageDetection/LanguageResult.php +++ b/Localization/LanguageDetection/LanguageResult.php @@ -36,7 +36,7 @@ class LanguageResult implements \ArrayAccess, \IteratorAggregate, \JsonSerializa * Match values per language * * @var array - * @sicne 1.0.0 + * @since 1.0.0 */ private array $result = []; @@ -188,7 +188,7 @@ class LanguageResult implements \ArrayAccess, \IteratorAggregate, \JsonSerializa * * @since 1.0.0 */ - public function limit(int $offset, int $length = null) : self + public function limit(int $offset, ?int $length = null) : self { return new self(\array_slice($this->result, $offset, $length)); } diff --git a/Localization/LanguageDetection/Trainer.php b/Localization/LanguageDetection/Trainer.php index 9fbbc445a..cd6eb9e36 100755 --- a/Localization/LanguageDetection/Trainer.php +++ b/Localization/LanguageDetection/Trainer.php @@ -42,7 +42,7 @@ class Trainer extends NgramParser } elseif (!\is_dir($dirname) || !\is_readable($dirname)) { throw new \InvalidArgumentException('Provided directory could not be found or is not readable'); } else { - $dirname = \rtrim($dirname, '/'); + $dirname = \rtrim($dirname, '/'); $dirname .= '/*/*.txt'; } diff --git a/Localization/LanguageDetection/resources/ab/ab.php b/Localization/LanguageDetection/resources/ab/ab.php index 9900d161d..e7acb1b27 100755 --- a/Localization/LanguageDetection/resources/ab/ab.php +++ b/Localization/LanguageDetection/resources/ab/ab.php @@ -1,8 +1,7 @@ - [ + 'ab' => [ 0 => 'а', 1 => 'и', 2 => 'р', diff --git a/Localization/LanguageDetection/resources/af/af.php b/Localization/LanguageDetection/resources/af/af.php index 0b1c8f348..099ccc68a 100755 --- a/Localization/LanguageDetection/resources/af/af.php +++ b/Localization/LanguageDetection/resources/af/af.php @@ -1,8 +1,7 @@ - [ + 'af' => [ 0 => 'e', 1 => 'n', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/am/am.php b/Localization/LanguageDetection/resources/am/am.php index 77f9e8673..d21128b58 100755 --- a/Localization/LanguageDetection/resources/am/am.php +++ b/Localization/LanguageDetection/resources/am/am.php @@ -1,8 +1,7 @@ - [ + 'am' => [ 0 => 'ን', 1 => 'ት', 2 => 'ት_', diff --git a/Localization/LanguageDetection/resources/ar/ar.php b/Localization/LanguageDetection/resources/ar/ar.php index 61035f1e7..f14b47f85 100755 --- a/Localization/LanguageDetection/resources/ar/ar.php +++ b/Localization/LanguageDetection/resources/ar/ar.php @@ -1,8 +1,7 @@ - [ + 'ar' => [ 0 => 'ا', 1 => 'ل', 2 => 'ال', diff --git a/Localization/LanguageDetection/resources/ay/ay.php b/Localization/LanguageDetection/resources/ay/ay.php index e9dc659ae..4b338e279 100755 --- a/Localization/LanguageDetection/resources/ay/ay.php +++ b/Localization/LanguageDetection/resources/ay/ay.php @@ -1,8 +1,7 @@ - [ + 'ay' => [ 0 => 'a', 1 => 'i', 2 => 'k', diff --git a/Localization/LanguageDetection/resources/az-Cyrl/az-Cyrl.php b/Localization/LanguageDetection/resources/az-Cyrl/az-Cyrl.php index eaae9a271..847d83d7a 100755 --- a/Localization/LanguageDetection/resources/az-Cyrl/az-Cyrl.php +++ b/Localization/LanguageDetection/resources/az-Cyrl/az-Cyrl.php @@ -1,8 +1,7 @@ - [ + 'az-Cyrl' => [ 0 => 'ә', 1 => 'а', 2 => 'и', diff --git a/Localization/LanguageDetection/resources/az-Latn/az-Latn.php b/Localization/LanguageDetection/resources/az-Latn/az-Latn.php index cca7252de..273fc151a 100755 --- a/Localization/LanguageDetection/resources/az-Latn/az-Latn.php +++ b/Localization/LanguageDetection/resources/az-Latn/az-Latn.php @@ -1,8 +1,7 @@ - [ + 'az-Latn' => [ 0 => 'ə', 1 => 'a', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/be/be.php b/Localization/LanguageDetection/resources/be/be.php index f11b43194..c2acbca1e 100755 --- a/Localization/LanguageDetection/resources/be/be.php +++ b/Localization/LanguageDetection/resources/be/be.php @@ -1,8 +1,7 @@ - [ + 'be' => [ 0 => 'а', 1 => 'н', 2 => 'ы', diff --git a/Localization/LanguageDetection/resources/bg/bg.php b/Localization/LanguageDetection/resources/bg/bg.php index 13493588c..fc3f140ea 100755 --- a/Localization/LanguageDetection/resources/bg/bg.php +++ b/Localization/LanguageDetection/resources/bg/bg.php @@ -1,8 +1,7 @@ - [ + 'bg' => [ 0 => 'а', 1 => 'о', 2 => 'и', diff --git a/Localization/LanguageDetection/resources/bi/bi.php b/Localization/LanguageDetection/resources/bi/bi.php index bd827a197..a426fa181 100755 --- a/Localization/LanguageDetection/resources/bi/bi.php +++ b/Localization/LanguageDetection/resources/bi/bi.php @@ -1,8 +1,7 @@ - [ + 'bi' => [ 0 => 'o', 1 => 'e', 2 => 'a', diff --git a/Localization/LanguageDetection/resources/bn/bn.php b/Localization/LanguageDetection/resources/bn/bn.php index 2c852f1e1..62d1af187 100755 --- a/Localization/LanguageDetection/resources/bn/bn.php +++ b/Localization/LanguageDetection/resources/bn/bn.php @@ -1,8 +1,7 @@ - [ + 'bn' => [ 0 => '_র_', 1 => '_র', 2 => 'র_', diff --git a/Localization/LanguageDetection/resources/bo/bo.php b/Localization/LanguageDetection/resources/bo/bo.php index bc200c5bc..f62123880 100755 --- a/Localization/LanguageDetection/resources/bo/bo.php +++ b/Localization/LanguageDetection/resources/bo/bo.php @@ -1,8 +1,7 @@ - [ + 'bo' => [ 0 => 'ས_', 1 => '_ས_', 2 => 'ས', diff --git a/Localization/LanguageDetection/resources/br/br.php b/Localization/LanguageDetection/resources/br/br.php index 2c1579843..14b8f6ef0 100755 --- a/Localization/LanguageDetection/resources/br/br.php +++ b/Localization/LanguageDetection/resources/br/br.php @@ -1,8 +1,7 @@ - [ + 'br' => [ 0 => 'e', 1 => 'a', 2 => 'n', diff --git a/Localization/LanguageDetection/resources/bs-Cyrl/bs-Cyrl.php b/Localization/LanguageDetection/resources/bs-Cyrl/bs-Cyrl.php index 7cb0c28a7..b32fcfb54 100755 --- a/Localization/LanguageDetection/resources/bs-Cyrl/bs-Cyrl.php +++ b/Localization/LanguageDetection/resources/bs-Cyrl/bs-Cyrl.php @@ -1,8 +1,7 @@ - [ + 'bs-Cyrl' => [ 0 => 'а', 1 => 'и', 2 => 'о', diff --git a/Localization/LanguageDetection/resources/bs-Latn/bs-Latn.php b/Localization/LanguageDetection/resources/bs-Latn/bs-Latn.php index da584f07e..762105f9a 100755 --- a/Localization/LanguageDetection/resources/bs-Latn/bs-Latn.php +++ b/Localization/LanguageDetection/resources/bs-Latn/bs-Latn.php @@ -1,8 +1,7 @@ - [ + 'bs-Latn' => [ 0 => 'a', 1 => 'i', 2 => 'o', diff --git a/Localization/LanguageDetection/resources/ca/ca.php b/Localization/LanguageDetection/resources/ca/ca.php index 7701459eb..74fa39b14 100755 --- a/Localization/LanguageDetection/resources/ca/ca.php +++ b/Localization/LanguageDetection/resources/ca/ca.php @@ -1,8 +1,7 @@ - [ + 'ca' => [ 0 => 'e', 1 => 'a', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/ch/ch.php b/Localization/LanguageDetection/resources/ch/ch.php index 88fae9f85..6fcf112fe 100755 --- a/Localization/LanguageDetection/resources/ch/ch.php +++ b/Localization/LanguageDetection/resources/ch/ch.php @@ -1,8 +1,7 @@ - [ + 'ch' => [ 0 => 'a', 1 => 'i', 2 => 'n', diff --git a/Localization/LanguageDetection/resources/co/co.php b/Localization/LanguageDetection/resources/co/co.php index 9bea91ec6..10e1ec17e 100755 --- a/Localization/LanguageDetection/resources/co/co.php +++ b/Localization/LanguageDetection/resources/co/co.php @@ -1,8 +1,7 @@ - [ + 'co' => [ 0 => 'i', 1 => 'a', 2 => 'u', diff --git a/Localization/LanguageDetection/resources/cr/cr.php b/Localization/LanguageDetection/resources/cr/cr.php index acf54e2af..82547afce 100755 --- a/Localization/LanguageDetection/resources/cr/cr.php +++ b/Localization/LanguageDetection/resources/cr/cr.php @@ -1,8 +1,7 @@ - [ + 'cr' => [ 0 => 'ᓂ', 1 => 'ᑕ', 2 => 'ᑭ', diff --git a/Localization/LanguageDetection/resources/cs/cs.php b/Localization/LanguageDetection/resources/cs/cs.php index acde29a90..b84892e67 100755 --- a/Localization/LanguageDetection/resources/cs/cs.php +++ b/Localization/LanguageDetection/resources/cs/cs.php @@ -1,8 +1,7 @@ - [ + 'cs' => [ 0 => 'o', 1 => 'n', 2 => 'e', diff --git a/Localization/LanguageDetection/resources/cy/cy.php b/Localization/LanguageDetection/resources/cy/cy.php index aade5a244..1a32754df 100755 --- a/Localization/LanguageDetection/resources/cy/cy.php +++ b/Localization/LanguageDetection/resources/cy/cy.php @@ -1,8 +1,7 @@ - [ + 'cy' => [ 0 => 'a', 1 => 'd', 2 => 'y', diff --git a/Localization/LanguageDetection/resources/da/da.php b/Localization/LanguageDetection/resources/da/da.php index 39c7544dd..e73a4d5c2 100755 --- a/Localization/LanguageDetection/resources/da/da.php +++ b/Localization/LanguageDetection/resources/da/da.php @@ -1,8 +1,7 @@ - [ + 'da' => [ 0 => 'e', 1 => 'r', 2 => 'n', diff --git a/Localization/LanguageDetection/resources/de/de.php b/Localization/LanguageDetection/resources/de/de.php index 66d8a808d..3e6fbd3fc 100755 --- a/Localization/LanguageDetection/resources/de/de.php +++ b/Localization/LanguageDetection/resources/de/de.php @@ -1,8 +1,7 @@ - [ + 'de' => [ 0 => 'e', 1 => 'n', 2 => 'r', diff --git a/Localization/LanguageDetection/resources/dz/dz.php b/Localization/LanguageDetection/resources/dz/dz.php index dc7d3cd76..f8349afb2 100755 --- a/Localization/LanguageDetection/resources/dz/dz.php +++ b/Localization/LanguageDetection/resources/dz/dz.php @@ -1,8 +1,7 @@ - [ + 'dz' => [ 0 => 'ས_', 1 => '_ད', 2 => '_ག', diff --git a/Localization/LanguageDetection/resources/el-monoton/el-monoton.php b/Localization/LanguageDetection/resources/el-monoton/el-monoton.php index 614798d08..7d2e52179 100755 --- a/Localization/LanguageDetection/resources/el-monoton/el-monoton.php +++ b/Localization/LanguageDetection/resources/el-monoton/el-monoton.php @@ -1,8 +1,7 @@ - [ + 'el-monoton' => [ 0 => 'α', 1 => 'ι', 2 => 'ε', diff --git a/Localization/LanguageDetection/resources/el-polyton/el-polyton.php b/Localization/LanguageDetection/resources/el-polyton/el-polyton.php index cc09972b6..87357c376 100755 --- a/Localization/LanguageDetection/resources/el-polyton/el-polyton.php +++ b/Localization/LanguageDetection/resources/el-polyton/el-polyton.php @@ -1,8 +1,7 @@ - [ + 'el-polyton' => [ 0 => 'α', 1 => 'τ', 2 => 'ι', diff --git a/Localization/LanguageDetection/resources/en/en.php b/Localization/LanguageDetection/resources/en/en.php index 0771e1924..a5be3e423 100755 --- a/Localization/LanguageDetection/resources/en/en.php +++ b/Localization/LanguageDetection/resources/en/en.php @@ -1,8 +1,7 @@ - [ + 'en' => [ 0 => 'e', 1 => 't', 2 => 'n', diff --git a/Localization/LanguageDetection/resources/eo/eo.php b/Localization/LanguageDetection/resources/eo/eo.php index 6b93bed48..e4d23e3f7 100755 --- a/Localization/LanguageDetection/resources/eo/eo.php +++ b/Localization/LanguageDetection/resources/eo/eo.php @@ -1,8 +1,7 @@ - [ + 'eo' => [ 0 => 'a', 1 => 'e', 2 => 'o', diff --git a/Localization/LanguageDetection/resources/es/es.php b/Localization/LanguageDetection/resources/es/es.php index a63eb4983..e14dbc05f 100755 --- a/Localization/LanguageDetection/resources/es/es.php +++ b/Localization/LanguageDetection/resources/es/es.php @@ -1,8 +1,7 @@ - [ + 'es' => [ 0 => 'e', 1 => 'a', 2 => 'o', diff --git a/Localization/LanguageDetection/resources/et/et.php b/Localization/LanguageDetection/resources/et/et.php index 3928a8c77..667c48517 100755 --- a/Localization/LanguageDetection/resources/et/et.php +++ b/Localization/LanguageDetection/resources/et/et.php @@ -1,8 +1,7 @@ - [ + 'et' => [ 0 => 'a', 1 => 'e', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/eu/eu.php b/Localization/LanguageDetection/resources/eu/eu.php index 67ec09dab..8bd892015 100755 --- a/Localization/LanguageDetection/resources/eu/eu.php +++ b/Localization/LanguageDetection/resources/eu/eu.php @@ -1,8 +1,7 @@ - [ + 'eu' => [ 0 => 'a', 1 => 'e', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/fa/fa.php b/Localization/LanguageDetection/resources/fa/fa.php index 271a93e80..7ec1855b1 100755 --- a/Localization/LanguageDetection/resources/fa/fa.php +++ b/Localization/LanguageDetection/resources/fa/fa.php @@ -1,8 +1,7 @@ - [ + 'fa' => [ 0 => 'ا', 1 => 'ی', 2 => 'د', diff --git a/Localization/LanguageDetection/resources/fi/fi.php b/Localization/LanguageDetection/resources/fi/fi.php index 0efdcd4c4..f3358b645 100755 --- a/Localization/LanguageDetection/resources/fi/fi.php +++ b/Localization/LanguageDetection/resources/fi/fi.php @@ -1,8 +1,7 @@ - [ + 'fi' => [ 0 => 'a', 1 => 'i', 2 => 't', diff --git a/Localization/LanguageDetection/resources/fj/fj.php b/Localization/LanguageDetection/resources/fj/fj.php index 27f106019..92720806c 100755 --- a/Localization/LanguageDetection/resources/fj/fj.php +++ b/Localization/LanguageDetection/resources/fj/fj.php @@ -1,8 +1,7 @@ - [ + 'fj' => [ 0 => 'a', 1 => 'a_', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/fo/fo.php b/Localization/LanguageDetection/resources/fo/fo.php index 906ed60bb..e583b6a9d 100755 --- a/Localization/LanguageDetection/resources/fo/fo.php +++ b/Localization/LanguageDetection/resources/fo/fo.php @@ -1,8 +1,7 @@ - [ + 'fo' => [ 0 => 'a', 1 => 'i', 2 => 'r', diff --git a/Localization/LanguageDetection/resources/fr/fr.php b/Localization/LanguageDetection/resources/fr/fr.php index aacc5a6b6..07d782d8c 100755 --- a/Localization/LanguageDetection/resources/fr/fr.php +++ b/Localization/LanguageDetection/resources/fr/fr.php @@ -1,8 +1,7 @@ - [ + 'fr' => [ 0 => 'e', 1 => 't', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/fy/fy.php b/Localization/LanguageDetection/resources/fy/fy.php index 91f3b5c52..0c18b3abe 100755 --- a/Localization/LanguageDetection/resources/fy/fy.php +++ b/Localization/LanguageDetection/resources/fy/fy.php @@ -1,8 +1,7 @@ - [ + 'fy' => [ 0 => 'e', 1 => 'n', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/ga/ga.php b/Localization/LanguageDetection/resources/ga/ga.php index 22346226f..ef46ac8b2 100755 --- a/Localization/LanguageDetection/resources/ga/ga.php +++ b/Localization/LanguageDetection/resources/ga/ga.php @@ -1,8 +1,7 @@ - [ + 'ga' => [ 0 => 'a', 1 => 'i', 2 => 'h', diff --git a/Localization/LanguageDetection/resources/gd/gd.php b/Localization/LanguageDetection/resources/gd/gd.php index 5d5812af8..571dc7d75 100755 --- a/Localization/LanguageDetection/resources/gd/gd.php +++ b/Localization/LanguageDetection/resources/gd/gd.php @@ -1,8 +1,7 @@ - [ + 'gd' => [ 0 => 'a', 1 => 'h', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/gl/gl.php b/Localization/LanguageDetection/resources/gl/gl.php index c797f999b..ce0d43bef 100755 --- a/Localization/LanguageDetection/resources/gl/gl.php +++ b/Localization/LanguageDetection/resources/gl/gl.php @@ -1,8 +1,7 @@ - [ + 'gl' => [ 0 => 'e', 1 => 'a', 2 => 'o', diff --git a/Localization/LanguageDetection/resources/gn/gn.php b/Localization/LanguageDetection/resources/gn/gn.php index 60f0892f0..dbd4060be 100755 --- a/Localization/LanguageDetection/resources/gn/gn.php +++ b/Localization/LanguageDetection/resources/gn/gn.php @@ -1,8 +1,7 @@ - [ + 'gn' => [ 0 => 'a', 1 => 'e', 2 => 'o', diff --git a/Localization/LanguageDetection/resources/gu/gu.php b/Localization/LanguageDetection/resources/gu/gu.php index 13d22356f..72d74deb0 100755 --- a/Localization/LanguageDetection/resources/gu/gu.php +++ b/Localization/LanguageDetection/resources/gu/gu.php @@ -1,8 +1,7 @@ - [ + 'gu' => [ 0 => 'ન_', 1 => '_ન_', 2 => '_ક_', diff --git a/Localization/LanguageDetection/resources/ha/ha.php b/Localization/LanguageDetection/resources/ha/ha.php index 850ec877c..ab3d1fd8c 100755 --- a/Localization/LanguageDetection/resources/ha/ha.php +++ b/Localization/LanguageDetection/resources/ha/ha.php @@ -1,8 +1,7 @@ - [ + 'ha' => [ 0 => 'a', 1 => 'ɛ', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/he/he.php b/Localization/LanguageDetection/resources/he/he.php index 1c486d840..58cb45a52 100755 --- a/Localization/LanguageDetection/resources/he/he.php +++ b/Localization/LanguageDetection/resources/he/he.php @@ -1,8 +1,7 @@ - [ + 'he' => [ 0 => 'ו', 1 => 'י', 2 => 'ה', diff --git a/Localization/LanguageDetection/resources/hi/hi.php b/Localization/LanguageDetection/resources/hi/hi.php index 88b4473b4..050de2c20 100755 --- a/Localization/LanguageDetection/resources/hi/hi.php +++ b/Localization/LanguageDetection/resources/hi/hi.php @@ -1,8 +1,7 @@ - [ + 'hi' => [ 0 => '_क_', 1 => 'क_', 2 => '_क', diff --git a/Localization/LanguageDetection/resources/hr/hr.php b/Localization/LanguageDetection/resources/hr/hr.php index 7942f90cd..cef271ab8 100755 --- a/Localization/LanguageDetection/resources/hr/hr.php +++ b/Localization/LanguageDetection/resources/hr/hr.php @@ -1,8 +1,7 @@ - [ + 'hr' => [ 0 => 'a', 1 => 'o', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/hu/hu.php b/Localization/LanguageDetection/resources/hu/hu.php index e2fd9bfd4..abd76690f 100755 --- a/Localization/LanguageDetection/resources/hu/hu.php +++ b/Localization/LanguageDetection/resources/hu/hu.php @@ -1,8 +1,7 @@ - [ + 'hu' => [ 0 => 'e', 1 => 'a', 2 => 's', diff --git a/Localization/LanguageDetection/resources/hy/hy.php b/Localization/LanguageDetection/resources/hy/hy.php index 3cf4da028..1da809cd8 100755 --- a/Localization/LanguageDetection/resources/hy/hy.php +++ b/Localization/LanguageDetection/resources/hy/hy.php @@ -1,8 +1,7 @@ - [ + 'hy' => [ 0 => 'ա', 1 => 'ն', 2 => 'ո', diff --git a/Localization/LanguageDetection/resources/ia/ia.php b/Localization/LanguageDetection/resources/ia/ia.php index a107d44cc..610f768aa 100755 --- a/Localization/LanguageDetection/resources/ia/ia.php +++ b/Localization/LanguageDetection/resources/ia/ia.php @@ -1,8 +1,7 @@ - [ + 'ia' => [ 0 => 'e', 1 => 't', 2 => 'a', diff --git a/Localization/LanguageDetection/resources/id/id.php b/Localization/LanguageDetection/resources/id/id.php index 5e125adee..ccff76e46 100755 --- a/Localization/LanguageDetection/resources/id/id.php +++ b/Localization/LanguageDetection/resources/id/id.php @@ -1,8 +1,7 @@ - [ + 'id' => [ 0 => 'a', 1 => 'n', 2 => 'e', diff --git a/Localization/LanguageDetection/resources/ig/ig.php b/Localization/LanguageDetection/resources/ig/ig.php index 806d7c1f0..5d708854e 100755 --- a/Localization/LanguageDetection/resources/ig/ig.php +++ b/Localization/LanguageDetection/resources/ig/ig.php @@ -1,8 +1,7 @@ - [ + 'ig' => [ 0 => 'a', 1 => 'e', 2 => 'a_', diff --git a/Localization/LanguageDetection/resources/io/io.php b/Localization/LanguageDetection/resources/io/io.php index bd4a48715..2b6a8baf9 100755 --- a/Localization/LanguageDetection/resources/io/io.php +++ b/Localization/LanguageDetection/resources/io/io.php @@ -1,8 +1,7 @@ - [ + 'io' => [ 0 => 'a', 1 => 'e', 2 => 'o', diff --git a/Localization/LanguageDetection/resources/is/is.php b/Localization/LanguageDetection/resources/is/is.php index 888d8c573..ea11e28b6 100755 --- a/Localization/LanguageDetection/resources/is/is.php +++ b/Localization/LanguageDetection/resources/is/is.php @@ -1,8 +1,7 @@ - [ + 'is' => [ 0 => 'a', 1 => 'r', 2 => 'n', diff --git a/Localization/LanguageDetection/resources/it/it.php b/Localization/LanguageDetection/resources/it/it.php index c4fafd0d3..b8dc05043 100755 --- a/Localization/LanguageDetection/resources/it/it.php +++ b/Localization/LanguageDetection/resources/it/it.php @@ -1,8 +1,7 @@ - [ + 'it' => [ 0 => 'i', 1 => 'e', 2 => 'a', diff --git a/Localization/LanguageDetection/resources/iu/iu.php b/Localization/LanguageDetection/resources/iu/iu.php index 5c945a981..6f91434d4 100755 --- a/Localization/LanguageDetection/resources/iu/iu.php +++ b/Localization/LanguageDetection/resources/iu/iu.php @@ -1,8 +1,7 @@ - [ + 'iu' => [ 0 => 'ᑦ', 1 => 'ᑦ_', 2 => 'ᑎ', diff --git a/Localization/LanguageDetection/resources/ja/ja.php b/Localization/LanguageDetection/resources/ja/ja.php index e72b4b417..38a841370 100755 --- a/Localization/LanguageDetection/resources/ja/ja.php +++ b/Localization/LanguageDetection/resources/ja/ja.php @@ -1,8 +1,7 @@ - [ + 'ja' => [ 0 => 'の', 1 => 'る', 2 => 'に', diff --git a/Localization/LanguageDetection/resources/jv/jv.php b/Localization/LanguageDetection/resources/jv/jv.php index 435dd58b5..d5f0657ea 100755 --- a/Localization/LanguageDetection/resources/jv/jv.php +++ b/Localization/LanguageDetection/resources/jv/jv.php @@ -1,8 +1,7 @@ - [ + 'jv' => [ 0 => 'a', 1 => 'n', 2 => 'an', diff --git a/Localization/LanguageDetection/resources/ka/ka.php b/Localization/LanguageDetection/resources/ka/ka.php index c5c3ccf91..73c193101 100755 --- a/Localization/LanguageDetection/resources/ka/ka.php +++ b/Localization/LanguageDetection/resources/ka/ka.php @@ -1,8 +1,7 @@ - [ + 'ka' => [ 0 => 'ა', 1 => 'ი', 2 => 'ე', diff --git a/Localization/LanguageDetection/resources/km/km.php b/Localization/LanguageDetection/resources/km/km.php index 5cc2326b2..dc325d17e 100755 --- a/Localization/LanguageDetection/resources/km/km.php +++ b/Localization/LanguageDetection/resources/km/km.php @@ -1,8 +1,7 @@ - [ + 'km' => [ 0 => '_រ', 1 => 'រ', 2 => '_ន_', diff --git a/Localization/LanguageDetection/resources/ko/ko.php b/Localization/LanguageDetection/resources/ko/ko.php index 2732be778..161bf1b9d 100755 --- a/Localization/LanguageDetection/resources/ko/ko.php +++ b/Localization/LanguageDetection/resources/ko/ko.php @@ -1,8 +1,7 @@ - [ + 'ko' => [ 0 => '의', 1 => '한', 2 => '의_', diff --git a/Localization/LanguageDetection/resources/kr/kr.php b/Localization/LanguageDetection/resources/kr/kr.php index aa0dfc84a..d4aa4cf37 100755 --- a/Localization/LanguageDetection/resources/kr/kr.php +++ b/Localization/LanguageDetection/resources/kr/kr.php @@ -1,8 +1,7 @@ - [ + 'kr' => [ 0 => 'a', 1 => 'n', 2 => 'ə', diff --git a/Localization/LanguageDetection/resources/ku/ku.php b/Localization/LanguageDetection/resources/ku/ku.php index 321b0b164..b1178d8f6 100755 --- a/Localization/LanguageDetection/resources/ku/ku.php +++ b/Localization/LanguageDetection/resources/ku/ku.php @@ -1,8 +1,7 @@ - [ + 'ku' => [ 0 => 'e', 1 => 'a', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/la/la.php b/Localization/LanguageDetection/resources/la/la.php index 3fcd391d2..5bb368ea7 100755 --- a/Localization/LanguageDetection/resources/la/la.php +++ b/Localization/LanguageDetection/resources/la/la.php @@ -1,8 +1,7 @@ - [ + 'la' => [ 0 => 'i', 1 => 'e', 2 => 't', diff --git a/Localization/LanguageDetection/resources/lg/lg.php b/Localization/LanguageDetection/resources/lg/lg.php index c462e273d..38760ca1d 100755 --- a/Localization/LanguageDetection/resources/lg/lg.php +++ b/Localization/LanguageDetection/resources/lg/lg.php @@ -1,8 +1,7 @@ - [ + 'lg' => [ 0 => 'a', 1 => 'u', 2 => 'e', diff --git a/Localization/LanguageDetection/resources/ln/ln.php b/Localization/LanguageDetection/resources/ln/ln.php index 68b2d3406..46b28c977 100755 --- a/Localization/LanguageDetection/resources/ln/ln.php +++ b/Localization/LanguageDetection/resources/ln/ln.php @@ -1,8 +1,7 @@ - [ + 'ln' => [ 0 => 'a', 1 => 'o', 2 => 'a_', diff --git a/Localization/LanguageDetection/resources/lo/lo.php b/Localization/LanguageDetection/resources/lo/lo.php index 215e7d27f..8fd83f1a2 100755 --- a/Localization/LanguageDetection/resources/lo/lo.php +++ b/Localization/LanguageDetection/resources/lo/lo.php @@ -1,8 +1,7 @@ - [ + 'lo' => [ 0 => 'ນ', 1 => 'າ', 2 => 'ດ', diff --git a/Localization/LanguageDetection/resources/lt/lt.php b/Localization/LanguageDetection/resources/lt/lt.php index a8f6885e6..6c8ca625c 100755 --- a/Localization/LanguageDetection/resources/lt/lt.php +++ b/Localization/LanguageDetection/resources/lt/lt.php @@ -1,8 +1,7 @@ - [ + 'lt' => [ 0 => 'i', 1 => 'a', 2 => 's', diff --git a/Localization/LanguageDetection/resources/lv/lv.php b/Localization/LanguageDetection/resources/lv/lv.php index 86eedef6c..97a04675f 100755 --- a/Localization/LanguageDetection/resources/lv/lv.php +++ b/Localization/LanguageDetection/resources/lv/lv.php @@ -1,8 +1,7 @@ - [ + 'lv' => [ 0 => 'a', 1 => 'i', 2 => 's', diff --git a/Localization/LanguageDetection/resources/mh/mh.php b/Localization/LanguageDetection/resources/mh/mh.php index 0aa5f7f63..92f4c1515 100755 --- a/Localization/LanguageDetection/resources/mh/mh.php +++ b/Localization/LanguageDetection/resources/mh/mh.php @@ -1,8 +1,7 @@ - [ + 'mh' => [ 0 => 'o', 1 => 'e', 2 => 'n', diff --git a/Localization/LanguageDetection/resources/mn-Cyrl/mn-Cyrl.php b/Localization/LanguageDetection/resources/mn-Cyrl/mn-Cyrl.php index 3d14c9fbc..3f0e14525 100755 --- a/Localization/LanguageDetection/resources/mn-Cyrl/mn-Cyrl.php +++ b/Localization/LanguageDetection/resources/mn-Cyrl/mn-Cyrl.php @@ -1,8 +1,7 @@ - [ + 'mn-Cyrl' => [ 0 => 'а', 1 => 'э', 2 => 'л', diff --git a/Localization/LanguageDetection/resources/ms-Arab/ms-Arab.php b/Localization/LanguageDetection/resources/ms-Arab/ms-Arab.php index 4b3a00903..e892cf915 100755 --- a/Localization/LanguageDetection/resources/ms-Arab/ms-Arab.php +++ b/Localization/LanguageDetection/resources/ms-Arab/ms-Arab.php @@ -1,8 +1,7 @@ - [ + 'ms-Arab' => [ 0 => 'ا', 1 => 'ن', 2 => 'ي', diff --git a/Localization/LanguageDetection/resources/ms-Latn/ms-Latn.php b/Localization/LanguageDetection/resources/ms-Latn/ms-Latn.php index 42bc87daa..63a9c43e2 100755 --- a/Localization/LanguageDetection/resources/ms-Latn/ms-Latn.php +++ b/Localization/LanguageDetection/resources/ms-Latn/ms-Latn.php @@ -1,8 +1,7 @@ - [ + 'ms-Latn' => [ 0 => 'a', 1 => 'n', 2 => 'e', diff --git a/Localization/LanguageDetection/resources/mt/mt.php b/Localization/LanguageDetection/resources/mt/mt.php index 8af896b94..ce1e7de22 100755 --- a/Localization/LanguageDetection/resources/mt/mt.php +++ b/Localization/LanguageDetection/resources/mt/mt.php @@ -1,8 +1,7 @@ - [ + 'mt' => [ 0 => 'i', 1 => 'a', 2 => 'l', diff --git a/Localization/LanguageDetection/resources/nb/nb.php b/Localization/LanguageDetection/resources/nb/nb.php index 56877d1bf..29cca937c 100755 --- a/Localization/LanguageDetection/resources/nb/nb.php +++ b/Localization/LanguageDetection/resources/nb/nb.php @@ -1,8 +1,7 @@ - [ + 'nb' => [ 0 => 'e', 1 => 'r', 2 => 't', diff --git a/Localization/LanguageDetection/resources/ng/ng.php b/Localization/LanguageDetection/resources/ng/ng.php index af07599b9..fdd925262 100755 --- a/Localization/LanguageDetection/resources/ng/ng.php +++ b/Localization/LanguageDetection/resources/ng/ng.php @@ -1,8 +1,7 @@ - [ + 'ng' => [ 0 => 'a', 1 => 'o', 2 => 'n', diff --git a/Localization/LanguageDetection/resources/nl/nl.php b/Localization/LanguageDetection/resources/nl/nl.php index c80d3de44..f0e69f6cd 100755 --- a/Localization/LanguageDetection/resources/nl/nl.php +++ b/Localization/LanguageDetection/resources/nl/nl.php @@ -1,8 +1,7 @@ - [ + 'nl' => [ 0 => 'e', 1 => 'n', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/nn/nn.php b/Localization/LanguageDetection/resources/nn/nn.php index b3c04cd7a..91fa9222e 100755 --- a/Localization/LanguageDetection/resources/nn/nn.php +++ b/Localization/LanguageDetection/resources/nn/nn.php @@ -1,8 +1,7 @@ - [ + 'nn' => [ 0 => 'e', 1 => 'a', 2 => 'r', diff --git a/Localization/LanguageDetection/resources/nv/nv.php b/Localization/LanguageDetection/resources/nv/nv.php index e68a119ac..5c36f7855 100755 --- a/Localization/LanguageDetection/resources/nv/nv.php +++ b/Localization/LanguageDetection/resources/nv/nv.php @@ -1,8 +1,7 @@ - [ + 'nv' => [ 0 => 'a', 1 => 'i', 2 => 'h', diff --git a/Localization/LanguageDetection/resources/oc/oc.php b/Localization/LanguageDetection/resources/oc/oc.php index 04b4a1ccf..9cf3622ba 100755 --- a/Localization/LanguageDetection/resources/oc/oc.php +++ b/Localization/LanguageDetection/resources/oc/oc.php @@ -1,8 +1,7 @@ - [ + 'oc' => [ 0 => 'a', 1 => 'e', 2 => 's', diff --git a/Localization/LanguageDetection/resources/om/om.php b/Localization/LanguageDetection/resources/om/om.php index 6fbe522cc..06d3758f6 100755 --- a/Localization/LanguageDetection/resources/om/om.php +++ b/Localization/LanguageDetection/resources/om/om.php @@ -1,8 +1,7 @@ - [ + 'om' => [ 0 => 'a', 1 => 'i', 2 => 'u', diff --git a/Localization/LanguageDetection/resources/pl/pl.php b/Localization/LanguageDetection/resources/pl/pl.php index 48b5110ed..230fbaefa 100755 --- a/Localization/LanguageDetection/resources/pl/pl.php +++ b/Localization/LanguageDetection/resources/pl/pl.php @@ -1,8 +1,7 @@ - [ + 'pl' => [ 0 => 'a', 1 => 'o', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/pt-BR/pt-BR.php b/Localization/LanguageDetection/resources/pt-BR/pt-BR.php index 4e2dcfdd7..0cc805f3c 100755 --- a/Localization/LanguageDetection/resources/pt-BR/pt-BR.php +++ b/Localization/LanguageDetection/resources/pt-BR/pt-BR.php @@ -1,8 +1,7 @@ - [ + 'pt-BR' => [ 0 => 'e', 1 => 'o', 2 => 'a', diff --git a/Localization/LanguageDetection/resources/pt-PT/pt-PT.php b/Localization/LanguageDetection/resources/pt-PT/pt-PT.php index 6dbadb628..bce0d0b2a 100755 --- a/Localization/LanguageDetection/resources/pt-PT/pt-PT.php +++ b/Localization/LanguageDetection/resources/pt-PT/pt-PT.php @@ -1,8 +1,7 @@ - [ + 'pt-PT' => [ 0 => 'e', 1 => 'a', 2 => 'o', diff --git a/Localization/LanguageDetection/resources/ro/ro.php b/Localization/LanguageDetection/resources/ro/ro.php index d89d599a9..5b54547bb 100755 --- a/Localization/LanguageDetection/resources/ro/ro.php +++ b/Localization/LanguageDetection/resources/ro/ro.php @@ -1,8 +1,7 @@ - [ + 'ro' => [ 0 => 'e', 1 => 'i', 2 => 'a', diff --git a/Localization/LanguageDetection/resources/ru/ru.php b/Localization/LanguageDetection/resources/ru/ru.php index c6a52b0ad..637f902e9 100755 --- a/Localization/LanguageDetection/resources/ru/ru.php +++ b/Localization/LanguageDetection/resources/ru/ru.php @@ -1,8 +1,7 @@ - [ + 'ru' => [ 0 => 'о', 1 => 'е', 2 => 'и', diff --git a/Localization/LanguageDetection/resources/sa/sa.php b/Localization/LanguageDetection/resources/sa/sa.php index 8f1331ab9..af5d7ab0f 100755 --- a/Localization/LanguageDetection/resources/sa/sa.php +++ b/Localization/LanguageDetection/resources/sa/sa.php @@ -1,8 +1,7 @@ - [ + 'sa' => [ 0 => '_य_', 1 => '_त_', 2 => 'त_', diff --git a/Localization/LanguageDetection/resources/sk/sk.php b/Localization/LanguageDetection/resources/sk/sk.php index e70aab01a..f3df5c008 100755 --- a/Localization/LanguageDetection/resources/sk/sk.php +++ b/Localization/LanguageDetection/resources/sk/sk.php @@ -1,8 +1,7 @@ - [ + 'sk' => [ 0 => 'o', 1 => 'a', 2 => 'n', diff --git a/Localization/LanguageDetection/resources/sl/sl.php b/Localization/LanguageDetection/resources/sl/sl.php index 616b69025..c4ab9c7a2 100755 --- a/Localization/LanguageDetection/resources/sl/sl.php +++ b/Localization/LanguageDetection/resources/sl/sl.php @@ -1,8 +1,7 @@ - [ + 'sl' => [ 0 => 'o', 1 => 'a', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/so/so.php b/Localization/LanguageDetection/resources/so/so.php index eaff5602a..46c11594c 100755 --- a/Localization/LanguageDetection/resources/so/so.php +++ b/Localization/LanguageDetection/resources/so/so.php @@ -1,8 +1,7 @@ - [ + 'so' => [ 0 => 'a', 1 => 'i', 2 => 'o', diff --git a/Localization/LanguageDetection/resources/sq/sq.php b/Localization/LanguageDetection/resources/sq/sq.php index 4d784e48a..13a417b88 100755 --- a/Localization/LanguageDetection/resources/sq/sq.php +++ b/Localization/LanguageDetection/resources/sq/sq.php @@ -1,8 +1,7 @@ - [ + 'sq' => [ 0 => 'e', 1 => 't', 2 => 'ë', diff --git a/Localization/LanguageDetection/resources/sr-Cyrl/sr-Cyrl.php b/Localization/LanguageDetection/resources/sr-Cyrl/sr-Cyrl.php index 76d741df6..98ef3b691 100755 --- a/Localization/LanguageDetection/resources/sr-Cyrl/sr-Cyrl.php +++ b/Localization/LanguageDetection/resources/sr-Cyrl/sr-Cyrl.php @@ -1,8 +1,7 @@ - [ + 'sr-Cyrl' => [ 0 => 'а', 1 => 'о', 2 => 'и', diff --git a/Localization/LanguageDetection/resources/sr-Latn/sr-Latn.php b/Localization/LanguageDetection/resources/sr-Latn/sr-Latn.php index a51d62e8f..7e4640866 100755 --- a/Localization/LanguageDetection/resources/sr-Latn/sr-Latn.php +++ b/Localization/LanguageDetection/resources/sr-Latn/sr-Latn.php @@ -1,8 +1,7 @@ - [ + 'sr-Latn' => [ 0 => 'a', 1 => 'o', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/ss/ss.php b/Localization/LanguageDetection/resources/ss/ss.php index 469c5af3b..878e157e9 100755 --- a/Localization/LanguageDetection/resources/ss/ss.php +++ b/Localization/LanguageDetection/resources/ss/ss.php @@ -1,8 +1,7 @@ - [ + 'ss' => [ 0 => 'e', 1 => 'a', 2 => 'n', diff --git a/Localization/LanguageDetection/resources/sv/sv.php b/Localization/LanguageDetection/resources/sv/sv.php index ff0694d2a..7d23fd18c 100755 --- a/Localization/LanguageDetection/resources/sv/sv.php +++ b/Localization/LanguageDetection/resources/sv/sv.php @@ -1,8 +1,7 @@ - [ + 'sv' => [ 0 => 'a', 1 => 'e', 2 => 't', diff --git a/Localization/LanguageDetection/resources/sw/sw.php b/Localization/LanguageDetection/resources/sw/sw.php index ec3661596..a9aa94947 100755 --- a/Localization/LanguageDetection/resources/sw/sw.php +++ b/Localization/LanguageDetection/resources/sw/sw.php @@ -1,8 +1,7 @@ - [ + 'sw' => [ 0 => 'a', 1 => 'a_', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/ta/ta.php b/Localization/LanguageDetection/resources/ta/ta.php index abb719a8c..f0a5bfd48 100755 --- a/Localization/LanguageDetection/resources/ta/ta.php +++ b/Localization/LanguageDetection/resources/ta/ta.php @@ -1,8 +1,7 @@ - [ + 'ta' => [ 0 => '_க_', 1 => '_ம_', 2 => '_க', diff --git a/Localization/LanguageDetection/resources/th/th.php b/Localization/LanguageDetection/resources/th/th.php index dcd8aa250..03188f4d6 100755 --- a/Localization/LanguageDetection/resources/th/th.php +++ b/Localization/LanguageDetection/resources/th/th.php @@ -1,8 +1,7 @@ - [ + 'th' => [ 0 => 'า', 1 => 'ร', 2 => 'น', diff --git a/Localization/LanguageDetection/resources/tl/tl.php b/Localization/LanguageDetection/resources/tl/tl.php index 8aaf5fa4f..ce055e56b 100755 --- a/Localization/LanguageDetection/resources/tl/tl.php +++ b/Localization/LanguageDetection/resources/tl/tl.php @@ -1,8 +1,7 @@ - [ + 'tl' => [ 0 => 'a', 1 => 'n', 2 => 'g', diff --git a/Localization/LanguageDetection/resources/to/to.php b/Localization/LanguageDetection/resources/to/to.php index bd206c4d0..75ac601ea 100755 --- a/Localization/LanguageDetection/resources/to/to.php +++ b/Localization/LanguageDetection/resources/to/to.php @@ -1,8 +1,7 @@ - [ + 'to' => [ 0 => 'a', 1 => 'u', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/tr/tr.php b/Localization/LanguageDetection/resources/tr/tr.php index 8b5d50a1a..d279caccc 100755 --- a/Localization/LanguageDetection/resources/tr/tr.php +++ b/Localization/LanguageDetection/resources/tr/tr.php @@ -1,8 +1,7 @@ - [ + 'tr' => [ 0 => 'e', 1 => 'a', 2 => 'i', diff --git a/Localization/LanguageDetection/resources/tt/tt.php b/Localization/LanguageDetection/resources/tt/tt.php index 764d4a5e5..2be63ba06 100755 --- a/Localization/LanguageDetection/resources/tt/tt.php +++ b/Localization/LanguageDetection/resources/tt/tt.php @@ -1,8 +1,7 @@ - [ + 'tt' => [ 0 => 'а', 1 => 'е', 2 => 'ә', diff --git a/Localization/LanguageDetection/resources/ty/ty.php b/Localization/LanguageDetection/resources/ty/ty.php index 975ea2036..4bd07c22e 100755 --- a/Localization/LanguageDetection/resources/ty/ty.php +++ b/Localization/LanguageDetection/resources/ty/ty.php @@ -1,8 +1,7 @@ - [ + 'ty' => [ 0 => 'a', 1 => '\'', 2 => 't', diff --git a/Localization/LanguageDetection/resources/ug-Arab/ug-Arab.php b/Localization/LanguageDetection/resources/ug-Arab/ug-Arab.php index 46749b894..768c4cf4c 100755 --- a/Localization/LanguageDetection/resources/ug-Arab/ug-Arab.php +++ b/Localization/LanguageDetection/resources/ug-Arab/ug-Arab.php @@ -1,8 +1,7 @@ - [ + 'ug-Arab' => [ 0 => 'ى', 1 => 'ا', 2 => 'ە', diff --git a/Localization/LanguageDetection/resources/ug-Latn/ug-Latn.php b/Localization/LanguageDetection/resources/ug-Latn/ug-Latn.php index f2de960d9..5c9bae4f5 100755 --- a/Localization/LanguageDetection/resources/ug-Latn/ug-Latn.php +++ b/Localization/LanguageDetection/resources/ug-Latn/ug-Latn.php @@ -1,8 +1,7 @@ - [ + 'ug-Latn' => [ 0 => 'i', 1 => 'a', 2 => 'e', diff --git a/Localization/LanguageDetection/resources/uk/uk.php b/Localization/LanguageDetection/resources/uk/uk.php index 7318f7cd1..ed6c461f2 100755 --- a/Localization/LanguageDetection/resources/uk/uk.php +++ b/Localization/LanguageDetection/resources/uk/uk.php @@ -1,8 +1,7 @@ - [ + 'uk' => [ 0 => 'о', 1 => 'а', 2 => 'н', diff --git a/Localization/LanguageDetection/resources/ur/ur.php b/Localization/LanguageDetection/resources/ur/ur.php index 07671c152..6caf25449 100755 --- a/Localization/LanguageDetection/resources/ur/ur.php +++ b/Localization/LanguageDetection/resources/ur/ur.php @@ -1,8 +1,7 @@ - [ + 'ur' => [ 0 => 'ا', 1 => 'ی', 2 => 'و', diff --git a/Localization/LanguageDetection/resources/uz/uz.php b/Localization/LanguageDetection/resources/uz/uz.php index 6188fe539..b257c9537 100755 --- a/Localization/LanguageDetection/resources/uz/uz.php +++ b/Localization/LanguageDetection/resources/uz/uz.php @@ -1,8 +1,7 @@ - [ + 'uz' => [ 0 => 'а', 1 => 'и', 2 => 'л', diff --git a/Localization/LanguageDetection/resources/ve/ve.php b/Localization/LanguageDetection/resources/ve/ve.php index f95a3d866..3715b33eb 100755 --- a/Localization/LanguageDetection/resources/ve/ve.php +++ b/Localization/LanguageDetection/resources/ve/ve.php @@ -1,8 +1,7 @@ - [ + 've' => [ 0 => 'a', 1 => 'a_', 2 => 'h', diff --git a/Localization/LanguageDetection/resources/vi/vi.php b/Localization/LanguageDetection/resources/vi/vi.php index bd20de2c4..7de503775 100755 --- a/Localization/LanguageDetection/resources/vi/vi.php +++ b/Localization/LanguageDetection/resources/vi/vi.php @@ -1,8 +1,7 @@ - [ + 'vi' => [ 0 => 'n', 1 => '_n', 2 => '_c', diff --git a/Localization/LanguageDetection/resources/wa/wa.php b/Localization/LanguageDetection/resources/wa/wa.php index 09fb454d0..ea6f8f24b 100755 --- a/Localization/LanguageDetection/resources/wa/wa.php +++ b/Localization/LanguageDetection/resources/wa/wa.php @@ -1,8 +1,7 @@ - [ + 'wa' => [ 0 => 's', 1 => 'e', 2 => 't', diff --git a/Localization/LanguageDetection/resources/wo/wo.php b/Localization/LanguageDetection/resources/wo/wo.php index 0b96bbc8d..e9a46d046 100755 --- a/Localization/LanguageDetection/resources/wo/wo.php +++ b/Localization/LanguageDetection/resources/wo/wo.php @@ -1,8 +1,7 @@ - [ + 'wo' => [ 0 => 'a', 1 => 'e', 2 => 'u', diff --git a/Localization/LanguageDetection/resources/xh/xh.php b/Localization/LanguageDetection/resources/xh/xh.php index 93f3a9f18..81a5f9b8e 100755 --- a/Localization/LanguageDetection/resources/xh/xh.php +++ b/Localization/LanguageDetection/resources/xh/xh.php @@ -1,8 +1,7 @@ - [ + 'xh' => [ 0 => 'e', 1 => 'a', 2 => 'n', diff --git a/Localization/LanguageDetection/resources/yo/yo.php b/Localization/LanguageDetection/resources/yo/yo.php index fffa29b75..897077110 100755 --- a/Localization/LanguageDetection/resources/yo/yo.php +++ b/Localization/LanguageDetection/resources/yo/yo.php @@ -1,8 +1,7 @@ - [ + 'yo' => [ 0 => 'n', 1 => 'í', 2 => 'à', diff --git a/Localization/LanguageDetection/resources/zh-Hans/zh-Hans.php b/Localization/LanguageDetection/resources/zh-Hans/zh-Hans.php index 0bf8287f3..980d59ced 100755 --- a/Localization/LanguageDetection/resources/zh-Hans/zh-Hans.php +++ b/Localization/LanguageDetection/resources/zh-Hans/zh-Hans.php @@ -1,8 +1,7 @@ - [ + 'zh-Hans' => [ 0 => '的', 1 => '人', 2 => '和', diff --git a/Localization/LanguageDetection/resources/zh-Hant/zh-Hant.php b/Localization/LanguageDetection/resources/zh-Hant/zh-Hant.php index 9591cdf35..1a2294aa8 100755 --- a/Localization/LanguageDetection/resources/zh-Hant/zh-Hant.php +++ b/Localization/LanguageDetection/resources/zh-Hant/zh-Hant.php @@ -1,8 +1,7 @@ - [ + 'zh-Hant' => [ 0 => '的', 1 => '人', 2 => '和', diff --git a/Localization/Localization.php b/Localization/Localization.php index 1f540ac84..eb1b0a528 100755 --- a/Localization/Localization.php +++ b/Localization/Localization.php @@ -216,8 +216,8 @@ class Localization implements \JsonSerializable $l11n = new self(); $l11n->setCountry($json['country']); $l11n->setTimezone($json['timezone'] ?? 'America/New_York'); - $l11n->setLanguage($json['language']); - $l11n->setCurrency(\is_string($json['currency']) ? $json['currency'] : ($json['currency']['code'] ?? ISO4217Enum::_USD)); + $l11n->language = $json['language']; + $l11n->currency = \is_string($json['currency']) ? $json['currency'] : ($json['currency']['code'] ?? ISO4217Enum::_USD); $l11n->setCurrencyFormat(isset($json['currencyformat']) && \is_string($json['currencyformat']) ? $json['currencyformat'] : ($json['currency']['format'] ?? '1')); $l11n->setDecimal($json['decimal']); $l11n->setThousands($json['thousand']); @@ -322,7 +322,7 @@ class Localization implements \JsonSerializable /** * Load localization from locale * - * @param array{language?:string, country?:string, currency?:array{code?:string}, thousand?:string, angle?:string, temperatur?:string, weight?:array, speed?:array, length?:array, area?:array, volume?:array, precision?:array, timezone?:string, datetime?:array} $locale Locale data + * @param array{language?:string, country?:string, currency?:array{code?:string}, thousand?:string, angle?:string, temperature?:string, weight?:array, speed?:array, length?:array, area?:array, volume?:array, precision?:array, timezone?:string, datetime?:array} $locale Locale data * * @return void * @@ -330,9 +330,9 @@ class Localization implements \JsonSerializable */ public function importLocale(array $locale) : void { - $this->setLanguage($locale['language'] ?? 'en'); + $this->language = $locale['language'] ?? 'en'; $this->setCountry($locale['country'] ?? 'US'); - $this->setCurrency($locale['currency']['code'] ?? ISO4217Enum::_USD); + $this->currency = $locale['currency']['code'] ?? ISO4217Enum::_USD; $this->setThousands($locale['thousand'] ?? ','); $this->setDecimal($locale['decimal'] ?? '.'); $this->setAngle($locale['angle'] ?? AngleType::DEGREE); @@ -350,7 +350,7 @@ class Localization implements \JsonSerializable /** * Set country name * - * @param string $country Contry name + * @param string $country Country name * * @return void * diff --git a/Localization/Money.php b/Localization/Money.php index 17f995ced..d70c19f77 100755 --- a/Localization/Money.php +++ b/Localization/Money.php @@ -73,7 +73,7 @@ final class Money extends FloatInt * * @since 1.0.0 */ - public function getCurrency(?int $decimals = 2, int $position = null, string $symbol = null) : string + public function getCurrency(?int $decimals = 2, ?int $position = null, ?string $symbol = null) : string { return (($position ?? $this->position) === 0 && !empty($symbol ?? $this->symbol) ? ($symbol ?? $this->symbol) . ' ' : '') . $this->getAmount($decimals) diff --git a/Localization/Subregion/ISO3166TwoATCharEnum.php b/Localization/Subregion/ISO3166TwoATCharEnum.php new file mode 100644 index 000000000..7dd9201b5 --- /dev/null +++ b/Localization/Subregion/ISO3166TwoATCharEnum.php @@ -0,0 +1,46 @@ + 2.22e-16; ++$i) { $an = - $i * ($i - $a); $b += 2.0; - $d = $an * $d + $b; - $c = $b + $an / $c; + $d = $an * $d + $b; + $c = $b + $an / $c; if (\abs($c) < 1.18e-37) { $c = 1.18e-37; @@ -296,7 +296,7 @@ final class Gamma $d = 1.0 / $d; $del = $d * $c; - $h *= $del; + $h *= $del; } return \exp(-$x + $a * \log($x) - self::logGamma($a)) * $h; diff --git a/Math/Geometry/Shape/D2/Polygon.php b/Math/Geometry/Shape/D2/Polygon.php index 5fbfdeaa3..74a4065c0 100755 --- a/Math/Geometry/Shape/D2/Polygon.php +++ b/Math/Geometry/Shape/D2/Polygon.php @@ -248,12 +248,12 @@ final class Polygon implements D2ShapeInterface $count = \count($this->coord); for ($i = 0; $i < $count - 1; ++$i) { - $mult = ($this->coord[$i]['x'] * $this->coord[$i + 1]['y'] - $this->coord[$i + 1]['x'] * $this->coord[$i]['y']); + $mult = ($this->coord[$i]['x'] * $this->coord[$i + 1]['y'] - $this->coord[$i + 1]['x'] * $this->coord[$i]['y']); $barycenter['x'] += ($this->coord[$i]['x'] + $this->coord[$i + 1]['x']) * $mult; $barycenter['y'] += ($this->coord[$i]['y'] + $this->coord[$i + 1]['y']) * $mult; } - $mult = ($this->coord[$count - 1]['x'] * $this->coord[0]['y'] - $this->coord[0]['x'] * $this->coord[$count - 1]['y']); + $mult = ($this->coord[$count - 1]['x'] * $this->coord[0]['y'] - $this->coord[0]['x'] * $this->coord[$count - 1]['y']); $barycenter['x'] += ($this->coord[$count - 1]['x'] + $this->coord[0]['x']) * $mult; $barycenter['y'] += ($this->coord[$count - 1]['y'] + $this->coord[0]['y']) * $mult; diff --git a/Math/Matrix/EigenvalueDecomposition.php b/Math/Matrix/EigenvalueDecomposition.php index c648e21e7..c12b9187e 100755 --- a/Math/Matrix/EigenvalueDecomposition.php +++ b/Math/Matrix/EigenvalueDecomposition.php @@ -182,14 +182,14 @@ final class EigenvalueDecomposition } else { for ($k = 0; $k < $i; ++$k) { $this->D[$k] /= $scale; - $h += $this->D[$k] * $this->D[$k]; + $h += $this->D[$k] * $this->D[$k]; } $f = $this->D[$i - 1]; $g = $f > 0 ? -\sqrt($h) : \sqrt($h); - $this->E[$i] = $scale * $g; - $h -= $f * $g; + $this->E[$i] = $scale * $g; + $h -= $f * $g; $this->D[$i - 1] = $f - $g; for ($j = 0; $j < $i; ++$j) { @@ -212,7 +212,7 @@ final class EigenvalueDecomposition $f = 0.0; for ($j = 0; $j < $i; ++$j) { $this->E[$j] /= $h; - $f += $this->E[$j] * $this->D[$j]; + $f += $this->E[$j] * $this->D[$j]; } $hh = $f / ($h + $h); @@ -321,7 +321,7 @@ final class EigenvalueDecomposition $this->D[$i] -= $h; } - $f += $h; + $f += $h; $p = $this->D[$m]; $c = 1.0; $c2 = 1.0; @@ -357,7 +357,7 @@ final class EigenvalueDecomposition } $this->D[$l] += $f; - $this->E[$l] = 0.0; + $this->E[$l] = 0.0; } for ($i = 0; $i < $this->m - 1; ++$i) { @@ -407,10 +407,10 @@ final class EigenvalueDecomposition $h = 0.0; for ($i = $high; $i >= $m; --$i) { $this->ort[$i] = $this->H[$i][$m - 1] / $scale; - $h += $this->ort[$i] * $this->ort[$i]; + $h += $this->ort[$i] * $this->ort[$i]; } - $g = $this->ort[$m] > 0 ? -\sqrt($h) : \sqrt($h); + $g = $this->ort[$m] > 0 ? -\sqrt($h) : \sqrt($h); $h -= $this->ort[$m] * $g; $this->ort[$m] -= $g; @@ -438,7 +438,7 @@ final class EigenvalueDecomposition } } - $this->ort[$m] *= $scale; + $this->ort[$m] *= $scale; $this->H[$m][$m - 1] = $scale * $g; } } @@ -553,9 +553,9 @@ final class EigenvalueDecomposition if ($l === $n) { $this->H[$n][$n] += $exshift; - $this->D[$n] = $this->H[$n][$n]; - $this->E[$n] = 0.0; - $iter = 0; + $this->D[$n] = $this->H[$n][$n]; + $this->E[$n] = 0.0; + $iter = 0; --$n; } elseif ($l === $n - 1) { @@ -576,11 +576,11 @@ final class EigenvalueDecomposition $this->E[$n - 1] = 0.0; $this->E[$n] = 0.0; - $x = $this->H[$n][$n - 1]; - $s = \abs($x) + \abs($z); - $p = $x / $s; - $q = $z / $s; - $r = \sqrt($p * $p + $q * $q); + $x = $this->H[$n][$n - 1]; + $s = \abs($x) + \abs($z); + $p = $x / $s; + $q = $z / $s; + $r = \sqrt($p * $p + $q * $q); $p /= $r; $q /= $r; @@ -608,7 +608,7 @@ final class EigenvalueDecomposition $this->E[$n] = -$z; } - $n -= 2; + $n -= 2; $iter = 0; } else { $x = $this->H[$n][$n]; @@ -645,7 +645,7 @@ final class EigenvalueDecomposition } $exshift += $s; - $x = $y = $w = 0.964; + $x = $y = $w = 0.964; } } @@ -653,13 +653,13 @@ final class EigenvalueDecomposition $m = $n - 2; while ($m >= $l) { - $z = $this->H[$m][$m]; - $r = $x - $z; - $s = $y - $z; - $p = ($r * $s - $w) / $this->H[$m + 1][$m] + $this->H[$m][$m + 1]; - $q = $this->H[$m + 1][$m + 1] - $z - $r - $s; - $r = $this->H[$m + 2][$m + 1]; - $s = \abs($p) + \abs($q) + \abs($r); + $z = $this->H[$m][$m]; + $r = $x - $z; + $s = $y - $z; + $p = ($r * $s - $w) / $this->H[$m + 1][$m] + $this->H[$m][$m + 1]; + $q = $this->H[$m + 1][$m + 1] - $z - $r - $s; + $r = $this->H[$m + 2][$m + 1]; + $s = \abs($p) + \abs($q) + \abs($r); $p /= $s; $q /= $s; $r /= $s; @@ -712,16 +712,16 @@ final class EigenvalueDecomposition } $p += $s; - $x = $p / $s; - $y = $q / $s; - $z = $r / $s; + $x = $p / $s; + $y = $q / $s; + $z = $r / $s; $q /= $p; $r /= $p; for ($j = $k; $j < $nn; ++$j) { $p = $this->H[$k][$j] + $q * $this->H[$k + 1][$j]; if ($notlast) { - $p += $r * $this->H[$k + 2][$j]; + $p += $r * $this->H[$k + 2][$j]; $this->H[$k + 2][$j] -= $p * $z; } @@ -734,7 +734,7 @@ final class EigenvalueDecomposition $p = $x * $this->H[$i][$k] + $y * $this->H[$i][$k + 1]; if ($notlast) { - $p += $z * $this->H[$i][$k + 2]; + $p += $z * $this->H[$i][$k + 2]; $this->H[$i][$k + 2] -= $p * $r; } @@ -746,7 +746,7 @@ final class EigenvalueDecomposition $p = $x * $this->V[$i][$k] + $y * $this->V[$i][$k + 1]; if ($notlast) { - $p += $z * $this->V[$i][$k + 2]; + $p += $z * $this->V[$i][$k + 2]; $this->V[$i][$k + 2] -= $p * $r; } $this->V[$i][$k] -= $p; diff --git a/Math/Matrix/Exception/InvalidDimensionException.php b/Math/Matrix/Exception/InvalidDimensionException.php index e423c2a66..69006f043 100755 --- a/Math/Matrix/Exception/InvalidDimensionException.php +++ b/Math/Matrix/Exception/InvalidDimensionException.php @@ -33,7 +33,7 @@ final class InvalidDimensionException extends \UnexpectedValueException * * @since 1.0.0 */ - public function __construct($message, int $code = 0, \Exception $previous = null) + public function __construct($message, int $code = 0, ?\Exception $previous = null) { parent::__construct('Dimension "' . $message . '" is not valid.', $code, $previous); } diff --git a/Math/Matrix/LUDecomposition.php b/Math/Matrix/LUDecomposition.php index 568b7a4e6..c336d3e90 100755 --- a/Math/Matrix/LUDecomposition.php +++ b/Math/Matrix/LUDecomposition.php @@ -118,9 +118,9 @@ final class LUDecomposition $this->LU[$j][$k] = $t; } - $k = $this->piv[$p]; - $this->piv[$p] = $this->piv[$j]; - $this->piv[$j] = $k; + $k = $this->piv[$p]; + $this->piv[$p] = $this->piv[$j]; + $this->piv[$j] = $k; $this->pivSign *= -1; } diff --git a/Math/Matrix/Matrix.php b/Math/Matrix/Matrix.php index 6daf401a3..a19d82d6f 100755 --- a/Math/Matrix/Matrix.php +++ b/Math/Matrix/Matrix.php @@ -860,7 +860,7 @@ class Matrix implements \ArrayAccess, \Iterator for ($i = 1; $i <= $iterations; ++$i) { $factorial *= $i; - $coeff = 1 / $factorial; + $coeff = 1 / $factorial; $pow = $pow->mult($this); $sum = $sum->add($pow->mult($coeff)); diff --git a/Math/Number/Integer.php b/Math/Number/Integer.php index f1952e588..3aef486f3 100755 --- a/Math/Number/Integer.php +++ b/Math/Number/Integer.php @@ -73,7 +73,7 @@ final class Integer while ($value % $prime === 0) { $factors[] = $prime; - $value /= $prime; + $value /= $prime; } } @@ -108,7 +108,7 @@ final class Integer } $cycleSize *= 2; - $y = $x; + $y = $x; } return $factor; diff --git a/Math/Number/Numbers.php b/Math/Number/Numbers.php index be331c4bf..bcb1e3338 100755 --- a/Math/Number/Numbers.php +++ b/Math/Number/Numbers.php @@ -102,7 +102,7 @@ final class Numbers } /** - * Count trailling zeros + * Count trailing zeros * * @param int $n Number to test * diff --git a/Math/Optimization/Simplex.php b/Math/Optimization/Simplex.php index cd6797040..439085865 100644 --- a/Math/Optimization/Simplex.php +++ b/Math/Optimization/Simplex.php @@ -17,11 +17,11 @@ namespace phpOMS\Math\Optimization; /** * Simplex class. * - * The Simplex algorithm aims to solve a linear program - optimising a linear function subject + * The Simplex algorithm aims to solve a linear program - optimizing a linear function subject * to linear constraints. As such it is useful for a very wide range of applications. * * N.B. The linear program has to be given in *slack form*, which is as follows: - * maximise + * maximize * c_1 * x_1 + c_2 * x_2 + ... + c_n * x_n + v * subj. to * a_11 * x_1 + a_12 * x_2 + ... + a_1n * x_n + b_1 = s_1 @@ -131,7 +131,7 @@ final class Simplex } } - $this->b[$x] /= -$this->A[$x][$y]; + $this->b[$x] /= -$this->A[$x][$y]; $this->A[$x][$y] = 1.0 / $this->A[$x][$y]; for ($i = 0; $i < $this->m; ++$i) { @@ -142,7 +142,7 @@ final class Simplex } } - $this->b[$i] += $this->A[$i][$y] * $this->b[$x]; + $this->b[$i] += $this->A[$i][$y] * $this->b[$x]; $this->A[$i][$y] *= $this->A[$x][$y]; } } @@ -153,7 +153,7 @@ final class Simplex } } - $this->v += $this->c[$y] * $this->b[$x]; + $this->v += $this->c[$y] * $this->b[$x]; $this->c[$y] *= $this->A[$x][$y]; $temp = $this->basic[$x]; @@ -329,7 +329,7 @@ final class Simplex for ($k = 0; $k < $this->n; ++$k) { if ($j === $this->nonbasic[$k]) { $this->c[$k] += $oldC[$j]; - $ok = true; + $ok = true; break; } } diff --git a/Math/Parser/Evaluator.php b/Math/Parser/Evaluator.php index e2e6b16c6..bdf1952ae 100755 --- a/Math/Parser/Evaluator.php +++ b/Math/Parser/Evaluator.php @@ -115,7 +115,7 @@ final class Evaluator '+' => ['precedence' => 2, 'order' => -1], '-' => ['precedence' => 2, 'order' => -1], ]; - $output = []; + $output = []; $equation = \str_replace(' ', '', $equation); $equation = \preg_split('/([\+\-\*\/\^\(\)])/', $equation, -1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE); diff --git a/Math/Solver/Root/Bisection.php b/Math/Solver/Root/Bisection.php index 48a16a7fc..cb92dab64 100644 --- a/Math/Solver/Root/Bisection.php +++ b/Math/Solver/Root/Bisection.php @@ -47,7 +47,7 @@ final class Bisection * * Iteratively searches for root between two points on the x-axis * - * @param Callable $func Function defintion + * @param Callable $func Function definition * @param float $a Start value * @param float $b End value * @param int $maxIterations Maximum amount of iterations diff --git a/Math/Solver/Root/Illinois.php b/Math/Solver/Root/Illinois.php index 09d8d50bf..4d9b1a7bc 100644 --- a/Math/Solver/Root/Illinois.php +++ b/Math/Solver/Root/Illinois.php @@ -47,7 +47,7 @@ final class Illinois * * Iteratively searches for root between two points on the x-axis * - * @param Callable $func Function defintion + * @param Callable $func Function definition * @param float $a Start value * @param float $b End value * @param int $maxIterations Maximum amount of iterations diff --git a/Math/Solver/Root/RegulaFalsi.php b/Math/Solver/Root/RegulaFalsi.php index a004a7ec1..361d18b23 100644 --- a/Math/Solver/Root/RegulaFalsi.php +++ b/Math/Solver/Root/RegulaFalsi.php @@ -47,7 +47,7 @@ final class RegulaFalsi * * Iteratively searches for root between two points on the x-axis * - * @param Callable $func Function defintion + * @param Callable $func Function definition * @param float $a Start value * @param float $b End value * @param int $maxIterations Maximum amount of iterations diff --git a/Math/Statistic/Average.php b/Math/Statistic/Average.php index 8395943f9..18d81bb0a 100755 --- a/Math/Statistic/Average.php +++ b/Math/Statistic/Average.php @@ -132,7 +132,7 @@ final class Average * * @since 1.0.0 */ - public static function totalMovingAverage(array $x, int $order, array $weight = null, bool $symmetric = false) : array + public static function totalMovingAverage(array $x, int $order, ?array $weight = null, bool $symmetric = false) : array { $periods = (int) ($order / ($symmetric ? 2 : 1)); $count = \count($x) - ($symmetric ? $periods : 0); @@ -160,7 +160,7 @@ final class Average * * @since 1.0.0 */ - public static function movingAverage(array $x, int $t, int $order, array $weight = null, bool $symmetric = false) : float + public static function movingAverage(array $x, int $t, int $order, ?array $weight = null, bool $symmetric = false) : float { $periods = (int) ($order / ($symmetric ? 2 : 1)); $count = \count($x); @@ -169,7 +169,7 @@ final class Average throw new \Exception('Periods'); } - $t += 2; + $t += 2; $end = $symmetric ? $t + $periods - 1 : $t - 1; $start = $t - 1 - $periods; diff --git a/Math/Statistic/Basic.php b/Math/Statistic/Basic.php index c165e7fe5..9826b581b 100755 --- a/Math/Statistic/Basic.php +++ b/Math/Statistic/Basic.php @@ -47,17 +47,17 @@ final class Basic */ public static function frequency(array $values) : array { - $freaquency = []; - $sum = 1; + $frequency = []; + $sum = 1; if (!(\is_array(\reset($values)))) { $sum = \array_sum($values); } foreach ($values as $value) { - $freaquency[] = \is_array($value) ? self::frequency($value) : $value / $sum; + $frequency[] = \is_array($value) ? self::frequency($value) : $value / $sum; } - return $freaquency; + return $frequency; } } diff --git a/Math/Statistic/Correlation.php b/Math/Statistic/Correlation.php index a4b446b81..278d35932 100755 --- a/Math/Statistic/Correlation.php +++ b/Math/Statistic/Correlation.php @@ -35,7 +35,7 @@ final class Correlation } /** - * Calculage bravais person correlation coefficient. + * Calculate bravais person correlation coefficient. * * Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3]) * @@ -54,7 +54,7 @@ final class Correlation } /** - * Calculage bravais person correlation coefficient. + * Calculate bravais person correlation coefficient. * * Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3]) * diff --git a/Math/Statistic/Forecast/Forecasts.php b/Math/Statistic/Forecast/Forecasts.php index 67979866e..6a2e0e9d9 100755 --- a/Math/Statistic/Forecast/Forecasts.php +++ b/Math/Statistic/Forecast/Forecasts.php @@ -71,7 +71,7 @@ final class Forecasts $variance += \pow($sale - $avg, 2); } - $variance /= $size; + $variance /= $size; $stdDeviation = \sqrt($variance); // Calculate the seasonal index for each period diff --git a/Math/Statistic/Forecast/Regression/RegressionAbstract.php b/Math/Statistic/Forecast/Regression/RegressionAbstract.php index 718d8a1e5..b08d87603 100755 --- a/Math/Statistic/Forecast/Regression/RegressionAbstract.php +++ b/Math/Statistic/Forecast/Regression/RegressionAbstract.php @@ -42,7 +42,7 @@ abstract class RegressionAbstract * * @latex y = b_{0} + b_{1} \cdot x * - * @param array $x Obersved x values + * @param array $x Observed x values * @param array $y Observed y values * * @return array [b0 => ?, b1 => ?] @@ -113,13 +113,13 @@ abstract class RegressionAbstract } /** - * Get predictional interval for linear regression. + * Get prediction interval for linear regression. * * @latex * * @param float $fX Forecasted at x value * @param float $fY Forecasted y value - * @param array $x observex x values + * @param array $x Observed x values * @param float $mse Errors for y values (y - y_forecasted) * @param float $multiplier Multiplier for interval * @@ -147,7 +147,7 @@ abstract class RegressionAbstract * * @latex \beta_{1} = \frac{\sum_{i=1}^{N} \left(y_{i} - \bar{y}\right)\left(x_{i} - \bar{x}\right)}{\sum_{i=1}^{N} \left(x_{i} - \bar{x}\right)^{2}} * - * @param array $x Obersved x values + * @param array $x Observed x values * @param array $y Observed y values * * @return float @@ -176,7 +176,7 @@ abstract class RegressionAbstract * * @latex \beta_{0} = \bar{x} - b_{1} \cdot \bar{x} * - * @param array $x Obersved x values + * @param array $x Observed x values * @param array $y Observed y values * @param float $b1 Beta 1 * @@ -193,7 +193,7 @@ abstract class RegressionAbstract * Get slope * * @param float $b1 Beta 1 - * @param float $x Obersved x values + * @param float $x Observed x values * @param float $y Observed y values * * @return float @@ -206,7 +206,7 @@ abstract class RegressionAbstract * Get elasticity * * @param float $b1 Beta 1 - * @param float $x Obersved x values + * @param float $x Observed x values * @param float $y Observed y values * * @return float diff --git a/Math/Statistic/MeasureOfDispersion.php b/Math/Statistic/MeasureOfDispersion.php index e63b1c42f..f2b59da8d 100755 --- a/Math/Statistic/MeasureOfDispersion.php +++ b/Math/Statistic/MeasureOfDispersion.php @@ -58,7 +58,7 @@ final class MeasureOfDispersion } /** - * Calculage empirical variation coefficient. + * Calculate empirical variation coefficient. * * Example: ([4, 5, 9, 1, 3]) * @@ -71,7 +71,7 @@ final class MeasureOfDispersion * * @since 1.0.0 */ - public static function empiricalVariationCoefficient(array $values, float $mean = null) : float + public static function empiricalVariationCoefficient(array $values, ?float $mean = null) : float { $mean = $mean !== null ? $mean : Average::arithmeticMean($values); @@ -96,7 +96,7 @@ final class MeasureOfDispersion * * @since 1.0.0 */ - public static function standardDeviationSample(array $values, float $mean = null) : float + public static function standardDeviationSample(array $values, ?float $mean = null) : float { $mean = $mean !== null ? $mean : Average::arithmeticMean($values); $sum = 0.0; @@ -125,7 +125,7 @@ final class MeasureOfDispersion * * @since 1.0.0 */ - public static function standardDeviationPopulation(array $values, float $mean = null) : float + public static function standardDeviationPopulation(array $values, ?float $mean = null) : float { $mean = $mean !== null ? $mean : Average::arithmeticMean($values); $sum = 0.0; @@ -141,7 +141,7 @@ final class MeasureOfDispersion } /** - * Calculage sample variance. + * Calculate sample variance. * * Similar to `empiricalVariance`. * @@ -158,7 +158,7 @@ final class MeasureOfDispersion * * @since 1.0.0 */ - public static function sampleVariance(array $values, float $mean = null) : float + public static function sampleVariance(array $values, ?float $mean = null) : float { $count = \count($values); @@ -170,7 +170,7 @@ final class MeasureOfDispersion } /** - * Calculage empirical variance. + * Calculate empirical variance. * * Similar to `sampleVariance`. * @@ -188,7 +188,7 @@ final class MeasureOfDispersion * * @since 1.0.0 */ - public static function empiricalVariance(array $values, array $probabilities = [], float $mean = null) : float + public static function empiricalVariance(array $values, array $probabilities = [], ?float $mean = null) : float { $count = \count($values); $hasProbability = !empty($probabilities); @@ -208,7 +208,7 @@ final class MeasureOfDispersion } /** - * Calculage empirical covariance. + * Calculate empirical covariance. * * Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3]) * @@ -226,7 +226,7 @@ final class MeasureOfDispersion * * @since 1.0.0 */ - public static function empiricalCovariance(array $x, array $y, float $meanX = null, float $meanY = null) : float + public static function empiricalCovariance(array $x, array $y, ?float $meanX = null, ?float $meanY = null) : float { $count = \count($x); @@ -251,7 +251,7 @@ final class MeasureOfDispersion } /** - * Calculage empirical covariance on a sample + * Calculate empirical covariance on a sample * * Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3]) * @@ -268,7 +268,7 @@ final class MeasureOfDispersion * * @since 1.0.0 */ - public static function sampleCovariance(array $x, array $y, float $meanX = null, float $meanY = null) : float + public static function sampleCovariance(array $x, array $y, ?float $meanX = null, ?float $meanY = null) : float { $count = \count($x); @@ -318,7 +318,7 @@ final class MeasureOfDispersion * * @since 1.0.0 */ - public static function meanDeviation(array $x, float $mean = null, int $offset = 0) : float + public static function meanDeviation(array $x, ?float $mean = null, int $offset = 0) : float { $mean = $mean !== null ? $mean : Average::arithmeticMean($x); $sum = 0.0; @@ -339,7 +339,7 @@ final class MeasureOfDispersion * * @since 1.0.0 */ - public static function meanDeviationArray(array $x, float $mean = null) : array + public static function meanDeviationArray(array $x, ?float $mean = null) : array { $mean = $mean !== null ? $mean : Average::arithmeticMean($x); @@ -361,7 +361,7 @@ final class MeasureOfDispersion * * @since 1.0.0 */ - public static function meanAbsoluteDeviation(array $x, float $mean = null, int $offset = 0) : float + public static function meanAbsoluteDeviation(array $x, ?float $mean = null, int $offset = 0) : float { $mean = $mean !== null ? $mean : Average::arithmeticMean($x); $sum = 0.0; @@ -382,7 +382,7 @@ final class MeasureOfDispersion * * @since 1.0.0 */ - public static function meanAbsoluteDeviationArray(array $x, float $mean = null) : array + public static function meanAbsoluteDeviationArray(array $x, ?float $mean = null) : array { $mean = $mean !== null ? $mean : Average::arithmeticMean($x); @@ -404,7 +404,7 @@ final class MeasureOfDispersion * * @since 1.0.0 */ - public static function squaredMeanDeviation(array $x, float $mean = null, int $offset = 0) : float + public static function squaredMeanDeviation(array $x, ?float $mean = null, int $offset = 0) : float { $mean = $mean !== null ? $mean : Average::arithmeticMean($x); $sum = 0.0; @@ -425,7 +425,7 @@ final class MeasureOfDispersion * * @since 1.0.0 */ - public static function squaredMeanDeviationArray(array $x, float $mean = null) : array + public static function squaredMeanDeviationArray(array $x, ?float $mean = null) : array { $mean = $mean !== null ? $mean : Average::arithmeticMean($x); diff --git a/Math/Stochastic/Distribution/BetaDistribution.php b/Math/Stochastic/Distribution/BetaDistribution.php index d661d9921..42d553acf 100755 --- a/Math/Stochastic/Distribution/BetaDistribution.php +++ b/Math/Stochastic/Distribution/BetaDistribution.php @@ -163,7 +163,7 @@ final class BetaDistribution } /** - * Get prdobability distribution function. + * Get probability distribution function. * * @param float $x Value * @param float $alpha Alpha diff --git a/Math/Stochastic/Distribution/ChiSquaredDistribution.php b/Math/Stochastic/Distribution/ChiSquaredDistribution.php index 50100a293..d8e582090 100755 --- a/Math/Stochastic/Distribution/ChiSquaredDistribution.php +++ b/Math/Stochastic/Distribution/ChiSquaredDistribution.php @@ -85,7 +85,7 @@ final class ChiSquaredDistribution } /** - * Test hypthesis. + * Test hypothesis. * * Goodness of fit test. * @@ -161,7 +161,7 @@ final class ChiSquaredDistribution * Get probability density function. * * @param float $x Value x - * @param int $df Degreegs of freedom + * @param int $df Degrees of freedom * * @return float * @@ -182,7 +182,7 @@ final class ChiSquaredDistribution * Get cumulative density function. * * @param float $x Value x - * @param int $df Degreegs of freedom + * @param int $df Degrees of freedom * * @return float * diff --git a/Math/Stochastic/Distribution/FDistribution.php b/Math/Stochastic/Distribution/FDistribution.php index 5890ea95f..a36f6b0b8 100755 --- a/Math/Stochastic/Distribution/FDistribution.php +++ b/Math/Stochastic/Distribution/FDistribution.php @@ -40,8 +40,8 @@ final class FDistribution * Get probability density function. * * @param float $x Value x - * @param int $d1 Degreegs of freedom - * @param int $d2 Degreegs of freedom + * @param int $d1 Degrees of freedom + * @param int $d2 Degrees of freedom * * @return float * @@ -57,8 +57,8 @@ final class FDistribution * Get cumulative density function. * * @param float $x Value x - * @param int $d1 Degreegs of freedom - * @param int $d2 Degreegs of freedom + * @param int $d1 Degrees of freedom + * @param int $d2 Degrees of freedom * * @return float * diff --git a/Math/Stochastic/Distribution/LaplaceDistribution.php b/Math/Stochastic/Distribution/LaplaceDistribution.php index d4d0b91e1..fbf92f0a7 100755 --- a/Math/Stochastic/Distribution/LaplaceDistribution.php +++ b/Math/Stochastic/Distribution/LaplaceDistribution.php @@ -139,7 +139,7 @@ final class LaplaceDistribution /** * Get moment generating function. * - * @param float $t Valute t + * @param float $t Value t * @param float $mu Mean * @param float $b Value b * diff --git a/Math/Stochastic/Distribution/TDistribution.php b/Math/Stochastic/Distribution/TDistribution.php index e88523cfd..3b0cafd28 100755 --- a/Math/Stochastic/Distribution/TDistribution.php +++ b/Math/Stochastic/Distribution/TDistribution.php @@ -210,8 +210,8 @@ final class TDistribution $sum = $term; while ($i < $degrees) { $term *= $cos ** 2 * ($i - 1) / $i; - $sum += $term; - $i += 2; + $sum += $term; + $i += 2; } $sum *= $sin; diff --git a/Math/Stochastic/Distribution/ZTesting.php b/Math/Stochastic/Distribution/ZTesting.php index 0a83d14bb..c50ca5ca5 100755 --- a/Math/Stochastic/Distribution/ZTesting.php +++ b/Math/Stochastic/Distribution/ZTesting.php @@ -93,7 +93,7 @@ final class ZTesting * * @since 1.0.0 */ - public static function zTest(float $value, array $data, float $sigma = null) : float + public static function zTest(float $value, array $data, ?float $sigma = null) : float { $sigma ??= MeasureOfDispersion::standardDeviationSample($data); diff --git a/Math/Stochastic/NaiveBayesClassifier.php b/Math/Stochastic/NaiveBayesClassifier.php index b42e3af6c..eda2acc0e 100755 --- a/Math/Stochastic/NaiveBayesClassifier.php +++ b/Math/Stochastic/NaiveBayesClassifier.php @@ -28,7 +28,7 @@ use phpOMS\Math\Statistic\MeasureOfDispersion; final class NaiveBayesClassifier { /** - * Dictionary of different criterias. + * Dictionary of different criteria. * * @var array * @since 1.0.0 @@ -70,15 +70,15 @@ final class NaiveBayesClassifier foreach ($dataset as $attr => $value) { if (!isset($this->dict[$criteria][$attr])) { $this->dict[$criteria][$attr] = [ - 'type' => \is_array($value) ? 1 : 2, - 'data' => [], + 'type' => \is_array($value) ? 1 : 2, + 'data' => [], ]; } if (!isset($this->probabilities['attr'][$attr])) { $this->probabilities['attr'][$attr] = [ - 'count' => 0, - 'data' => [], + 'count' => 0, + 'data' => [], ]; } @@ -117,7 +117,7 @@ final class NaiveBayesClassifier * * @param string $criteria Criteria to match against * @param array $toMatch Values to match - * @param int $minimum Minimum amount of ocurances for consideration + * @param int $minimum Minimum amount of occurrences for consideration * * @return float * diff --git a/Math/Topology/KernelsND.php b/Math/Topology/KernelsND.php index 483ac2b60..01e33e7be 100644 --- a/Math/Topology/KernelsND.php +++ b/Math/Topology/KernelsND.php @@ -51,14 +51,14 @@ final class KernelsND { $dim = \count($bandwidths); - $bandwithMatrix = Matrix::fromArray($bandwidths); - $distnaceMatrix = Matrix::fromArray($distances); - $identityMatrix = new IdentityMatrix($dim); + $bandwidthMatrix = Matrix::fromArray($bandwidths); + $distanceMatrix = Matrix::fromArray($distances); + $identityMatrix = new IdentityMatrix($dim); - $cov = $bandwithMatrix->mult($identityMatrix); + $cov = $bandwidthMatrix->mult($identityMatrix); /** @phpstan-ignore-next-line */ - $exponent = $distnaceMatrix->mult($cov->inverse())->mult($distnaceMatrix)->sum(1)->mult(-0.5); + $exponent = $distanceMatrix->mult($cov->inverse())->mult($distanceMatrix)->sum(1)->mult(-0.5); return $exponent->exp()->mult((1 / \pow(2 * \M_PI, $dim / 2)) * \pow($cov->det(), 0.5))->matrix; } diff --git a/Message/Cli/CliHeader.php b/Message/Cli/CliHeader.php index 0a7f4e280..e1b47a860 100755 --- a/Message/Cli/CliHeader.php +++ b/Message/Cli/CliHeader.php @@ -129,7 +129,7 @@ final class CliHeader extends HeaderAbstract * * @since 1.0.0 */ - public function get(string $key = null) : array + public function get(?string $key = null) : array { return $key === null ? $this->header : ($this->header[\strtolower($key)] ?? []); } diff --git a/Message/Cli/CliRequest.php b/Message/Cli/CliRequest.php index eb57db07e..b4ab87d0c 100755 --- a/Message/Cli/CliRequest.php +++ b/Message/Cli/CliRequest.php @@ -66,7 +66,7 @@ final class CliRequest extends RequestAbstract * * @since 1.0.0 */ - public function __construct(UriInterface $uri = null, Localization $l11n = null) + public function __construct(?UriInterface $uri = null, ?Localization $l11n = null) { $this->header = new CliHeader(); $this->header->l11n = $l11n ?? new Localization(); @@ -85,7 +85,7 @@ final class CliRequest extends RequestAbstract * * @since 1.0.0 */ - public function getData(string $key = null, string $type = null) : mixed + public function getData(?string $key = null, ?string $type = null) : mixed { if ($key === null) { return $this->data; diff --git a/Message/Cli/CliResponse.php b/Message/Cli/CliResponse.php index 580357a9f..3be1e9887 100755 --- a/Message/Cli/CliResponse.php +++ b/Message/Cli/CliResponse.php @@ -48,7 +48,7 @@ final class CliResponse extends ResponseAbstract implements RenderableInterface * * @since 1.0.0 */ - public function __construct(Localization $l11n = null) + public function __construct(?Localization $l11n = null) { $this->header = new CliHeader(); $this->header->l11n = $l11n ?? new Localization(); diff --git a/Message/HeaderAbstract.php b/Message/HeaderAbstract.php index 7f3ae51c0..aabffba6e 100755 --- a/Message/HeaderAbstract.php +++ b/Message/HeaderAbstract.php @@ -143,7 +143,7 @@ abstract class HeaderAbstract * * @since 1.0.0 */ - abstract public function get(string $key = null) : array; + abstract public function get(?string $key = null) : array; /** * Header has key? diff --git a/Message/Http/HttpHeader.php b/Message/Http/HttpHeader.php index 100857e5c..6192a5dee 100755 --- a/Message/Http/HttpHeader.php +++ b/Message/Http/HttpHeader.php @@ -290,7 +290,7 @@ final class HttpHeader extends HeaderAbstract /** * {@inheritdoc} */ - public function get(string $key = null) : array + public function get(?string $key = null) : array { return $key === null ? $this->header : ($this->header[\strtolower($key)] ?? []); } diff --git a/Message/Http/HttpRequest.php b/Message/Http/HttpRequest.php index e7ae85f16..2be173972 100755 --- a/Message/Http/HttpRequest.php +++ b/Message/Http/HttpRequest.php @@ -77,7 +77,7 @@ final class HttpRequest extends RequestAbstract * * @since 1.0.0 */ - public function __construct(UriInterface $uri = null, Localization $l11n = null) + public function __construct(?UriInterface $uri = null, ?Localization $l11n = null) { $this->header = new HttpHeader(); $this->header->l11n = $l11n ?? new Localization(); @@ -115,8 +115,8 @@ final class HttpRequest extends RequestAbstract $this->data = $_POST + $_GET; $this->files = $_FILES; $this->header->initCurrentRequest(); - $this->header->l11n->setLanguage($this->getRequestLanguage()); - $this->header->l11n->setCountry($this->getRequestCountry()); + $this->header->l11n->language = $this->getRequestLanguage(); + $this->header->l11n->country = $this->getRequestCountry(); $this->initNonGetData(); } @@ -156,7 +156,7 @@ final class HttpRequest extends RequestAbstract } $input .= $lineRaw; - $size += \strlen($lineRaw); + $size += \strlen($lineRaw); } \fclose($stream); @@ -192,7 +192,7 @@ final class HttpRequest extends RequestAbstract } $content .= $lineRaw; - $size += \strlen($lineRaw); + $size += \strlen($lineRaw); } \fclose($stream); @@ -447,7 +447,7 @@ final class HttpRequest extends RequestAbstract */ public static function createFromSuperglobals() : self { - $request = new self(); + $request = new self(); $request->initRequest(); return $request; @@ -464,7 +464,7 @@ final class HttpRequest extends RequestAbstract */ public function setUri(UriInterface $uri) : void { - $this->uri = $uri; + $this->uri = $uri; $this->data += $uri->getQueryArray(); } diff --git a/Message/Http/HttpResponse.php b/Message/Http/HttpResponse.php index 23608abe6..4fbe034fd 100755 --- a/Message/Http/HttpResponse.php +++ b/Message/Http/HttpResponse.php @@ -42,7 +42,7 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface * * @since 1.0.0 */ - public function __construct(Localization $l11n = null) + public function __construct(?Localization $l11n = null) { $this->header = new HttpHeader(); $this->header->l11n = $l11n ?? new Localization(); @@ -103,7 +103,7 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface /** * Generate response based on header. * - * @param mixed ...$data Data passt to render function. (0 => bool: $optimize) + * @param mixed ...$data Data passed to render function. (0 => bool: $optimize) * * @return string * diff --git a/Message/Http/Rest.php b/Message/Http/Rest.php index 8eea3b030..9dd6b6adf 100755 --- a/Message/Http/Rest.php +++ b/Message/Http/Rest.php @@ -96,7 +96,7 @@ final class Rest $data = self::createMultipartData($boundary, $request->data); // @todo Replace boundary/ with the correct boundary= in the future. - // Currently this cannot be done due to a bug. If we do it now the server cannot correclty populate php://input + // Currently this cannot be done due to a bug. If we do it now the server cannot correctly populate php://input $headers['Content-Type'] = 'Content-Type: multipart/form-data; boundary/' . $boundary; $headers['content-length'] = 'Content-Length: ' . \strlen($data); diff --git a/Message/Mail/Email.php b/Message/Mail/Email.php index 5ef5d13f2..ba725ada4 100755 --- a/Message/Mail/Email.php +++ b/Message/Mail/Email.php @@ -642,8 +642,8 @@ class Email implements MessageInterface $this->headerMime = ''; $this->bodyMime = $this->createBody(); - $tempheaders = $this->headerMime; - $this->headerMime = $this->createHeader(); + $tempheaders = $this->headerMime; + $this->headerMime = $this->createHeader(); $this->headerMime .= $tempheaders; if ($this->mailer === SubmitType::MAIL) { @@ -830,7 +830,7 @@ class Email implements MessageInterface break; default: // Catches case 'plain': and case '': - $result .= 'Content-Type: ' . $this->contentType . '; charset=' . $this->charset . self::$LE; + $result .= 'Content-Type: ' . $this->contentType . '; charset=' . $this->charset . self::$LE; $isMultipart = false; break; } @@ -1087,7 +1087,7 @@ class Email implements MessageInterface default: // Catch case 'plain' and case '', applies to simple `text/plain` and `text/html` body content types $this->encoding = $bodyEncoding; - $body .= $this->encodeString($this->body, $this->encoding); + $body .= $this->encodeString($this->body, $this->encoding); break; } @@ -1129,9 +1129,9 @@ class Email implements MessageInterface \unlink($signed); //The message returned by openssl contains both headers and body, so need to split them up - $parts = \explode("\n\n", $body, 2); + $parts = \explode("\n\n", $body, 2); $this->headerMime .= $parts[0] . self::$LE . self::$LE; - $body = $parts[1]; + $body = $parts[1]; } return $body; @@ -1510,8 +1510,8 @@ class Email implements MessageInterface $len -= 2; } - $part = \substr($word, 0, $len); - $word = \substr($word, $len); + $part = \substr($word, 0, $len); + $word = \substr($word, $len); $buf .= ' ' . $part; $message .= $buf . \sprintf('=%s', self::$LE); } else { @@ -1553,7 +1553,7 @@ class Email implements MessageInterface $buf .= $word; if ($bufO !== '' && \strlen($buf) > $length) { $message .= $bufO . $softBreak; - $buf = $word; + $buf = $word; } } @@ -1959,7 +1959,7 @@ class Email implements MessageInterface * * @since 1.0.0 */ - public function addCustomHeader(string $name, string $value = null) : bool + public function addCustomHeader(string $name, ?string $value = null) : bool { $name = \trim($name); $value = \trim($value); @@ -2003,7 +2003,7 @@ class Email implements MessageInterface * * @since 1.0.0 */ - public function msgHTML(string $message, string $basedir = '', \Closure $advanced = null) + public function msgHTML(string $message, string $basedir = '', ?\Closure $advanced = null) { \preg_match_all('/(?= 0x21) && ($ord <= 0x3A)) || $ord === 0x3C || (($ord >= 0x3E) && ($ord <= 0x7E)) ? $txt[$i] : '=' . \sprintf('%02X', $ord); diff --git a/Message/Mail/Imap.php b/Message/Mail/Imap.php index e9823357a..23b16a035 100755 --- a/Message/Mail/Imap.php +++ b/Message/Mail/Imap.php @@ -91,7 +91,7 @@ class Imap implements MailBoxInterface $this->password = $pass; $this->port = $port; $this->encryption = $encryption; - $this->flags .= $this->encryption !== EncryptionType::NONE ? '/ssl' : ''; + $this->flags .= $this->encryption !== EncryptionType::NONE ? '/ssl' : ''; } /** @@ -254,9 +254,9 @@ class Imap implements MailBoxInterface string $cc = '', string $from = '', string $bcc = '', - \DateTime $before = null, - \DateTime $since = null, - \DateTime $on = null, + ?\DateTime $before = null, + ?\DateTime $since = null, + ?\DateTime $on = null, bool $deleted = false, bool $flagged = false ) : array diff --git a/Message/Mail/MailBoxInterface.php b/Message/Mail/MailBoxInterface.php index 05e0c10c6..021d279a5 100755 --- a/Message/Mail/MailBoxInterface.php +++ b/Message/Mail/MailBoxInterface.php @@ -76,7 +76,7 @@ interface MailBoxInterface public function countUnseen(string $box) : int; /** - * Get messages by search criterium + * Get messages by search criteria * * @param string $box Box to count the mail in * @param string $subject Subject @@ -86,7 +86,7 @@ interface MailBoxInterface * @param string $from From * @param string $bcc BCC * @param \DateTime $before Message before - * @param \DateTime $sicne Message since + * @param \DateTime $since Message since * @param \DateTime $on Message on date * @param bool $deleted Message is deleted * @param bool $flagged Message is flagged (false = any message) @@ -103,9 +103,9 @@ interface MailBoxInterface string $cc = '', string $from = '', string $bcc = '', - \DateTime $before = null, - \DateTime $since = null, - \DateTime $on = null, + ?\DateTime $before = null, + ?\DateTime $since = null, + ?\DateTime $on = null, bool $deleted = false, bool $flagged = false ) : array; diff --git a/Message/Mail/MailHandler.php b/Message/Mail/MailHandler.php index d073444bd..e3ab31749 100755 --- a/Message/Mail/MailHandler.php +++ b/Message/Mail/MailHandler.php @@ -18,6 +18,7 @@ declare(strict_types=1); namespace phpOMS\Message\Mail; +use phpOMS\Security\Guard; use phpOMS\System\SystemUtils; use phpOMS\Utils\StringUtils; use phpOMS\Validation\Network\Email as EmailValidator; @@ -322,7 +323,7 @@ class MailHandler $header = \rtrim($mail->headerMime, " \r\n\t") . self::$LE . self::$LE; // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. - if (!empty($mail->sender) && StringUtils::isShellSafe($mail->sender)) { + if (!empty($mail->sender) && Guard::isShellSafe($mail->sender)) { $mailerToolFmt = $this->mailer === SubmitType::QMAIL ? '%s -f%s' : '%s -oi -f%s -t'; @@ -372,7 +373,7 @@ class MailHandler $params = null; if (!empty($mail->sender) && EmailValidator::isValid($mail->sender) - && StringUtils::isShellSafe($mail->sender) + && Guard::isShellSafe($mail->sender) ) { $params = \sprintf('-f%s', $mail->sender); } @@ -405,7 +406,7 @@ class MailHandler * * @since 1.0.0 */ - private function mailPassthru(string $to, Email $mail, string $header, string $params = null) : bool + private function mailPassthru(string $to, Email $mail, string $header, ?string $params = null) : bool { $subject = $mail->encodeHeader(\trim(\str_replace(["\r", "\n"], '', $mail->subject))); @@ -477,7 +478,7 @@ class MailHandler * * @since 1.0.0 */ - public function smtpConnect(array $options = null) : bool + public function smtpConnect(?array $options = null) : bool { if ($this->smtp === null) { $this->smtp = new Smtp(); diff --git a/Message/Mail/Pop3.php b/Message/Mail/Pop3.php index e56be9721..3ddc28b84 100755 --- a/Message/Mail/Pop3.php +++ b/Message/Mail/Pop3.php @@ -250,9 +250,9 @@ class Pop3 implements MailBoxInterface string $cc = '', string $from = '', string $bcc = '', - \DateTime $before = null, - \DateTime $since = null, - \DateTime $on = null, + ?\DateTime $before = null, + ?\DateTime $since = null, + ?\DateTime $on = null, bool $deleted = false, bool $flagged = false ) : array diff --git a/Message/Mail/Smtp.php b/Message/Mail/Smtp.php index c1496aaca..e2898156e 100755 --- a/Message/Mail/Smtp.php +++ b/Message/Mail/Smtp.php @@ -460,9 +460,9 @@ class Smtp } } - $tmpTimeLimit = $this->timeLimit; + $tmpTimeLimit = $this->timeLimit; $this->timeLimit *= 2; - $result = $this->sendCommand('DATA END', '.', [250]); + $result = $this->sendCommand('DATA END', '.', [250]); $this->recordLastTransactionId(); @@ -833,7 +833,7 @@ class Smtp } } - $str = \fgets($this->con, self::MAX_REPLY_LENGTH); + $str = \fgets($this->con, self::MAX_REPLY_LENGTH); $data .= $str; // If response is only 3 chars (not valid, but RFC5321 S4.2 says it must be handled), diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index 54b44e816..b3c88d536 100755 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -92,7 +92,7 @@ abstract class RequestAbstract implements MessageInterface * * @since 1.0.0 */ - public function getData(string $key = null, string $type = null) : mixed + public function getData(?string $key = null, ?string $type = null) : mixed { if ($key === null) { return $this->data; diff --git a/Message/ResponseAbstract.php b/Message/ResponseAbstract.php index 45789786c..47b01277c 100755 --- a/Message/ResponseAbstract.php +++ b/Message/ResponseAbstract.php @@ -51,7 +51,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface * * @since 1.0.0 */ - public function getData(mixed $key = null, string $type = null) : mixed + public function getData(mixed $key = null, ?string $type = null) : mixed { if ($key === null) { return $this->data; diff --git a/Message/Socket/PacketManager.php b/Message/Socket/PacketManager.php index 2d8d90d9a..2715a3e29 100755 --- a/Message/Socket/PacketManager.php +++ b/Message/Socket/PacketManager.php @@ -72,12 +72,12 @@ class PacketManager public function handle(string $data, $client) : void { $request = new SocketRequest(); - $request->header->account = $client->getAccount()->getId(); + $request->header->account = $client->account->id; $response = new SocketResponse(); $this->dispatcher->dispatch( - $this->router->route($data, null, RouteVerb::ANY, 2, 1, $client->getAccount()), + $this->router->route($data, null, RouteVerb::ANY, 2, 1, $client->account), $request, $response ); diff --git a/Message/Socket/SocketHeader.php b/Message/Socket/SocketHeader.php index e2bf15332..5505ca499 100755 --- a/Message/Socket/SocketHeader.php +++ b/Message/Socket/SocketHeader.php @@ -249,7 +249,7 @@ class SocketHeader extends HeaderAbstract implements SerializableInterface /** * {@inheritdoc} */ - public function get(string $key = null) : array + public function get(?string $key = null) : array { return $key === null ? $this->header : ($this->header[\strtolower($key)] ?? []); } diff --git a/Model/Html/Head.php b/Model/Html/Head.php index e072d6c55..9607ea11e 100755 --- a/Model/Html/Head.php +++ b/Model/Html/Head.php @@ -36,7 +36,7 @@ final class Head implements RenderableInterface * @var string * @since 1.0.0 */ - private string $language = ISO639x1Enum::_EN; + public string $language = ISO639x1Enum::_EN; /** * Page title. @@ -167,7 +167,7 @@ final class Head implements RenderableInterface */ public function render(mixed ...$data) : string { - $head = ''; + $head = ''; $head .= $this->meta->render(); $head .= $this->renderAssets(); $head .= empty($this->style) ? '' : ''; diff --git a/Module/Exception/InvalidModuleException.php b/Module/Exception/InvalidModuleException.php index 23562458d..a86b75ab6 100755 --- a/Module/Exception/InvalidModuleException.php +++ b/Module/Exception/InvalidModuleException.php @@ -15,7 +15,7 @@ declare(strict_types=1); namespace phpOMS\Module\Exception; /** - * Zero devision exception. + * Zero division exception. * * @package phpOMS\Module\Exception * @license OMS License 2.0 @@ -33,7 +33,7 @@ final class InvalidModuleException extends \UnexpectedValueException * * @since 1.0.0 */ - public function __construct(string $message, int $code = 0, \Exception $previous = null) + public function __construct(string $message, int $code = 0, ?\Exception $previous = null) { parent::__construct('Data for module "' . $message . '" could be found.', $code, $previous); } diff --git a/Module/Exception/InvalidThemeException.php b/Module/Exception/InvalidThemeException.php index 82f62f428..a7d47c889 100755 --- a/Module/Exception/InvalidThemeException.php +++ b/Module/Exception/InvalidThemeException.php @@ -33,7 +33,7 @@ final class InvalidThemeException extends \UnexpectedValueException * * @since 1.0.0 */ - public function __construct(string $message, int $code = 0, \Exception $previous = null) + public function __construct(string $message, int $code = 0, ?\Exception $previous = null) { parent::__construct('Data for theme "' . $message . '" could be found.', $code, $previous); } diff --git a/Module/InstallerAbstract.php b/Module/InstallerAbstract.php index 316520c04..8e14c189b 100755 --- a/Module/InstallerAbstract.php +++ b/Module/InstallerAbstract.php @@ -132,7 +132,7 @@ abstract class InstallerAbstract * * @since 1.0.0 */ - public static function reInit(ModuleInfo $info, ApplicationInfo $appInfo = null) : void + public static function reInit(ModuleInfo $info, ?ApplicationInfo $appInfo = null) : void { if (($path = \realpath(static::PATH)) === false) { return; // @codeCoverageIgnore diff --git a/Module/ModuleAbstract.php b/Module/ModuleAbstract.php index 744d1a4ba..5c967cfba 100755 --- a/Module/ModuleAbstract.php +++ b/Module/ModuleAbstract.php @@ -120,7 +120,7 @@ abstract class ModuleAbstract * * @since 1.0.0 */ - public function __construct(ApplicationAbstract $app = null) + public function __construct(?ApplicationAbstract $app = null) { $this->app = $app ?? new class() extends ApplicationAbstract {}; @@ -903,7 +903,7 @@ abstract class ModuleAbstract * * @feature Implement softDelete functionality. * Models which have a soft delete cannot be used, read or modified unless a person has soft delete permissions - * In addition to DELETE permisstions we now need SOFTDELETE as well. + * In addition to DELETE permissions we now need SOFTDELETE as well. * There also needs to be an undo function for this soft delete * In a backend environment a soft delete would be very helpful!!! * diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 5274c9712..cb10e3fc0 100755 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -113,7 +113,7 @@ final class ModuleManager * * @since 1.0.0 */ - public function getLanguageFiles(RequestAbstract $request, string $app = null) : array + public function getLanguageFiles(RequestAbstract $request, ?string $app = null) : array { $files = $this->getUriLoad($request); if (!isset($files['5'])) { @@ -249,7 +249,7 @@ final class ModuleManager * * @since 1.0.0 */ - public function isRunning(string $module, string $ctlName = null) : bool + public function isRunning(string $module, ?string $ctlName = null) : bool { $name = '\\Modules\\' . $module . '\\Controller\\' . ($ctlName ?? $this->app->appName) . 'Controller'; @@ -475,7 +475,7 @@ final class ModuleManager * * @since 1.0.0 */ - public function reInit(string $module, ApplicationInfo $appInfo = null) : void + public function reInit(string $module, ?ApplicationInfo $appInfo = null) : void { $info = $this->loadInfo($module); if ($info === null) { @@ -664,7 +664,7 @@ final class ModuleManager * * @since 1.0.0 */ - public function get(string $module, string $ctlName = null) : ModuleAbstract + public function get(string $module, ?string $ctlName = null) : ModuleAbstract { $name = '\\Modules\\' . $module . '\\Controller\\' . ($ctlName ?? $this->app->appName) . 'Controller'; if (!isset($this->running[$name])) { @@ -687,7 +687,7 @@ final class ModuleManager * * @since 1.0.0 */ - private function initModuleController(string $module, string $ctlName = null) : void + private function initModuleController(string $module, ?string $ctlName = null) : void { $name = '\\Modules\\' . $module . '\\Controller\\' . ($ctlName ?? $this->app->appName) . 'Controller'; $this->running[$name] = $this->getModuleInstance($module, $ctlName); @@ -707,7 +707,7 @@ final class ModuleManager * * @since 1.0.0 */ - public function getModuleInstance(string $module, string $ctlName = null) : ModuleAbstract + public function getModuleInstance(string $module, ?string $ctlName = null) : ModuleAbstract { $class = '\\Modules\\' . $module . '\\Controller\\' . ($ctlName ?? $this->app->appName) . 'Controller'; @@ -740,7 +740,7 @@ final class ModuleManager * * @since 1.0.0 */ - public function initRequestModules(RequestAbstract $request, string $ctlName = null) : void + public function initRequestModules(RequestAbstract $request, ?string $ctlName = null) : void { $toInit = $this->getRoutedModules($request); foreach ($toInit as $module) { diff --git a/Module/NullModule.php b/Module/NullModule.php index 55244dd0e..2cc502da7 100755 --- a/Module/NullModule.php +++ b/Module/NullModule.php @@ -17,7 +17,7 @@ namespace phpOMS\Module; use phpOMS\Log\FileLogger; /** - * Module abstraction class. + * Mull module class. * * @package phpOMS\Module * @license OMS License 2.0 diff --git a/Module/StatusAbstract.php b/Module/StatusAbstract.php index f4109077f..fc385bf76 100755 --- a/Module/StatusAbstract.php +++ b/Module/StatusAbstract.php @@ -69,7 +69,7 @@ abstract class StatusAbstract * * @since 1.0.0 */ - public static function activateRoutes(ModuleInfo $info, ApplicationInfo $appInfo = null) : void + public static function activateRoutes(ModuleInfo $info, ?ApplicationInfo $appInfo = null) : void { self::activateRoutesHooks($info, $appInfo, 'Routes'); } @@ -125,7 +125,7 @@ abstract class StatusAbstract * * @since 1.0.0 */ - public static function activateHooks(ModuleInfo $info, ApplicationInfo $appInfo = null) : void + public static function activateHooks(ModuleInfo $info, ?ApplicationInfo $appInfo = null) : void { self::activateRoutesHooks($info, $appInfo, 'Hooks'); } @@ -140,7 +140,7 @@ abstract class StatusAbstract * * @since 1.0.0 */ - public static function activateRoutesHooks(ModuleInfo $info, ApplicationInfo $appInfo = null, string $type) : void + public static function activateRoutesHooks(ModuleInfo $info, ?ApplicationInfo $appInfo = null, string $type) : void { $directories = new Directory(static::PATH . '/' . $type); @@ -195,7 +195,7 @@ abstract class StatusAbstract * * @since 1.0.0 */ - public static function deactivateRoutes(ModuleInfo $info, ApplicationInfo $appInfo = null) : void + public static function deactivateRoutes(ModuleInfo $info, ?ApplicationInfo $appInfo = null) : void { self::deactivateRoutesHooks($info, $appInfo, 'Routes'); } @@ -210,7 +210,7 @@ abstract class StatusAbstract * * @since 1.0.0 */ - public static function deactivateRoutesHooks(ModuleInfo $info, ApplicationInfo $appInfo = null, string $type) : void + public static function deactivateRoutesHooks(ModuleInfo $info, ?ApplicationInfo $appInfo = null, string $type) : void { $directories = new Directory(static::PATH . '/'. $type); @@ -283,7 +283,7 @@ abstract class StatusAbstract * * @since 1.0.0 */ - public static function deactivateHooks(ModuleInfo $info, ApplicationInfo $appInfo = null) : void + public static function deactivateHooks(ModuleInfo $info, ?ApplicationInfo $appInfo = null) : void { self::deactivateRoutesHooks($info, $appInfo, 'Hooks'); } diff --git a/Router/RouterInterface.php b/Router/RouterInterface.php index 5e6be5c02..ffcfc013a 100755 --- a/Router/RouterInterface.php +++ b/Router/RouterInterface.php @@ -85,11 +85,11 @@ interface RouterInterface */ public function route( string $uri, - string $csrf = null, + ?string $csrf = null, int $verb = RouteVerb::GET, - int $app = null, - int $unitId = null, - Account $account = null, - array $data = null + ?int $app = null, + ?int $unitId = null, + ?Account $account = null, + ?array $data = null ) : array; } diff --git a/Router/SocketRouter.php b/Router/SocketRouter.php index 718d451f4..a5cd0e9e5 100755 --- a/Router/SocketRouter.php +++ b/Router/SocketRouter.php @@ -110,12 +110,12 @@ final class SocketRouter implements RouterInterface */ public function route( string $uri, - string $csrf = null, + ?string $csrf = null, int $verb = RouteVerb::GET, - int $app = null, - int $unitId = null, - Account $account = null, - array $data = null + ?int $app = null, + ?int $unitId = null, + ?Account $account = null, + ?array $data = null ) : array { $bound = []; @@ -136,7 +136,7 @@ final class SocketRouter implements RouterInterface // if permission check is invalid if (isset($d['permission']) && !empty($d['permission']) - && ($account === null || $account->getId() === 0) + && ($account === null || $account->id === 0) ) { return ['dest' => RouteStatus::NOT_LOGGED_IN]; } elseif (isset($d['permission']) && !empty($d['permission']) diff --git a/Router/WebRouter.php b/Router/WebRouter.php index e5eb36631..06c42c7da 100755 --- a/Router/WebRouter.php +++ b/Router/WebRouter.php @@ -112,12 +112,12 @@ final class WebRouter implements RouterInterface */ public function route( string $uri, - string $csrf = null, + ?string $csrf = null, int $verb = RouteVerb::GET, - int $app = null, - int $unitId = null, - Account $account = null, - array $data = null + ?int $app = null, + ?int $unitId = null, + ?Account $account = null, + ?array $data = null ) : array { $bound = []; @@ -138,7 +138,7 @@ final class WebRouter implements RouterInterface // if permission check is invalid if (isset($d['permission']) && !empty($d['permission']) - && ($account === null || $account->getId() === 0) + && ($account === null || $account->id === 0) ) { return ['dest' => RouteStatus::NOT_LOGGED_IN]; } elseif (isset($d['permission']) && !empty($d['permission']) diff --git a/Security/Guard.php b/Security/Guard.php index cb80c5cb3..4f9d773bf 100755 --- a/Security/Guard.php +++ b/Security/Guard.php @@ -84,4 +84,34 @@ final class Guard return $data; } + + /** + * Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters. + * + * @param string $string String to check + * + * @return bool + * + * @since 1.0.0 + */ + public static function isShellSafe(string $string) : bool + { + if (\escapeshellcmd($string) !== $string + || !\in_array(\escapeshellarg($string), ["'{$string}'", "\"{$string}\""]) + ) { + return false; + } + + $length = \strlen($string); + + for ($i = 0; $i < $length; ++$i) { + $c = $string[$i]; + + if (!\ctype_alnum($c) && \strpos('@_-.', $c) === false) { + return false; + } + } + + return true; + } } diff --git a/Security/PhpCode.php b/Security/PhpCode.php index c5ade693f..536e0cec6 100755 --- a/Security/PhpCode.php +++ b/Security/PhpCode.php @@ -18,7 +18,7 @@ namespace phpOMS\Security; * Php code security class. * * This can be used to ensure php code doesn't contain malicious functions and or characters. - * Additionally this can also be used in order verify that the source code is not altered compared to some expected source code. + * Additionally, this can also be used in order verify that the source code is not altered compared to some expected source code. * * @package phpOMS\Security * @license OMS License 2.0 @@ -156,12 +156,12 @@ final class PhpCode } /** - * Validate file integrety + * Validate file integrity * * @param string $source Source code path * @param string $hash Source hash (md5) * - * @return bool Returns true if filee matches expected signature otherwise false is returned + * @return bool Returns true if file matches expected signature otherwise false is returned * * @since 1.0.0 */ @@ -171,7 +171,7 @@ final class PhpCode } /** - * Validate code integrety + * Validate code integrity * * @param string $source Source code * @param string $remote Remote code diff --git a/Socket/Client/Client.php b/Socket/Client/Client.php index 64b6c1a7f..5d9410008 100755 --- a/Socket/Client/Client.php +++ b/Socket/Client/Client.php @@ -147,7 +147,7 @@ class Client extends SocketAbstract } /** - * Add packet to be handeld + * Add packet to be handled * * @param mixed $packet Packet to handle * diff --git a/Socket/Client/ClientConnection.php b/Socket/Client/ClientConnection.php index 96ff84ea4..1f83b7da5 100755 --- a/Socket/Client/ClientConnection.php +++ b/Socket/Client/ClientConnection.php @@ -48,7 +48,7 @@ class ClientConnection */ public function __construct(Account $account, $socket) { - $this->id = $account->getId(); + $this->id = $account->id; $this->account = $account; $this->socket = $socket; } @@ -108,7 +108,7 @@ class ClientConnection * * @return mixed * - * @sicne 1.0.0 + * @since 1.0.0 */ public function getHandshake() { diff --git a/Socket/Server/Server.php b/Socket/Server/Server.php index facef28d3..026abb1e2 100755 --- a/Socket/Server/Server.php +++ b/Socket/Server/Server.php @@ -174,7 +174,7 @@ class Server extends SocketAbstract $upgrade = "HTTP/1.1 101 Switching Protocols\r\n" . "Upgrade: websocket\r\n" . "Connection: Upgrade\r\n" . - "Sec-WebSocket-Accept: ${acceptKey}" . + "Sec-WebSocket-Accept: {$acceptKey}" . "\r\n\r\n"; \socket_write($client->getSocket(), $upgrade); $client->setHandshake(true); @@ -295,11 +295,11 @@ class Server extends SocketAbstract \socket_shutdown($client->getSocket(), 2); \socket_close($client->getSocket()); - if (isset($this->conn[$client->getId()])) { - unset($this->conn[$client->getId()]); + if (isset($this->conn[$client->id])) { + unset($this->conn[$client->id]); } - $this->clientManager->remove($client->getId()); + $this->clientManager->remove($client->id); $this->app->logger->debug('Disconnected client.'); } diff --git a/Stdlib/Base/AddressType.php b/Stdlib/Base/AddressType.php index a6ecd8aab..f5cff24c3 100755 --- a/Stdlib/Base/AddressType.php +++ b/Stdlib/Base/AddressType.php @@ -34,9 +34,7 @@ abstract class AddressType extends Enum public const WORK = 5; - public const CONTRACT = 6; - - public const OTHER = 7; - public const EDUCATION = 8; + + public const OTHER = 99; } diff --git a/Stdlib/Base/Enum.php b/Stdlib/Base/Enum.php index 5000cb211..7cbd47f21 100755 --- a/Stdlib/Base/Enum.php +++ b/Stdlib/Base/Enum.php @@ -45,6 +45,27 @@ abstract class Enum return \in_array($value, $constants, true); } + /** + * Check enum value. + * + * Checking if a given value is part of this enum + * + * @param mixed $value Value to check + * + * @return mixed + * + * @since 1.0.0 + */ + public static function tryFromValue(mixed $value) : mixed + { + $reflect = new \ReflectionClass(static::class); + $constants = $reflect->getConstants(); + + return \in_array($value, $constants, true) + ? $value + : null; + } + /** * Getting all constants of this enum. * diff --git a/Stdlib/Base/Exception/InvalidEnumName.php b/Stdlib/Base/Exception/InvalidEnumName.php index 007c9dd11..dd9950fab 100755 --- a/Stdlib/Base/Exception/InvalidEnumName.php +++ b/Stdlib/Base/Exception/InvalidEnumName.php @@ -35,7 +35,7 @@ class InvalidEnumName extends \UnexpectedValueException * * @since 1.0.0 */ - public function __construct(string $message, int $code = 0, \Exception $previous = null) + public function __construct(string $message, int $code = 0, ?\Exception $previous = null) { parent::__construct('The enum name "' . $message . '" is not valid.', $code, $previous); } diff --git a/Stdlib/Base/Exception/InvalidEnumValue.php b/Stdlib/Base/Exception/InvalidEnumValue.php index f7d95ac8e..93d121ca3 100755 --- a/Stdlib/Base/Exception/InvalidEnumValue.php +++ b/Stdlib/Base/Exception/InvalidEnumValue.php @@ -35,7 +35,7 @@ class InvalidEnumValue extends \UnexpectedValueException * * @since 1.0.0 */ - public function __construct($message, int $code = 0, \Exception $previous = null) + public function __construct($message, int $code = 0, ?\Exception $previous = null) { parent::__construct('The enum value "' . $message . '" is not valid.', $code, $previous); } diff --git a/Stdlib/Base/FloatInt.php b/Stdlib/Base/FloatInt.php index 1104f0d18..ccd4f4b02 100755 --- a/Stdlib/Base/FloatInt.php +++ b/Stdlib/Base/FloatInt.php @@ -145,6 +145,20 @@ class FloatInt implements SerializableInterface return $this; } + public function getNormalizedValue() : float + { + return $this->value / \pow(10, self::MAX_DECIMALS); + } + + public function guessScalarValue() : int|float + { + $divider = \pow(10, self::MAX_DECIMALS); + + return $this->value % $divider === 0 + ? (int) ($this->value / $divider) + : (float) ($this->value / $divider); + } + /** * Get money. * diff --git a/Stdlib/Base/Heap.php b/Stdlib/Base/Heap.php index d3dbcf697..aad6b0ccc 100755 --- a/Stdlib/Base/Heap.php +++ b/Stdlib/Base/Heap.php @@ -47,7 +47,7 @@ class Heap * * @since 1.0.0 */ - public function __construct(\Closure $compare = null) + public function __construct(?\Closure $compare = null) { $this->compare = $compare ?? function($a, $b) { return $a <=> $b; diff --git a/Stdlib/Base/Location.php b/Stdlib/Base/Location.php index 2cc1f1467..2260cabef 100755 --- a/Stdlib/Base/Location.php +++ b/Stdlib/Base/Location.php @@ -109,32 +109,6 @@ class Location implements \JsonSerializable, SerializableInterface return $this->id; } - /** - * Get location type - * - * @return int - * - * @since 1.0.0 - */ - public function getType() : int - { - return $this->type; - } - - /** - * Set location type - * - * @param int $type Location type - * - * @return void - * - * @since 1.0.0 - */ - public function setType(int $type) : void - { - $this->type = $type; - } - /** * Get country code * diff --git a/Stdlib/Base/NullAddress.php b/Stdlib/Base/NullAddress.php index e2cd2f297..b4e477311 100644 --- a/Stdlib/Base/NullAddress.php +++ b/Stdlib/Base/NullAddress.php @@ -24,4 +24,15 @@ namespace phpOMS\Stdlib\Base; */ final class NullAddress extends Address { + /** + * Constructor + * + * @param int $id Model id + * + * @since 1.0.0 + */ + public function __construct(int $id = 0) + { + $this->id = $id; + } } diff --git a/Stdlib/Base/NullLocation.php b/Stdlib/Base/NullLocation.php index 4da786fd9..b5d95b361 100755 --- a/Stdlib/Base/NullLocation.php +++ b/Stdlib/Base/NullLocation.php @@ -24,4 +24,15 @@ namespace phpOMS\Stdlib\Base; */ final class NullLocation extends Location { + /** + * Constructor + * + * @param int $id Model id + * + * @since 1.0.0 + */ + public function __construct(int $id = 0) + { + $this->id = $id; + } } diff --git a/Stdlib/Base/SmartDateTime.php b/Stdlib/Base/SmartDateTime.php index c88516aaf..1d7ef7ee0 100755 --- a/Stdlib/Base/SmartDateTime.php +++ b/Stdlib/Base/SmartDateTime.php @@ -52,7 +52,7 @@ class SmartDateTime extends \DateTime * * @since 1.0.0 */ - public function __construct(string $datetime = 'now', \DateTimeZone $timezone = null) + public function __construct(string $datetime = 'now', ?\DateTimeZone $timezone = null) { $parsed = \str_replace( ['Y', 'm', 'd'], @@ -448,8 +448,8 @@ class SmartDateTime extends \DateTime public static function formatDuration(int $duration) : string { - $days = \floor($duration / (24 * 3600)); - $hours = \floor(($duration % (24 * 3600)) / 3600); + $days = \floor($duration / (24 * 3600)); + $hours = \floor(($duration % (24 * 3600)) / 3600); $minutes = \floor(($duration % 3600) / 60); $seconds = $duration % 60; diff --git a/Stdlib/Graph/Graph.php b/Stdlib/Graph/Graph.php index 55955d10b..8cdf8265e 100755 --- a/Stdlib/Graph/Graph.php +++ b/Stdlib/Graph/Graph.php @@ -531,7 +531,7 @@ class Graph */ private function pathBetweenNodesDfs( Node $node1, - Node $node2 = null, + ?Node $node2 = null, array &$visited, array &$path, array &$paths @@ -675,7 +675,7 @@ class Graph /** * Get all paths between two nodes - * Inclides end node, but not start node in the paths + * Includes end node, but not start node in the paths * * @param int|string|Node $node1 Graph node * @param int|string|Node $node2 Graph node @@ -916,7 +916,7 @@ class Graph $current = \array_shift($stack); foreach ($this->nodes as $j) { - // Has neighbour + // Has neighbor if ($this->nodes[$current->getId()]->hasNeighbor($j)) { if ($distances[$j->getId()] === \PHP_INT_MAX) { $distances[$j->getId()] = $distances[$current->getId()] + 1; @@ -1017,7 +1017,7 @@ class Graph * * @since 1.0.0 */ - public function isConnected(int | string | Node $node1 = null, int | string | Node $node2 = null) : bool + public function isConnected(int | string | Node|null $node1 = null, int | string | Node|null $node2 = null) : bool { if (empty($this->nodes)) { return true; diff --git a/Stdlib/Graph/Node.php b/Stdlib/Graph/Node.php index ca0fff92a..ba0848645 100755 --- a/Stdlib/Graph/Node.php +++ b/Stdlib/Graph/Node.php @@ -125,7 +125,7 @@ class Node * * @since 1.0.0 */ - public function setNodeRelative(self $node, int $key = null, bool $isDirected = false) : Edge + public function setNodeRelative(self $node, ?int $key = null, bool $isDirected = false) : Edge { $edge = new Edge($this, $node, 0.0, $isDirected); $this->setEdge($edge, $key); @@ -147,7 +147,7 @@ class Node * * @since 1.0.0 */ - public function setEdge(Edge $edge, int $key = null) : self + public function setEdge(Edge $edge, ?int $key = null) : self { if ($key === null) { $this->edges[] = $edge; diff --git a/Stdlib/Map/MultiMap.php b/Stdlib/Map/MultiMap.php index 949f43f91..fa5fa752f 100755 --- a/Stdlib/Map/MultiMap.php +++ b/Stdlib/Map/MultiMap.php @@ -95,7 +95,7 @@ final class MultiMap implements \Countable // prevent adding elements if keys are just ordered differently if ($this->orderType === OrderType::LOOSE) { /** @var array $keysToTest */ - $keysToTest = Permutation::permut($keys, [], false); + $keysToTest = Permutation::permuteAll($keys, [], false); foreach ($keysToTest as $test) { $key = \implode(':', $test); @@ -219,7 +219,7 @@ final class MultiMap implements \Countable if (\is_array($key)) { if ($this->orderType === OrderType::LOOSE) { /** @var array $keys */ - $keys = Permutation::permut($key, [], false); + $keys = Permutation::permuteAll($key, [], false); foreach ($keys as $key => $value) { $key = \implode(':', $value); @@ -273,7 +273,7 @@ final class MultiMap implements \Countable if ($this->orderType !== OrderType::STRICT) { /** @var array $permutation */ - $permutation = Permutation::permut($key, [], false); + $permutation = Permutation::permuteAll($key, [], false); foreach ($permutation as $permut) { if ($this->setSingle(\implode(':', $permut), $value)) { @@ -344,7 +344,7 @@ final class MultiMap implements \Countable } /** @var array $keys */ - $keys = Permutation::permut($key, [], false); + $keys = Permutation::permuteAll($key, [], false); $found = false; foreach ($keys as $key => $value) { @@ -487,7 +487,7 @@ final class MultiMap implements \Countable if ($this->orderType === OrderType::LOOSE) { $key = \is_array($key) ? $key : [$key]; - return Permutation::permut($key, [], false); + return Permutation::permuteAll($key, [], false); } return []; diff --git a/Stdlib/Tree/BinarySearchTree.php b/Stdlib/Tree/BinarySearchTree.php index 6b03d4f17..93a92e07e 100644 --- a/Stdlib/Tree/BinarySearchTree.php +++ b/Stdlib/Tree/BinarySearchTree.php @@ -40,7 +40,7 @@ class BinarySearchTree * * @since 1.0.0 */ - public function __construct(Node $root = null) + public function __construct(?Node $root = null) { $this->root = $root; } diff --git a/System/File/DirectoryInterface.php b/System/File/DirectoryInterface.php index 4ad150435..4117bdb86 100755 --- a/System/File/DirectoryInterface.php +++ b/System/File/DirectoryInterface.php @@ -32,7 +32,7 @@ interface DirectoryInterface extends \ArrayAccess, \Iterator, ContainerInterface /** * Get node by name. * - * @param string $name File/direcotry name + * @param string $name File/directory name * * @return null|ContainerInterface * diff --git a/System/File/FileUtils.php b/System/File/FileUtils.php index 903fd44e8..7d7cb8bfa 100755 --- a/System/File/FileUtils.php +++ b/System/File/FileUtils.php @@ -164,7 +164,7 @@ final class FileUtils } /** - * Converts a string permisseion (rwx) to octal + * Converts a string permission (rwx) to octal * * @param string $permission Permission string (e.g. rwx-w-r--) * @@ -188,7 +188,7 @@ final class FileUtils } if (($i + 1) % 3 === 0) { - $perm .= $tempPermission; + $perm .= $tempPermission; $tempPermission = 0; } } @@ -206,7 +206,7 @@ final class FileUtils * * @since 1.0.0 */ - public static function mb_pathinfo(string $path, int | string $options = null) : string | array + public static function mb_pathinfo(string $path, int | string|null $options = null) : string | array { $ret = ['dirname' => '', 'basename' => '', 'extension' => '', 'filename' => '']; $pathinfo = []; diff --git a/System/File/Ftp/Directory.php b/System/File/Ftp/Directory.php index 7c50a23fd..8496c6c11 100755 --- a/System/File/Ftp/Directory.php +++ b/System/File/Ftp/Directory.php @@ -87,7 +87,7 @@ class Directory extends FileAbstract implements DirectoryInterface * * @since 1.0.0 */ - public function __construct(HttpUri $uri, bool $initialize = true, \FTP\Connection $con = null) + public function __construct(HttpUri $uri, bool $initialize = true, ?\FTP\Connection $con = null) { $this->uri = $uri; $this->con = $con ?? self::ftpConnect($uri); @@ -680,8 +680,8 @@ class Directory extends FileAbstract implements DirectoryInterface */ public function addNode(ContainerInterface $node) : self { - $this->count += $node->getCount(); - $this->size += $node->getSize(); + $this->count += $node->getCount(); + $this->size += $node->getSize(); $this->nodes[$node->getBasename()] = $node; $node->createNode(); @@ -863,7 +863,7 @@ class Directory extends FileAbstract implements DirectoryInterface * * @since 1.0.0 */ - public function isExisting(string $name = null) : bool + public function isExisting(?string $name = null) : bool { if ($name === null) { return \is_dir($this->path); diff --git a/System/File/Ftp/File.php b/System/File/Ftp/File.php index d8a2bbd51..85d08ea4a 100755 --- a/System/File/Ftp/File.php +++ b/System/File/Ftp/File.php @@ -44,7 +44,7 @@ class File extends FileAbstract implements FileInterface * * @since 1.0.0 */ - public function __construct(HttpUri $uri, \FTP\Connection $con = null) + public function __construct(HttpUri $uri, ?\FTP\Connection $con = null) { $this->uri = $uri; $this->con = $con ?? self::ftpConnect($this->uri); diff --git a/System/File/Ftp/FileAbstract.php b/System/File/Ftp/FileAbstract.php index 9652383b2..f8d229d50 100755 --- a/System/File/Ftp/FileAbstract.php +++ b/System/File/Ftp/FileAbstract.php @@ -273,7 +273,7 @@ abstract class FileAbstract implements FtpContainerInterface // Walk parent path for ($j = $currentLength - $i; $j > 0; --$j) { if ($newParent->parent === null) { - // No pwarent found + // No parent found $newParent = null; break; diff --git a/System/File/Local/Directory.php b/System/File/Local/Directory.php index f7c8b3c33..aa309a9d3 100755 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -188,8 +188,8 @@ final class Directory extends FileAbstract implements DirectoryInterface */ public function addNode(ContainerInterface $node) : self { - $this->count += $node->getCount(); - $this->size += $node->getSize(); + $this->count += $node->getCount(); + $this->size += $node->getSize(); $this->nodes[$node->getBasename()] = $node; $node->createNode(); @@ -465,7 +465,7 @@ final class Directory extends FileAbstract implements DirectoryInterface * * @since 1.0.0 */ - public function isExisting(string $name = null) : bool + public function isExisting(?string $name = null) : bool { if ($name === null) { return \is_dir($this->path); diff --git a/System/File/Local/FileAbstract.php b/System/File/Local/FileAbstract.php index 87b03ec69..b1ea28c0e 100755 --- a/System/File/Local/FileAbstract.php +++ b/System/File/Local/FileAbstract.php @@ -304,7 +304,7 @@ abstract class FileAbstract implements LocalContainerInterface // Walk parent path for ($j = $currentLength - $i; $j > 0; --$j) { if ($newParent->parent === null) { - // No pwarent found + // No parent found $newParent = null; break; diff --git a/System/File/PathException.php b/System/File/PathException.php index 70b18080e..f399a28b9 100755 --- a/System/File/PathException.php +++ b/System/File/PathException.php @@ -33,7 +33,7 @@ final class PathException extends \UnexpectedValueException * * @since 1.0.0 */ - public function __construct(string $message, int $code = 0, \Exception $previous = null) + public function __construct(string $message, int $code = 0, ?\Exception $previous = null) { parent::__construct('The path "' . $message . '" is not a valid path.', $code, $previous); } diff --git a/System/File/PermissionException.php b/System/File/PermissionException.php index 9fa2a1d22..ef19bf726 100755 --- a/System/File/PermissionException.php +++ b/System/File/PermissionException.php @@ -33,7 +33,7 @@ final class PermissionException extends \RuntimeException * * @since 1.0.0 */ - public function __construct(string $message, int $code = 0, \Exception $previous = null) + public function __construct(string $message, int $code = 0, ?\Exception $previous = null) { parent::__construct('Insufficient permissions for "' . $message . '" operations.', $code, $previous); } diff --git a/System/File/Storage.php b/System/File/Storage.php index 56b7fb91f..7adb5956c 100755 --- a/System/File/Storage.php +++ b/System/File/Storage.php @@ -47,7 +47,7 @@ final class Storage } /** - * Get registred env instance. + * Get registered env instance. * * @param string $env Environment name * diff --git a/System/Search/StringSearch.php b/System/Search/StringSearch.php index a37c1c4c9..262614280 100755 --- a/System/Search/StringSearch.php +++ b/System/Search/StringSearch.php @@ -60,7 +60,7 @@ abstract class StringSearch if ($j > 0) { $i += $shift[$j - 1]; - $j = \max($j - $shift[$j - 1], 0); + $j = \max($j - $shift[$j - 1], 0); } else { ++$i; $j = 0; @@ -98,7 +98,7 @@ abstract class StringSearch if ($j > 0) { $i += $shift[$j - 1]; - $j = \max($j - $shift[$j - 1], 0); + $j = \max($j - $shift[$j - 1], 0); } else { ++$i; $j = 0; diff --git a/Uri/Argument.php b/Uri/Argument.php index addbc7ff4..ce35d8d81 100755 --- a/Uri/Argument.php +++ b/Uri/Argument.php @@ -303,7 +303,7 @@ final class Argument implements UriInterface /** * {@inheritdoc} */ - public function getQuery(string $key = null) : string + public function getQuery(?string $key = null) : string { if ($key !== null) { $key = (int) \strtolower($key); diff --git a/Uri/HttpUri.php b/Uri/HttpUri.php index 22f6a8822..7c82a2fd3 100755 --- a/Uri/HttpUri.php +++ b/Uri/HttpUri.php @@ -362,7 +362,7 @@ final class HttpUri implements UriInterface /** * {@inheritdoc} */ - public function getQuery(string $key = null) : string + public function getQuery(?string $key = null) : string { if ($key !== null) { $key = \strtolower($key); diff --git a/Uri/InvalidUriException.php b/Uri/InvalidUriException.php index 326c88876..1ed36c379 100755 --- a/Uri/InvalidUriException.php +++ b/Uri/InvalidUriException.php @@ -33,7 +33,7 @@ class InvalidUriException extends \UnexpectedValueException * * @since 1.0.0 */ - public function __construct(string $message, int $code = 0, \Exception $previous = null) + public function __construct(string $message, int $code = 0, ?\Exception $previous = null) { parent::__construct('The uri "' . $message . '" is not valid.', $code, $previous); } diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index 7a13ca3b1..ddb131f97 100755 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -257,8 +257,7 @@ final class UriFactory } } - $escaped = - (isset($urlStructure['scheme']) && !empty($urlStructure['scheme']) + $escaped = (isset($urlStructure['scheme']) && !empty($urlStructure['scheme']) ? $urlStructure['scheme'] . '://' : '') . (isset($urlStructure['username']) ? $urlStructure['username'] . ':' : '') diff --git a/Uri/UriInterface.php b/Uri/UriInterface.php index da6a92a59..ec8ec6088 100755 --- a/Uri/UriInterface.php +++ b/Uri/UriInterface.php @@ -168,7 +168,7 @@ interface UriInterface * * @since 1.0.0 */ - public function getQuery(string $key = null) : string; + public function getQuery(?string $key = null) : string; /** * Get query array. diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index f71d6f8b0..7217ff1cb 100755 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -279,7 +279,7 @@ final class ArrayUtils * * @since 1.0.0 */ - public static function arrayToXml(array $data, \SimpleXMLElement $xml = null) : string + public static function arrayToXml(array $data, ?\SimpleXMLElement $xml = null) : string { $xml ??= new \SimpleXMLElement(''); diff --git a/Utils/Barcode/BarAbstract.php b/Utils/Barcode/BarAbstract.php index e828d9cae..19025e28c 100755 --- a/Utils/Barcode/BarAbstract.php +++ b/Utils/Barcode/BarAbstract.php @@ -115,9 +115,9 @@ abstract class BarAbstract extends CodeAbstract $checksum = static::$CHECKSUM; for ($pos = 1; $pos <= $length; ++$pos) { - $activeKey = \substr($this->content, ($pos - 1), 1); + $activeKey = \substr($this->content, ($pos - 1), 1); $this->codestring .= static::$CODEARRAY[$activeKey]; - $checksum += $values[$activeKey] * $pos; + $checksum += $values[$activeKey] * $pos; } $this->codestring .= static::$CODEARRAY[$keys[($checksum - ((int) ($checksum / 103) * 103))]]; diff --git a/Utils/Barcode/C128c.php b/Utils/Barcode/C128c.php index 5236e9938..d4a202990 100755 --- a/Utils/Barcode/C128c.php +++ b/Utils/Barcode/C128c.php @@ -97,7 +97,7 @@ class C128c extends BarAbstract : \substr($this->content, ($pos - 1), 1) . '0'; $codeString .= self::$CODEARRAY[$activeKey]; - $checksum += $values[$activeKey] * $checkPos; + $checksum += $values[$activeKey] * $checkPos; ++$checkPos; } diff --git a/Utils/Barcode/Datamatrix.php b/Utils/Barcode/Datamatrix.php index c9c8c2cbd..8c2115d0b 100755 --- a/Utils/Barcode/Datamatrix.php +++ b/Utils/Barcode/Datamatrix.php @@ -487,7 +487,7 @@ class Datamatrix extends TwoDAbstract if ($this->isCharMode($chr, self::ENC_ASCII_NUM)) { $numch[self::ENC_ASCII] += (1 / 2); } elseif ($this->isCharMode($chr, self::ENC_ASCII_EXT)) { - $numch[self::ENC_ASCII] = \ceil($numch[self::ENC_ASCII]); + $numch[self::ENC_ASCII] = \ceil($numch[self::ENC_ASCII]); $numch[self::ENC_ASCII] += 2; } else { $numch[self::ENC_ASCII] = \ceil($numch[self::ENC_ASCII]); @@ -711,8 +711,8 @@ class Datamatrix extends TwoDAbstract if ($this->isCharMode($chr, self::ENC_ASCII_EXT)) { // 3. If the next data character is extended ASCII (greater than 127) encode it in ASCII mode first using the Upper Shift (value 235) character. - $cw[] = 235; - $cw[] = ($chr - 127); + $cw[] = 235; + $cw[] = ($chr - 127); $cw_num += 2; } else { // 4. Otherwise process the next data character in ASCII encodation. @@ -747,10 +747,10 @@ class Datamatrix extends TwoDAbstract return []; } - $chr &= 0x7f; + $chr &= 0x7f; $temp_cw[] = 1; // shift 2 $temp_cw[] = 30; // upper shift - $p += 2; + $p += 2; } if (isset($charset[$chr])) { @@ -774,19 +774,19 @@ class Datamatrix extends TwoDAbstract } $temp_cw[] = $shiftset[$chr]; - $p += 2; + $p += 2; } if ($p >= 3) { - $c1 = \array_shift($temp_cw); - $c2 = \array_shift($temp_cw); - $c3 = \array_shift($temp_cw); - $p -= 3; - $tmp = ((1600 * $c1) + (40 * $c2) + $c3 + 1); - $cw[] = ($tmp >> 8); - $cw[] = ($tmp % 256); + $c1 = \array_shift($temp_cw); + $c2 = \array_shift($temp_cw); + $c3 = \array_shift($temp_cw); + $p -= 3; + $tmp = ((1600 * $c1) + (40 * $c2) + $c3 + 1); + $cw[] = ($tmp >> 8); + $cw[] = ($tmp % 256); $cw_num += 2; - $pos = $epos; + $pos = $epos; // 1. If the C40 encoding is at the point of starting a new double symbol character and if the look-ahead test (starting at step J) indicates another mode, switch to that mode. $newenc = $this->lookAheadTest($data, $pos, $enc); @@ -802,7 +802,7 @@ class Datamatrix extends TwoDAbstract $cw[] = $this->getSwitchEncodingCodeword($enc); $pos -= $p; - $p = 0; + $p = 0; break; } @@ -828,22 +828,22 @@ class Datamatrix extends TwoDAbstract // c. If two symbol characters remain and only one C40 value (data character) remains to be encoded --$p; - $c1 = \array_shift($temp_cw); - $cw[] = 254; - $cw[] = ($chr + 1); - $cw_num += 2; + $c1 = \array_shift($temp_cw); + $cw[] = 254; + $cw[] = ($chr + 1); + $cw_num += 2; $pos = $epos; $enc = self::ENC_ASCII; $this->encoding = $enc; } elseif (($cwr === 2) && ($p === 2)) { // b. If two symbol characters remain and two C40 values remain to be encoded - $c1 = \array_shift($temp_cw); - $c2 = \array_shift($temp_cw); - $p -= 2; - $tmp = ((1600 * $c1) + (40 * $c2) + 1); - $cw[] = ($tmp >> 8); - $cw[] = ($tmp % 256); - $cw_num += 2; + $c1 = \array_shift($temp_cw); + $c2 = \array_shift($temp_cw); + $p -= 2; + $tmp = ((1600 * $c1) + (40 * $c2) + 1); + $cw[] = ($tmp >> 8); + $cw[] = ($tmp % 256); + $cw_num += 2; $pos = $epos; $enc = self::ENC_ASCII; $this->encoding = $enc; @@ -962,8 +962,8 @@ class Datamatrix extends TwoDAbstract $cw[] = $this->get255StateCodeword($field_length, ($cw_num + 1)); ++$cw_num; } else { - $cw[] = $this->get255StateCodeword((int) (\floor($field_length / 250) + 249), ($cw_num + 1)); - $cw[] = $this->get255StateCodeword(($field_length % 250), ($cw_num + 2)); + $cw[] = $this->get255StateCodeword((int) (\floor($field_length / 250) + 249), ($cw_num + 1)); + $cw[] = $this->get255StateCodeword(($field_length % 250), ($cw_num + 2)); $cw_num += 2; } diff --git a/Utils/Barcode/QR.php b/Utils/Barcode/QR.php index 1d3febd36..8530565f7 100755 --- a/Utils/Barcode/QR.php +++ b/Utils/Barcode/QR.php @@ -613,7 +613,7 @@ class QR extends TwoDAbstract for ($j = 0; $j < 8; ++$j) { $addr = $this->getNextPosition(); $this->frame[$addr['y']][$addr['x']] = 0x02 | (($bit & $code) !== 0); - $bit >>= 1; + $bit >>= 1; } } @@ -685,8 +685,8 @@ class QR extends TwoDAbstract if ($this->dir < 0) { if ($y < 0) { - $y = 0; - $x -= 2; + $y = 0; + $x -= 2; $this->dir = 1; if ($x === 6) { @@ -695,8 +695,8 @@ class QR extends TwoDAbstract } } } elseif ($y === $w) { - $y = $w - 1; - $x -= 2; + $y = $w - 1; + $x -= 2; $this->dir = -1; if ($x === 6) { @@ -746,8 +746,8 @@ class QR extends TwoDAbstract $ecc = $this->encode_rs_char($rs, $this->rsblocks[$blockNo]['data'], $ecc); $this->rsblocks[$blockNo]['ecc'] = $ecc; $this->ecccode = \array_merge(\array_slice($this->ecccode, 0, $eccPos), $ecc); - $dataPos += $dl; - $eccPos += $el; + $dataPos += $dl; + $eccPos += $el; ++$blockNo; } @@ -773,8 +773,8 @@ class QR extends TwoDAbstract $ecc = $this->encode_rs_char($rs, $this->rsblocks[$blockNo]['data'], $ecc); $this->rsblocks[$blockNo]['ecc'] = $ecc; $this->ecccode = \array_merge(\array_slice($this->ecccode, 0, $eccPos), $ecc); - $dataPos += $dl; - $eccPos += $el; + $dataPos += $dl; + $eccPos += $el; ++$blockNo; } @@ -830,7 +830,7 @@ class QR extends TwoDAbstract for ($i = 0; $i < 8; ++$i) { if (($format & 1) !== 0) { $blacks += 2; - $v = 0x85; + $v = 0x85; } else { $v = 0x84; } @@ -848,7 +848,7 @@ class QR extends TwoDAbstract for ($i = 0; $i < 7; ++$i) { if (($format & 1) !== 0) { $blacks += 2; - $v = 0x85; + $v = 0x85; } else { $v = 0x84; } @@ -1099,13 +1099,13 @@ class QR extends TwoDAbstract $bestMask = $frame; foreach ($checked_masks as $i) { - $mask = \array_fill(0, $width, \str_repeat("\0", $width)); - $demerit = 0; - $blacks = 0; - $blacks = $this->makeMaskNo($i, $width, $frame, $mask); - $blacks += $this->writeFormatInformation($width, $mask, $i, $level); - $blacks = (int) (100 * $blacks / ($width * $width)); - $demerit = (int) ((int) (\abs($blacks - 50) / 5) * self::N4); + $mask = \array_fill(0, $width, \str_repeat("\0", $width)); + $demerit = 0; + $blacks = 0; + $blacks = $this->makeMaskNo($i, $width, $frame, $mask); + $blacks += $this->writeFormatInformation($width, $mask, $i, $level); + $blacks = (int) (100 * $blacks / ($width * $width)); + $demerit = (int) ((int) (\abs($blacks - 50) / 5) * self::N4); $demerit += $this->evaluateSymbol($width, $mask); if ($demerit < $minDemerit) { @@ -1473,7 +1473,7 @@ class QR extends TwoDAbstract $ord0 = \ord('0'); for ($i = 0; $i < $words; ++$i) { - $val = (\ord($inputitem['data'][$i * 3 ]) - $ord0) * 100; + $val = (\ord($inputitem['data'][$i * 3 ]) - $ord0) * 100; $val += (\ord($inputitem['data'][$i * 3 + 1]) - $ord0) * 10; $val += (\ord($inputitem['data'][$i * 3 + 2]) - $ord0); @@ -1484,7 +1484,7 @@ class QR extends TwoDAbstract $val = \ord($inputitem['data'][$words * 3]) - $ord0; $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val); } elseif (($inputitem['size'] - ($words * 3)) === 2) { - $val = (\ord($inputitem['data'][$words * 3 ]) - $ord0) * 10; + $val = (\ord($inputitem['data'][$words * 3 ]) - $ord0) * 10; $val += (\ord($inputitem['data'][$words * 3 + 1]) - $ord0); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 7, $val); @@ -1509,7 +1509,7 @@ class QR extends TwoDAbstract $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(self::QR_MODE_AN, $version), $inputitem['size']); for ($i = 0; $i < $words; ++$i) { - $val = $this->lookAnTable(\ord($inputitem['data'][$i * 2])) * 45; + $val = $this->lookAnTable(\ord($inputitem['data'][$i * 2])) * 45; $val += $this->lookAnTable(\ord($inputitem['data'][($i * 2) + 1])); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 11, $val); @@ -1537,7 +1537,7 @@ class QR extends TwoDAbstract $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x4); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(self::QR_MODE_8B, $version), $inputitem['size']); - for ($i=0; $i < $inputitem['size']; ++$i) { + for ($i = 0; $i < $inputitem['size']; ++$i) { $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 8, \ord($inputitem['data'][$i])); } @@ -1900,9 +1900,9 @@ class QR extends TwoDAbstract return 0; } - $l = $this->lengthIndicator($item['mode'], $version); - $m = 1 << $l; - $num = (int) (($item['size'] + $m - 1) / $m); + $l = $this->lengthIndicator($item['mode'], $version); + $m = 1 << $l; + $num = (int) (($item['size'] + $m - 1) / $m); $bits += $num * (4 + $l); } @@ -2006,7 +2006,7 @@ class QR extends TwoDAbstract foreach ($items as $key => $item) { $items[$key] = $this->encodeBitStream($item, $this->version); $bits = \count($items[$key]['bstream']); - $total += $bits; + $total += $bits; } return [$items, $total]; @@ -2073,7 +2073,7 @@ class QR extends TwoDAbstract return $this->appendNum($bstream, $maxbits - $bits, 0); } - $bits += 4; + $bits += 4; $words = (int) (($bits + 7) / 8); $padding = []; $padding = $this->appendNum($padding, $words * 8 - $bits + 4, 0); @@ -2168,7 +2168,7 @@ class QR extends TwoDAbstract for ($i = 0; $i < $bits; ++$i) { $bstream[$i] = (($num & $mask) !== 0) ? 1 : 0; - $mask >>= 1; + $mask >>= 1; } return $bstream; @@ -2279,7 +2279,7 @@ class QR extends TwoDAbstract for ($j = 0; $j < 8; ++$j) { $v <<= 1; - $v |= $bstream[$p]; + $v |= $bstream[$p]; ++$p; } @@ -2291,7 +2291,7 @@ class QR extends TwoDAbstract for ($j = 0; $j < ($size & 7); ++$j) { $v <<= 1; - $v |= $bstream[$p]; + $v |= $bstream[$p]; ++$p; } @@ -2580,7 +2580,7 @@ class QR extends TwoDAbstract for ($x = 0; $x < 6; ++$x) { for ($y = 0; $y < 3; ++$y) { $frame[($width - 11) + $y][$x] = \chr(0x88 | ($v & 1)); - $v >>= 1; + $v >>= 1; } } @@ -2588,7 +2588,7 @@ class QR extends TwoDAbstract for ($y = 0; $y < 6; ++$y) { for ($x = 0; $x < 3; ++$x) { $frame[$y][$x + ($width - 11)] = \chr(0x88 | ($v & 1)); - $v >>= 1; + $v >>= 1; } } } @@ -2659,7 +2659,7 @@ class QR extends TwoDAbstract { while ($x >= $rs['nn']) { $x -= $rs['nn']; - $x = ($x >> $rs['mm']) + ($x & $rs['nn']); + $x = ($x >> $rs['mm']) + ($x & $rs['nn']); } return $x; @@ -2693,8 +2693,8 @@ class QR extends TwoDAbstract $rs['index_of'] = \array_fill(0, ($rs['nn'] + 1), 0); // PHP style macro replacement ;) - $NN =& $rs['nn']; - $A0 =& $NN; + $NN = & $rs['nn']; + $A0 = & $NN; // Generate Galois field lookup tables $rs['index_of'][0] = $A0; // log(zero) = -inf @@ -2704,7 +2704,7 @@ class QR extends TwoDAbstract for ($i = 0; $i < $rs['nn']; ++$i) { $rs['index_of'][$sr] = $i; $rs['alpha_to'][$i] = $sr; - $sr <<= 1; + $sr <<= 1; if (($sr & (1 << $symsize)) !== 0) { $sr ^= $gfpoly; @@ -2767,17 +2767,17 @@ class QR extends TwoDAbstract */ protected function encode_rs_char(array $rs, array $data, array $parity) : array { - $MM =& $rs['mm']; // bits per symbol - $NN =& $rs['nn']; // the total number of symbols in a RS block - $ALPHA_TO =& $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form - $INDEX_OF =& $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form - $GENPOLY =& $rs['genpoly']; // an array of NROOTS+1 elements containing the generator polynomial in index form - $NROOTS =& $rs['nroots']; // the number of roots in the RS code generator polynomial, which is the same as the number of parity symbols in a block - $FCR =& $rs['fcr']; // first consecutive root, index form - $PRIM =& $rs['prim']; // primitive element, index form - $IPRIM =& $rs['iprim']; // prim-th root of 1, index form - $PAD =& $rs['pad']; // the number of pad symbols in a block - $A0 =& $NN; + $MM = & $rs['mm']; // bits per symbol + $NN = & $rs['nn']; // the total number of symbols in a RS block + $ALPHA_TO = & $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form + $INDEX_OF = & $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form + $GENPOLY = & $rs['genpoly']; // an array of NROOTS+1 elements containing the generator polynomial in index form + $NROOTS = & $rs['nroots']; // the number of roots in the RS code generator polynomial, which is the same as the number of parity symbols in a block + $FCR = & $rs['fcr']; // first consecutive root, index form + $PRIM = & $rs['prim']; // primitive element, index form + $IPRIM = & $rs['iprim']; // prim-th root of 1, index form + $PAD = & $rs['pad']; // the number of pad symbols in a block + $A0 = & $NN; $parity = \array_fill(0, $NROOTS, 0); for ($i = 0; $i < $NN - $NROOTS - $PAD; ++$i) { diff --git a/Utils/ColorUtils.php b/Utils/ColorUtils.php index 818486cc9..37855ec11 100755 --- a/Utils/ColorUtils.php +++ b/Utils/ColorUtils.php @@ -65,7 +65,7 @@ final class ColorUtils */ public static function rgbToInt(array $rgb) : int { - $i = (255 & $rgb['r']) << 16; + $i = (255 & $rgb['r']) << 16; $i += (255 & $rgb['g']) << 8; $i += (255 & $rgb['b']); diff --git a/Utils/Compression/LZW.php b/Utils/Compression/LZW.php index 6a40a065c..0c4c80cd0 100755 --- a/Utils/Compression/LZW.php +++ b/Utils/Compression/LZW.php @@ -94,7 +94,7 @@ class LZW implements CompressionInterface throw new \Exception('Wrong dictionary size!' . $k . '.' . $dictSize); // @codeCoverageIgnore } - $result .= $entry; + $result .= $entry; $dictionary[$dictSize++] = $w . $entry[0]; $w = $entry; } diff --git a/Utils/Converter/EnergyPowerType.php b/Utils/Converter/EnergyPowerType.php index 807d16415..037437b1f 100755 --- a/Utils/Converter/EnergyPowerType.php +++ b/Utils/Converter/EnergyPowerType.php @@ -26,19 +26,19 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class EnergyPowerType extends Enum { - public const KILOWATT_HOUERS = 'kWh'; + public const KILOWATT_HOURS = 'kWh'; - public const MEGAWATT_HOUERS = 'MWh'; + public const MEGAWATT_HOURS = 'MWh'; public const KILOTONS = 'kt'; - public const JOULS = 'J'; + public const JOULES = 'J'; public const CALORIES = 'Cal'; public const BTU = 'BTU'; - public const KILOJOULS = 'kJ'; + public const KILOJOULES = 'kJ'; public const THERMEC = 'thmEC'; diff --git a/Utils/Converter/Measurement.php b/Utils/Converter/Measurement.php index ae33a002a..9abaf33cd 100755 --- a/Utils/Converter/Measurement.php +++ b/Utils/Converter/Measurement.php @@ -1425,17 +1425,17 @@ final class Measurement * * @since 1.0.0 */ - public static function convertEnergy(float $value, string $from = EnergyPowerType::JOULS, string $to = EnergyPowerType::KILOWATT_HOUERS) : float + public static function convertEnergy(float $value, string $from = EnergyPowerType::JOULES, string $to = EnergyPowerType::KILOWATT_HOURS) : float { $value = self::normalizeEnergy($value, $from); switch ($to) { - case EnergyPowerType::JOULS: + case EnergyPowerType::JOULES: break; - case EnergyPowerType::KILOWATT_HOUERS: + case EnergyPowerType::KILOWATT_HOURS: $value *= 0.00000027778; break; - case EnergyPowerType::MEGAWATT_HOUERS: + case EnergyPowerType::MEGAWATT_HOURS: $value *= 0.00000000027778; break; case EnergyPowerType::KILOTONS: @@ -1447,7 +1447,7 @@ final class Measurement case EnergyPowerType::BTU: $value *= 0.00094782; break; - case EnergyPowerType::KILOJOULS: + case EnergyPowerType::KILOJOULES: $value *= 0.0010000; break; case EnergyPowerType::THERMEC: @@ -1477,12 +1477,12 @@ final class Measurement private static function normalizeEnergy(float $value, string $from) : float { switch ($from) { - case EnergyPowerType::JOULS: + case EnergyPowerType::JOULES: break; - case EnergyPowerType::KILOWATT_HOUERS: + case EnergyPowerType::KILOWATT_HOURS: $value /= 0.00000027778; break; - case EnergyPowerType::MEGAWATT_HOUERS: + case EnergyPowerType::MEGAWATT_HOURS: $value /= 0.00000000027778; break; case EnergyPowerType::KILOTONS: @@ -1494,7 +1494,7 @@ final class Measurement case EnergyPowerType::BTU: $value /= 0.00094782; break; - case EnergyPowerType::KILOJOULS: + case EnergyPowerType::KILOJOULES: $value /= 0.0010000; break; case EnergyPowerType::THERMEC: diff --git a/Utils/Converter/Numeric.php b/Utils/Converter/Numeric.php index d35a05c50..26206e86f 100755 --- a/Utils/Converter/Numeric.php +++ b/Utils/Converter/Numeric.php @@ -145,7 +145,7 @@ final class Numeric foreach (self::ROMANS as $key => $value) { while (\str_starts_with($roman, $key)) { $result += $value; - $temp = \substr($roman, \strlen($key)); + $temp = \substr($roman, \strlen($key)); if ($temp !== false) { $roman = $temp; @@ -172,7 +172,7 @@ final class Numeric $alpha = ''; for ($i = 1; $number >= 0 && $i < 10; ++$i) { - $alpha = \chr(0x41 + (int) ($number % \pow(26, $i) / \pow(26, $i - 1))) . $alpha; + $alpha = \chr(0x41 + (int) ($number % \pow(26, $i) / \pow(26, $i - 1))) . $alpha; $number -= \pow(26, $i); } diff --git a/Utils/Encoding/Base64Url.php b/Utils/Encoding/Base64Url.php index c7c5d0527..d647a1647 100644 --- a/Utils/Encoding/Base64Url.php +++ b/Utils/Encoding/Base64Url.php @@ -52,9 +52,9 @@ final class Base64Url } /** - * Dedecodes text + * Decodes text * - * @param string $b64 Encoded value to dedecode + * @param string $b64 Encoded value to decode * * @return string * diff --git a/Utils/Encoding/EncodingInterface.php b/Utils/Encoding/EncodingInterface.php index 656a2922d..2b071827f 100755 --- a/Utils/Encoding/EncodingInterface.php +++ b/Utils/Encoding/EncodingInterface.php @@ -36,9 +36,9 @@ interface EncodingInterface public static function encode(mixed $source); /** - * Dedecodes text + * Decodes text * - * @param string $decoded encoded text to dedecode + * @param string $decoded encoded text to decode * * @return string * diff --git a/Utils/Encoding/Gray.php b/Utils/Encoding/Gray.php index 1260650e3..63a47b1fb 100755 --- a/Utils/Encoding/Gray.php +++ b/Utils/Encoding/Gray.php @@ -49,9 +49,9 @@ final class Gray } /** - * Dedecodes text + * Decodes text * - * @param int $gray encoded value to dedecode + * @param int $gray encoded value to decode * * @return int * diff --git a/Utils/Encoding/Huffman/Huffman.php b/Utils/Encoding/Huffman/Huffman.php index cdf29374d..b44befdce 100755 --- a/Utils/Encoding/Huffman/Huffman.php +++ b/Utils/Encoding/Huffman/Huffman.php @@ -118,10 +118,10 @@ final class Huffman } $binary = ''; - $rawLenght = \strlen($raw); + $rawLength = \strlen($raw); $source = ''; - for ($i = 0; $i < $rawLenght; ++$i) { + for ($i = 0; $i < $rawLength; ++$i) { $decbin = \decbin(\ord($raw[$i])); while (\strlen($decbin) < 8) { @@ -141,7 +141,7 @@ final class Huffman } } - if ($i + 1 === $rawLenght) { + if ($i + 1 === $rawLength) { $pos = \strrpos($decbin, '1'); if ($pos === false) { diff --git a/Utils/Encoding/XorEncoding.php b/Utils/Encoding/XorEncoding.php index 1ef125d13..953d38191 100755 --- a/Utils/Encoding/XorEncoding.php +++ b/Utils/Encoding/XorEncoding.php @@ -70,7 +70,7 @@ final class XorEncoding $j = 0; } - $ascii = \ord($source[$i]) ^ \ord($key[$j]); + $ascii = \ord($source[$i]) ^ \ord($key[$j]); $result .= \chr($ascii); } diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 92e584666..30329ed83 100755 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -254,7 +254,7 @@ class Repository * * @since 1.0.0 */ - public function create(string $source = null) : void + public function create(?string $source = null) : void { if (!\is_dir($this->path) || \is_dir($this->path . '/.git')) { throw new \Exception('Already repository'); @@ -690,7 +690,7 @@ class Repository * * @since 1.0.0 */ - public function getContributors(\DateTime $start = null, \DateTime $end = null) : array + public function getContributors(?\DateTime $start = null, ?\DateTime $end = null) : array { if ($start === null) { $start = new \DateTime('1970-12-31'); @@ -730,7 +730,7 @@ class Repository * * @since 1.0.0 */ - public function getCommitsCount(\DateTime $start = null, \DateTime $end = null) : array + public function getCommitsCount(?\DateTime $start = null, ?\DateTime $end = null) : array { if ($start === null) { $start = new \DateTime('1970-12-31'); @@ -766,7 +766,7 @@ class Repository * * @since 1.0.0 */ - public function getAdditionsRemovalsByContributor(Author $author, \DateTime $start = null, \DateTime $end = null) : array + public function getAdditionsRemovalsByContributor(Author $author, ?\DateTime $start = null, ?\DateTime $end = null) : array { if ($start === null) { $start = new \DateTime('1900-01-01'); @@ -817,7 +817,7 @@ class Repository * * @since 1.0.0 */ - public function getCommitsBy(\DateTime $start = null, \DateTime $end = null, Author $author = null) : array + public function getCommitsBy(?\DateTime $start = null, ?\DateTime $end = null, ?Author $author = null) : array { if ($start === null) { $start = new \DateTime('1970-12-31'); diff --git a/Utils/IO/Json/InvalidJsonException.php b/Utils/IO/Json/InvalidJsonException.php index 3a6dc412e..9a0a24bda 100755 --- a/Utils/IO/Json/InvalidJsonException.php +++ b/Utils/IO/Json/InvalidJsonException.php @@ -33,7 +33,7 @@ final class InvalidJsonException extends \UnexpectedValueException * * @since 1.0.0 */ - public function __construct($message, $code = 0, \Exception $previous = null) + public function __construct($message, $code = 0, ?\Exception $previous = null) { parent::__construct('Couldn\'t parse "' . $message . '" as valid json.', $code, $previous); } diff --git a/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapper.php b/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapper.php index efa5467d2..dfdcba4c5 100755 --- a/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapper.php +++ b/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapper.php @@ -123,8 +123,8 @@ final class SpreadsheetDatabaseMapper implements IODatabaseMapper { $sheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); $sheet->getProperties() - ->setCreator('Karaka') - ->setLastModifiedBy('Karaka') + ->setCreator('Jingga') + ->setLastModifiedBy('Jingga') ->setTitle('Database export') ->setSubject('Database export') ->setDescription('This document is automatically generated from a database export.'); diff --git a/Utils/MbStringUtils.php b/Utils/MbStringUtils.php index 6748f4e43..94139b509 100755 --- a/Utils/MbStringUtils.php +++ b/Utils/MbStringUtils.php @@ -242,7 +242,7 @@ final class MbStringUtils $countChars = self::mb_count_chars($value); foreach ($countChars as $v) { - $p = $v / $size; + $p = $v / $size; $entropy -= $p * \log($p) / \log(2); } diff --git a/Utils/NumericUtils.php b/Utils/NumericUtils.php index fc41d4f0e..27adc32f7 100755 --- a/Utils/NumericUtils.php +++ b/Utils/NumericUtils.php @@ -47,7 +47,7 @@ final class NumericUtils public static function uRightShift(int $a, int $b) : int { if ($b >= 32 || $b < -32) { - $m = (int) ($b / 32); + $m = (int) ($b / 32); $b -= $m * 32; } @@ -61,8 +61,8 @@ final class NumericUtils if ($a < 0) { $a >>= 1; - $a &= 0x7fffffff; - $a |= 0x40000000; + $a &= 0x7fffffff; + $a |= 0x40000000; $a >>= $b - 1; } else { $a >>= $b; diff --git a/Utils/Parser/Markdown/Markdown.php b/Utils/Parser/Markdown/Markdown.php index 8aac82a46..e520abfee 100755 --- a/Utils/Parser/Markdown/Markdown.php +++ b/Utils/Parser/Markdown/Markdown.php @@ -464,7 +464,7 @@ class Markdown // Marks if ($this->options['mark'] ?? true) { $this->inlineTypes['='][] = 'Mark'; - $this->inlineMarkerList .= '='; + $this->inlineMarkerList .= '='; } // Keystrokes @@ -475,20 +475,20 @@ class Markdown // Spoiler if ($this->options['spoiler'] ?? false) { $this->inlineTypes['>'][] = 'Spoiler'; - $this->inlineMarkerList .= '>'; + $this->inlineMarkerList .= '>'; } // Inline Math if ($this->options['math'] ?? false) { $this->inlineTypes['\\'][] = 'Math'; $this->inlineTypes['$'][] = 'Math'; - $this->inlineMarkerList .= '$'; + $this->inlineMarkerList .= '$'; } // Superscript if ($this->options['sup'] ?? false) { $this->inlineTypes['^'][] = 'Superscript'; - $this->inlineMarkerList .= '^'; + $this->inlineMarkerList .= '^'; } // Subscript @@ -504,14 +504,14 @@ class Markdown // Typographer if ($this->options['typographer'] ?? false) { $this->inlineTypes['('][] = 'Typographer'; - $this->inlineMarkerList .= '('; + $this->inlineMarkerList .= '('; $this->inlineTypes['.'][] = 'Typographer'; - $this->inlineMarkerList .= '.'; + $this->inlineMarkerList .= '.'; $this->inlineTypes['+'][] = 'Typographer'; - $this->inlineMarkerList .= '+'; + $this->inlineMarkerList .= '+'; $this->inlineTypes['!'][] = 'Typographer'; $this->inlineTypes['?'][] = 'Typographer'; - $this->inlineMarkerList .= '?'; + $this->inlineMarkerList .= '?'; } // Block Math @@ -598,7 +598,7 @@ class Markdown // Add footnotes if (isset($this->definitionData['Footnote'])) { $element = $this->buildFootnoteElement(); - $html .= "\n" . $this->element($element); + $html .= "\n" . $this->element($element); } return $this->decodeToCTagFromHash($html); // Unescape the ToC tag @@ -1808,7 +1808,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockFootnote(array $line, array $_ = null) : ?array + protected function blockFootnote(array $line, ?array $_ = null) : ?array { return ($this->options['footnotes'] ?? true) && \preg_match('/^\[\^(.+?)\]:[ ]?(.*)$/', $line['text'], $matches) == 1 @@ -1830,7 +1830,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockDefinitionList(array $line, array $block = null) : ?array + protected function blockDefinitionList(array $line, ?array $block = null) : ?array { if (!($this->options['definition_lists'] ?? true) || $block === null @@ -1872,7 +1872,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockCode(array $line, array $block = null) : ?array + protected function blockCode(array $line, ?array $block = null) : ?array { if (!($this->options['code']['blocks'] ?? true) || !($this->options['code'] ?? true) @@ -1905,7 +1905,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockComment(array $line, array $_ = null) : ?array + protected function blockComment(array $line, ?array $_ = null) : ?array { if (!($this->options['comments'] ?? true) || $this->markupEscaped || $this->safeMode @@ -1938,7 +1938,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockHeader(array $line, array $_ = null) : ?array + protected function blockHeader(array $line, ?array $_ = null) : ?array { if (!($this->options['headings'] ?? true)) { return null; @@ -2019,7 +2019,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockList(array $line, array $block = null) : ?array + protected function blockList(array $line, ?array $block = null) : ?array { if (!($this->options['lists'] ?? true)) { return null; @@ -2098,7 +2098,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockQuote(array $line, array $_ = null) : ?array + protected function blockQuote(array $line, ?array $_ = null) : ?array { if (!($this->options['qoutes'] ?? true) || \preg_match('/^>[ ]?+(.*+)/', $line['text'], $matches) !== 1 @@ -2128,7 +2128,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockRule(array $line, array $_ = null) : ?array + protected function blockRule(array $line, ?array $_ = null) : ?array { if (!($this->options['thematic_breaks'] ?? true)) { return null; @@ -2156,7 +2156,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockSetextHeader(array $line, array $block = null) : ?array + protected function blockSetextHeader(array $line, ?array $block = null) : ?array { if (!($this->options['headings'] ?? true) || $block === null @@ -2223,7 +2223,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockMarkup(array $line, array $_ = null) : ?array + protected function blockMarkup(array $line, ?array $_ = null) : ?array { if (!($this->options['markup'] ?? true) || $this->markupEscaped || $this->safeMode @@ -2278,7 +2278,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockReference(array $line, array $_ = null) : ?array + protected function blockReference(array $line, ?array $_ = null) : ?array { if (!($this->options['references'] ?? true) || \strpos($line['text'], ']') === false @@ -2310,7 +2310,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockTable(array $line, array $block = null) : ?array + protected function blockTable(array $line, ?array $block = null) : ?array { if (!($this->options['tables'] ?? true) || $block === null || $block['type'] !== 'Paragraph' || isset($block['interrupted']) @@ -2422,7 +2422,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockAbbreviation(array $line, array $_ = null) : ?array + protected function blockAbbreviation(array $line, ?array $_ = null) : ?array { if (!($this->options['abbreviations'] ?? true)) { return null; @@ -2459,7 +2459,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockMath(array $line, array $_ = null) : ?array + protected function blockMath(array $line, ?array $_ = null) : ?array { $block = [ 'element' => [ @@ -2549,7 +2549,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockFencedCode(array $line, array $_ = null) : ?array + protected function blockFencedCode(array $line, ?array $_ = null) : ?array { if (!($this->options['code']['blocks'] ?? true) || !($this->options['code'] ?? true) @@ -2659,7 +2659,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockSpoiler(array $line, array $_ = null) : ?array + protected function blockSpoiler(array $line, ?array $_ = null) : ?array { if (!($this->options['code']['blocks'] ?? true) || !($this->options['code'] ?? true) @@ -2836,7 +2836,7 @@ class Markdown * * @since 1.0.0 */ - protected function blockCheckbox(array $line, array $_ = null) : ?array + protected function blockCheckbox(array $line, ?array $_ = null) : ?array { $text = \trim($line['text']); $beginLine = \substr($text, 0, 4); @@ -3384,7 +3384,7 @@ class Markdown } if (isset($block['interrupted'])) { - $block['dd']['handler']['function'] = 'textElements'; + $block['dd']['handler']['function'] = 'textElements'; $block['dd']['handler']['argument'] .= "\n\n"; $block['dd']['handler']['destination'] = 'elements'; @@ -3743,7 +3743,7 @@ class Markdown $elementText = "\n" . $this->text($elementText) . "\n"; } else { foreach ($dom->documentElement->childNodes as $node) { - $nodeMarkup = $dom->saveHTML($node); + $nodeMarkup = $dom->saveHTML($node); $elementText .= $node instanceof \DOMElement && !\in_array($node->nodeName, $this->textLevelElements) ? $this->processTag($nodeMarkup) : $nodeMarkup; @@ -4618,7 +4618,7 @@ class Markdown // (autobreak === false) covers both sides of an element $autoBreak = $autoBreak ? $autoBreakNext : $autoBreak; - $markup .= ($autoBreak ? "\n" : '') . $this->element($element); + $markup .= ($autoBreak ? "\n" : '') . $this->element($element); $autoBreak = $autoBreakNext; } diff --git a/Utils/Permutation.php b/Utils/Permutation.php index 6f4bc3532..d2f62106e 100755 --- a/Utils/Permutation.php +++ b/Utils/Permutation.php @@ -37,14 +37,14 @@ final class Permutation /** * Create all permutations. * - * @param array $toPermute data to permutate + * @param array $toPermute data to permute * @param array $result existing permutations * * @return array * * @since 1.0.0 */ - public static function permut(array $toPermute, array $result = [], bool $concat = true) : array + public static function permuteAll(array $toPermute, array $result = [], bool $concat = true) : array { $permutations = []; @@ -58,7 +58,7 @@ final class Permutation unset($newArr[$key]); - $permutations = \array_merge($permutations, self::permut($newArr, $newres, $concat)); + $permutations = \array_merge($permutations, self::permuteAll($newArr, $newres, $concat)); } } @@ -98,9 +98,9 @@ final class Permutation } /** - * Permutate based on transposition key. + * Permute based on transposition key. * - * @param array|string $toPermute To permutate + * @param array|string $toPermute To permute * @param int[] $key Permutation keys * * @return string|array @@ -109,7 +109,7 @@ final class Permutation * * @since 1.0.0 */ - public static function permutate(string | array $toPermute, array $key) : string | array + public static function permuteByKey(string | array $toPermute, array $key) : string | array { $length = \is_array($toPermute) ? \count($toPermute) : \strlen($toPermute); diff --git a/Utils/RnG/File.php b/Utils/RnG/File.php index 9262a991f..79fd29055 100755 --- a/Utils/RnG/File.php +++ b/Utils/RnG/File.php @@ -63,7 +63,7 @@ final class File * * @since 1.0.0 */ - public static function generateExtension(array $source = null) : string + public static function generateExtension(?array $source = null) : string { if ($source === null) { $source = self::$extensions; diff --git a/Utils/RnG/Name.php b/Utils/RnG/Name.php index fddd55d8f..dff549c46 100755 --- a/Utils/RnG/Name.php +++ b/Utils/RnG/Name.php @@ -216,7 +216,7 @@ final class Name 'Zula', 'Catrina', 'Hazeline', 'Lillian', 'Reanne', 'Zuri', 'Catriona', 'Heather', 'Lillie', 'Rebecca', 'Zyana', 'Cayla', 'Heaven', ], - 'male' => [ + 'male' => [ 'Aaron', 'Clay', 'Gino', 'Laurie', 'Richard', 'Abdul', 'Clayton', 'Giorgio', 'Lawrence', 'Richie', 'Abdullah', 'Clement', 'Giovanni', 'Lawson', 'Rick', 'Abe', 'Cliff', 'Glen', 'Layne', 'Rickey', 'Abel', 'Clifford', 'Glenn', 'Layton', 'Rickie', 'Abraham', 'Clifton', 'Glyndwr', 'Leaf', 'Ricky', 'Abram', diff --git a/Utils/RnG/Number.php b/Utils/RnG/Number.php new file mode 100644 index 000000000..60012d14c --- /dev/null +++ b/Utils/RnG/Number.php @@ -0,0 +1,51 @@ +start = $start ?? new \DateTime('now'); @@ -225,7 +225,7 @@ class Interval implements SerializableInterface * * @since 1.0.0 */ - public function setMinute(int $index, int $start = null, int $end = null, int $step = null) : void + public function setMinute(int $index, ?int $start = null, ?int $end = null, ?int $step = null) : void { $this->minute[$index] = [ 'start' => $start, @@ -245,7 +245,7 @@ class Interval implements SerializableInterface * * @since 1.0.0 */ - public function addMinute(int $start = null, int $end = null, int $step = null) : void + public function addMinute(?int $start = null, ?int $end = null, ?int $step = null) : void { $this->minute[] = [ 'start' => $start, @@ -278,7 +278,7 @@ class Interval implements SerializableInterface * * @since 1.0.0 */ - public function setHour(int $index, int $start = null, int $end = null, int $step = null) : void + public function setHour(int $index, ?int $start = null, ?int $end = null, ?int $step = null) : void { $this->hour[$index] = [ 'start' => $start, @@ -298,7 +298,7 @@ class Interval implements SerializableInterface * * @since 1.0.0 */ - public function addHour(int $start = null, int $end = null, int $step = null) : void + public function addHour(?int $start = null, ?int $end = null, ?int $step = null) : void { $this->hour[] = [ 'start' => $start, @@ -331,7 +331,7 @@ class Interval implements SerializableInterface * * @since 1.0.0 */ - public function setDayOfMonth(int $index, int $start = null, int $end = null, int $step = null) : void + public function setDayOfMonth(int $index, ?int $start = null, ?int $end = null, ?int $step = null) : void { $this->dayOfMonth[$index] = [ 'start' => $start, @@ -351,7 +351,7 @@ class Interval implements SerializableInterface * * @since 1.0.0 */ - public function addDayOfMonth(int $start = null, int $end = null, int $step = null) : void + public function addDayOfMonth(?int $start = null, ?int $end = null, ?int $step = null) : void { $this->dayOfMonth[] = [ 'start' => $start, @@ -384,7 +384,7 @@ class Interval implements SerializableInterface * * @since 1.0.0 */ - public function setDayOfWeek(int $index, int $start = null, int $end = null, int $step = null) : void + public function setDayOfWeek(int $index, ?int $start = null, ?int $end = null, ?int $step = null) : void { $this->dayOfWeek[$index] = [ 'start' => $start, @@ -404,7 +404,7 @@ class Interval implements SerializableInterface * * @since 1.0.0 */ - public function addDayOfWeek(int $start = null, int $end = null, int $step = null) : void + public function addDayOfWeek(?int $start = null, ?int $end = null, ?int $step = null) : void { $this->dayOfWeek[] = [ 'start' => $start, @@ -437,7 +437,7 @@ class Interval implements SerializableInterface * * @since 1.0.0 */ - public function setMonth(int $index, int $start = null, int $end = null, int $step = null) : void + public function setMonth(int $index, ?int $start = null, ?int $end = null, ?int $step = null) : void { $this->month[$index] = [ 'start' => $start, @@ -457,7 +457,7 @@ class Interval implements SerializableInterface * * @since 1.0.0 */ - public function addMonth(int $start = null, int $end = null, int $step = null) : void + public function addMonth(?int $start = null, ?int $end = null, ?int $step = null) : void { $this->month[] = [ 'start' => $start, @@ -490,7 +490,7 @@ class Interval implements SerializableInterface * * @since 1.0.0 */ - public function setYear(int $index, int $start = null, int $end = null, int $step = null) : void + public function setYear(int $index, ?int $start = null, ?int $end = null, ?int $step = null) : void { $this->year[$index] = [ 'start' => $start, @@ -510,7 +510,7 @@ class Interval implements SerializableInterface * * @since 1.0.0 */ - public function addYear(int $start = null, int $end = null, int $step = null) : void + public function addYear(?int $start = null, ?int $end = null, ?int $step = null) : void { $this->year[] = [ 'start' => $start, diff --git a/Utils/TaskSchedule/TaskAbstract.php b/Utils/TaskSchedule/TaskAbstract.php index e1dc82ff2..586720f0b 100755 --- a/Utils/TaskSchedule/TaskAbstract.php +++ b/Utils/TaskSchedule/TaskAbstract.php @@ -54,7 +54,7 @@ abstract class TaskAbstract * @var int * @since 1.0.0 */ - protected int $status = TaskStatus::ACTIVE; + public int $status = TaskStatus::ACTIVE; /** * Next runtime @@ -170,32 +170,6 @@ abstract class TaskAbstract $this->interval = $interval; } - /** - * Get status. - * - * @return int - * - * @since 1.0.0 - */ - public function getStatus() : int - { - return $this->status; - } - - /** - * Set status. - * - * @param int $status Status - * - * @return void - * - * @since 1.0.0 - */ - public function setStatus(int $status) : void - { - $this->status = $status; - } - /** * Get next run time. * diff --git a/Validation/Base/DateTime.php b/Validation/Base/DateTime.php index b0f656058..38ddbcfc9 100755 --- a/Validation/Base/DateTime.php +++ b/Validation/Base/DateTime.php @@ -29,7 +29,7 @@ abstract class DateTime extends ValidatorAbstract /** * {@inheritdoc} */ - public static function isValid(mixed $value, array $constraints = null) : bool + public static function isValid(mixed $value, ?array $constraints = null) : bool { if (!\is_string($value)) { return false; diff --git a/Validation/Base/Json.php b/Validation/Base/Json.php index c0f4d375a..78e285cec 100755 --- a/Validation/Base/Json.php +++ b/Validation/Base/Json.php @@ -30,7 +30,7 @@ abstract class Json extends ValidatorAbstract /** * {@inheritdoc} */ - public static function isValid(mixed $value, array $constraints = null) : bool + public static function isValid(mixed $value, ?array $constraints = null) : bool { if (!\is_string($value)) { return false; diff --git a/Validation/Finance/BIC.php b/Validation/Finance/BIC.php index 986ad0645..d63dc9004 100755 --- a/Validation/Finance/BIC.php +++ b/Validation/Finance/BIC.php @@ -29,7 +29,7 @@ final class BIC extends ValidatorAbstract /** * {@inheritdoc} */ - public static function isValid(mixed $value, array $constraints = null) : bool + public static function isValid(mixed $value, ?array $constraints = null) : bool { if (!\is_string($value)) { return false; diff --git a/Validation/Finance/CreditCard.php b/Validation/Finance/CreditCard.php index 19c5ee050..05a292010 100755 --- a/Validation/Finance/CreditCard.php +++ b/Validation/Finance/CreditCard.php @@ -29,7 +29,7 @@ final class CreditCard extends ValidatorAbstract /** * {@inheritdoc} */ - public static function isValid($value, array $constraints = null) : bool + public static function isValid($value, ?array $constraints = null) : bool { if (!\is_string($value)) { return false; diff --git a/Validation/Finance/EUVat.php b/Validation/Finance/EUVat.php index 1d86aa38b..92e1776e3 100644 --- a/Validation/Finance/EUVat.php +++ b/Validation/Finance/EUVat.php @@ -63,7 +63,7 @@ final class EUVat extends ValidatorAbstract /** * {@inheritdoc} */ - public static function isValid(mixed $value, array $constraints = null) : bool + public static function isValid(mixed $value, ?array $constraints = null) : bool { if (!\is_string($value)) { return false; diff --git a/Validation/Finance/Iban.php b/Validation/Finance/Iban.php index c905bbebf..3369770fe 100755 --- a/Validation/Finance/Iban.php +++ b/Validation/Finance/Iban.php @@ -29,7 +29,7 @@ final class Iban extends ValidatorAbstract /** * {@inheritdoc} */ - public static function isValid(mixed $value, array $constraints = null) : bool + public static function isValid(mixed $value, ?array $constraints = null) : bool { if (!\is_string($value)) { return false; @@ -148,14 +148,16 @@ final class Iban extends ValidatorAbstract */ private static function validateChecksum(string $iban) : bool { - $chars = ['a' => 10, 'b' => 11, 'c' => 12, 'd' => 13, 'e' => 14, 'f' => 15, 'g' => 16, 'h' => 17, 'i' => 18, - 'j' => 19, 'k' => 20, 'l' => 21, 'm' => 22, 'n' => 23, 'o' => 24, 'p' => 25, 'q' => 26, 'r' => 27, - 's' => 28, 't' => 29, 'u' => 30, 'v' => 31, 'w' => 32, 'x' => 33, 'y' => 34, 'z' => 35,]; + $chars = [ + 'a' => 10, 'b' => 11, 'c' => 12, 'd' => 13, 'e' => 14, 'f' => 15, 'g' => 16, 'h' => 17, 'i' => 18, + 'j' => 19, 'k' => 20, 'l' => 21, 'm' => 22, 'n' => 23, 'o' => 24, 'p' => 25, 'q' => 26, 'r' => 27, + 's' => 28, 't' => 29, 'u' => 30, 'v' => 31, 'w' => 32, 'x' => 33, 'y' => 34, 'z' => 35, + ]; $moved = \substr($iban, 4) . \substr($iban, 0, 4); $movedArray = (array) \str_split($moved); $new = ''; - foreach ($movedArray as $key => $value) { + foreach ($movedArray as $key => $_) { if (!\is_numeric($movedArray[$key])) { $movedArray[$key] = $chars[$movedArray[$key]]; } diff --git a/Validation/Network/Email.php b/Validation/Network/Email.php index edb68fb2f..81a6dc209 100755 --- a/Validation/Network/Email.php +++ b/Validation/Network/Email.php @@ -39,7 +39,7 @@ abstract class Email extends ValidatorAbstract /** * {@inheritdoc} */ - public static function isValid(mixed $value, array $constraints = null) : bool + public static function isValid(mixed $value, ?array $constraints = null) : bool { if (\filter_var($value, \FILTER_VALIDATE_EMAIL) === false) { self::$msg = 'Invalid Email by filter_var standards'; diff --git a/Validation/Network/Hostname.php b/Validation/Network/Hostname.php index 215c7bdc7..7b6aa25a5 100755 --- a/Validation/Network/Hostname.php +++ b/Validation/Network/Hostname.php @@ -39,9 +39,9 @@ abstract class Hostname extends ValidatorAbstract /** * {@inheritdoc} * - * A IPv6 string MUST be in [...] to be sucessfully validated + * A IPv6 string MUST be in [...] to be successfully validated */ - public static function isValid(mixed $value, array $constraints = null) : bool + public static function isValid(mixed $value, ?array $constraints = null) : bool { //return \filter_var(\gethostbyname($value), \FILTER_VALIDATE_IP) !== false; diff --git a/Validation/Network/Ip.php b/Validation/Network/Ip.php index b8a358f53..dafffce06 100755 --- a/Validation/Network/Ip.php +++ b/Validation/Network/Ip.php @@ -39,7 +39,7 @@ abstract class Ip extends ValidatorAbstract /** * {@inheritdoc} */ - public static function isValid(mixed $value, array $constraints = null) : bool + public static function isValid(mixed $value, ?array $constraints = null) : bool { return \filter_var($value, \FILTER_VALIDATE_IP) !== false; } diff --git a/Validation/Validator.php b/Validation/Validator.php index bbc88455a..80d879cf7 100755 --- a/Validation/Validator.php +++ b/Validation/Validator.php @@ -38,7 +38,7 @@ final class Validator extends ValidatorAbstract * * @since 1.0.0 */ - public static function isValid(mixed $var, array $constraints = null) : bool + public static function isValid(mixed $var, ?array $constraints = null) : bool { if ($constraints === null) { return true; diff --git a/Validation/ValidatorInterface.php b/Validation/ValidatorInterface.php index 955cfa258..48b419fab 100755 --- a/Validation/ValidatorInterface.php +++ b/Validation/ValidatorInterface.php @@ -34,7 +34,7 @@ interface ValidatorInterface * * @since 1.0.0 */ - public static function isValid(mixed $value, array $constraints = null) : bool; + public static function isValid(mixed $value, ?array $constraints = null) : bool; /** * Get most recent error string. diff --git a/Views/View.php b/Views/View.php index f9b743c0a..9905006ef 100755 --- a/Views/View.php +++ b/Views/View.php @@ -98,7 +98,7 @@ class View extends ViewAbstract * * @since 1.0.0 */ - public function __construct(L11nManager $l11n = null, RequestAbstract $request = null, ResponseAbstract $response = null) + public function __construct(?L11nManager $l11n = null, ?RequestAbstract $request = null, ?ResponseAbstract $response = null) { $this->l11nManager = $l11n ?? new L11nManager(); $this->request = $request; @@ -201,7 +201,7 @@ class View extends ViewAbstract * * @since 1.0.0 */ - public function getText(string $translation, string $module = null, string $theme = null) : string + public function getText(string $translation, ?string $module = null, ?string $theme = null) : string { if ($module === null && $this->module === null) { $this->setModuleDynamically(); @@ -302,7 +302,7 @@ class View extends ViewAbstract * * @since 1.0.0 */ - public function getHtml(string $translation, string $module = null, string $theme = null) : string + public function getHtml(string $translation, ?string $module = null, ?string $theme = null) : string { return \htmlspecialchars($this->getText($translation, $module, $theme)); } @@ -317,7 +317,7 @@ class View extends ViewAbstract * * @since 1.0.0 */ - public function getNumeric(int | float | FloatInt $numeric, string $format = null) : string + public function getNumeric(int | float | FloatInt $numeric, ?string $format = null) : string { return $this->l11nManager->getNumeric($this->l11n, $numeric, $format); } @@ -332,7 +332,7 @@ class View extends ViewAbstract * * @since 1.0.0 */ - public function getPercentage(float $percentage, string $format = null) : string + public function getPercentage(float $percentage, ?string $format = null) : string { return $this->l11nManager->getPercentage($this->l11n, $percentage, $format); } @@ -351,8 +351,8 @@ class View extends ViewAbstract */ public function getCurrency( int | float | Money | FloatInt $currency, - string $symbol = null, - string $format = null, + ?string $symbol = null, + ?string $format = null, int $divide = 1 ) : string { @@ -369,7 +369,7 @@ class View extends ViewAbstract * * @since 1.0.0 */ - public function getDateTime(\DateTimeInterface $datetime = null, string $format = null) : string + public function getDateTime(?\DateTimeInterface $datetime = null, ?string $format = null) : string { return $this->l11nManager->getDateTime($this->l11n, $datetime, $format); } diff --git a/tests/Account/AccountManagerTest.php b/tests/Account/AccountManagerTest.php index bc1e19090..63c6ea074 100755 --- a/tests/Account/AccountManagerTest.php +++ b/tests/Account/AccountManagerTest.php @@ -73,7 +73,7 @@ final class AccountManagerTest extends \PHPUnit\Framework\TestCase public function testRetrieveAccount() : void { $this->manager->add($this->account); - self::assertEquals($this->account, $this->manager->get($this->account->getId())); + self::assertEquals($this->account, $this->manager->get($this->account->id)); } /** @@ -87,7 +87,7 @@ final class AccountManagerTest extends \PHPUnit\Framework\TestCase $added = $this->manager->add($this->account); self::assertFalse($added); - self::assertTrue($this->manager->remove($this->account->getId())); + self::assertTrue($this->manager->remove($this->account->id)); self::assertFalse($this->manager->remove(-1)); self::assertEquals(0, $this->manager->count()); } @@ -100,7 +100,7 @@ final class AccountManagerTest extends \PHPUnit\Framework\TestCase public function testRemoveAccount() : void { $this->manager->add($this->account); - self::assertTrue($this->manager->remove($this->account->getId())); + self::assertTrue($this->manager->remove($this->account->id)); self::assertEquals(0, $this->manager->count()); self::assertFalse($this->manager->remove(-1)); } @@ -115,7 +115,7 @@ final class AccountManagerTest extends \PHPUnit\Framework\TestCase $this->manager->add($this->account); self::assertFalse($this->manager->remove(-1)); self::assertEquals(1, $this->manager->count()); - self::assertTrue($this->manager->remove($this->account->getId())); + self::assertTrue($this->manager->remove($this->account->id)); self::assertEquals(0, $this->manager->count()); } } diff --git a/tests/Account/AccountTest.php b/tests/Account/AccountTest.php index 130d2c571..99891fb9e 100755 --- a/tests/Account/AccountTest.php +++ b/tests/Account/AccountTest.php @@ -53,8 +53,8 @@ final class AccountTest extends \PHPUnit\Framework\TestCase $account = new Account(); /* Testing default values */ - self::assertIsInt($account->getId()); - self::assertEquals(0, $account->getId()); + self::assertIsInt($account->id); + self::assertEquals(0, $account->id); self::assertInstanceOf('\phpOMS\Localization\Localization', $account->l11n); @@ -74,11 +74,11 @@ final class AccountTest extends \PHPUnit\Framework\TestCase self::assertIsString($account->getEmail()); self::assertEquals('', $account->getEmail()); - self::assertIsInt($account->getStatus()); - self::assertEquals(AccountStatus::INACTIVE, $account->getStatus()); + self::assertIsInt($account->status); + self::assertEquals(AccountStatus::INACTIVE, $account->status); - self::assertIsInt($account->getType()); - self::assertEquals(AccountType::USER, $account->getType()); + self::assertIsInt($account->type); + self::assertEquals(AccountType::USER, $account->type); self::assertEquals([], $account->getPermissions()); self::assertFalse($account->hasGroup(2)); @@ -145,34 +145,6 @@ final class AccountTest extends \PHPUnit\Framework\TestCase self::assertEquals('d.duck@duckburg.com', $account->getEmail()); } - /** - * @testdox The default status of the account can be changed to a different valid status - * @covers phpOMS\Account\Account - * @group framework - */ - public function testChangeStatus() : void - { - $account = new Account(); - $account->generatePassword('abcd'); - - $account->setStatus(AccountStatus::ACTIVE); - self::assertEquals(AccountStatus::ACTIVE, $account->getStatus()); - } - - /** - * @testdox The default type of the account can be changed to a different valid type - * @covers phpOMS\Account\Account - * @group framework - */ - public function testChangeType() : void - { - $account = new Account(); - $account->generatePassword('abcd'); - - $account->setType(AccountType::GROUP); - self::assertEquals(AccountType::GROUP, $account->getType()); - } - /** * @testdox Account permissions can be added * @covers phpOMS\Account\Account @@ -293,40 +265,4 @@ final class AccountTest extends \PHPUnit\Framework\TestCase $account = new Account(); $account->setEmail('d.duck!@#%@duckburg'); } - - /** - * @testdox An account can only have valid account status - * @group framework - */ - public function testStatusException() : void - { - $this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class); - - $account = new Account(); - - $rand = 0; - do { - $rand = \mt_rand(\PHP_INT_MIN, \PHP_INT_MAX); - } while (AccountStatus::isValidValue($rand)); - - $account->setStatus($rand); - } - - /** - * @testdox An account can only have valid account types - * @group framework - */ - public function testTypeException() : void - { - $this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class); - - $account = new Account(); - - $rand = 0; - do { - $rand = \mt_rand(\PHP_INT_MIN, \PHP_INT_MAX); - } while (AccountType::isValidValue($rand)); - - $account->setType($rand); - } } diff --git a/tests/Account/GroupTest.php b/tests/Account/GroupTest.php index f55bbd427..a6d4c36c7 100755 --- a/tests/Account/GroupTest.php +++ b/tests/Account/GroupTest.php @@ -38,14 +38,14 @@ final class GroupTest extends \PHPUnit\Framework\TestCase $group = new Group(); /* Testing default values */ - self::assertIsInt($group->getId()); - self::assertEquals(0, $group->getId()); + self::assertIsInt($group->id); + self::assertEquals(0, $group->id); self::assertIsString($group->name); self::assertEquals('', $group->name); - self::assertIsInt($group->getStatus()); - self::assertEquals(GroupStatus::INACTIVE, $group->getStatus()); + self::assertIsInt($group->status); + self::assertEquals(GroupStatus::INACTIVE, $group->status); self::assertIsString($group->description); self::assertEquals('', $group->description); @@ -138,36 +138,4 @@ final class GroupTest extends \PHPUnit\Framework\TestCase $group->removePermission($perm); self::assertCount(0, $group->getPermissions()); } - - /** - * @testdox The default status of the group can be changed to a different valid status - * @covers phpOMS\Account\Group - * @group framework - */ - public function testChangeStatus() : void - { - $group = new Group(); - - $group->setStatus(GroupStatus::ACTIVE); - self::assertEquals(GroupStatus::ACTIVE, $group->getStatus()); - } - - /** - * @testdox A group can only have valid group status - * @covers phpOMS\Account\Group - * @group framework - */ - public function testStatusException() : void - { - $this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class); - - $group = new Group(); - - $rand = 0; - do { - $rand = \mt_rand(\PHP_INT_MIN, \PHP_INT_MAX); - } while (GroupStatus::isValidValue($rand)); - - $group->setStatus($rand); - } } diff --git a/tests/Account/NullAccountTest.php b/tests/Account/NullAccountTest.php index f3c5e5470..e08f6c07e 100755 --- a/tests/Account/NullAccountTest.php +++ b/tests/Account/NullAccountTest.php @@ -42,7 +42,7 @@ final class NullAccountTest extends \PHPUnit\Framework\TestCase public function testId() : void { $null = new NullAccount(2); - self::assertEquals(2, $null->getId()); + self::assertEquals(2, $null->id); } public function testJsonSerialization() : void diff --git a/tests/Account/NullGroupTest.php b/tests/Account/NullGroupTest.php index 39694ba93..03e4738e3 100755 --- a/tests/Account/NullGroupTest.php +++ b/tests/Account/NullGroupTest.php @@ -42,7 +42,7 @@ final class NullGroupTest extends \PHPUnit\Framework\TestCase public function testId() : void { $null = new NullGroup(2); - self::assertEquals(2, $null->getId()); + self::assertEquals(2, $null->id); } public function testJsonSerialization() : void diff --git a/tests/Algorithm/JobScheduling/WeightedTest.php b/tests/Algorithm/JobScheduling/WeightedTest.php index fa7bd0412..69ce8908f 100755 --- a/tests/Algorithm/JobScheduling/WeightedTest.php +++ b/tests/Algorithm/JobScheduling/WeightedTest.php @@ -46,7 +46,7 @@ final class WeightedTest extends \PHPUnit\Framework\TestCase $names = []; foreach ($filtered as $job) { - $value += $job->getValue(); + $value += $job->getValue(); $names[] = $job->name; } diff --git a/tests/Application/ApplicationInfoTest.php b/tests/Application/ApplicationInfoTest.php index 427fe5a3e..6af83db67 100755 --- a/tests/Application/ApplicationInfoTest.php +++ b/tests/Application/ApplicationInfoTest.php @@ -111,7 +111,7 @@ final class ApplicationInfoTest extends \PHPUnit\Framework\TestCase $info = new ApplicationInfo(__DIR__ . '/info-test.json'); $info->load(); - $testObj = new class() { + $testObj = new class() { public $test = 1; public function test() : void diff --git a/tests/Application/ApplicationManagerTest.php b/tests/Application/ApplicationManagerTest.php index 6c594c4e1..aac7e3318 100755 --- a/tests/Application/ApplicationManagerTest.php +++ b/tests/Application/ApplicationManagerTest.php @@ -49,7 +49,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase */ protected function setUp() : void { - $app = new class() extends ApplicationAbstract { + $app = new class() extends ApplicationAbstract { protected string $appName = 'Api'; }; @@ -62,12 +62,12 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase public function get( mixed $ids = null, - string | array $names = null, - int $unit = null, - int $app = null, - string $module = null, - int $group = null, - int $account = null + string | array|null $names = null, + ?int $unit = null, + ?int $app = null, + ?string $module = null, + ?int $group = null, + ?int $account = null ) : mixed { return ''; } @@ -172,7 +172,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase } /** - * @testdox A invalid application path results in no uninstallation + * @testdox A invalid application path results in no uninstall * @covers phpOMS\Application\ApplicationManager * @group framework */ @@ -183,7 +183,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase } /** - * @testdox A missing uninstallation file results in no uninstallation + * @testdox A missing uninstall file results in no uninstall * @covers phpOMS\Application\ApplicationManager * @group framework */ diff --git a/tests/Application/InstallerAbstractTest.php b/tests/Application/InstallerAbstractTest.php index d06211f77..0cdba868d 100755 --- a/tests/Application/InstallerAbstractTest.php +++ b/tests/Application/InstallerAbstractTest.php @@ -32,7 +32,7 @@ final class InstallerAbstractTest extends \PHPUnit\Framework\TestCase */ protected function setUp() : void { - $this->installer = new class() extends InstallerAbstract { + $this->installer = new class() extends InstallerAbstract { public const PATH = __DIR__ . '/Invalid'; }; } diff --git a/tests/Application/Testapp/Admin/Install/Application/Routes.php b/tests/Application/Testapp/Admin/Install/Application/Routes.php index 8bfccbeab..8ca42bfe7 100755 --- a/tests/Application/Testapp/Admin/Install/Application/Routes.php +++ b/tests/Application/Testapp/Admin/Install/Application/Routes.php @@ -15,13 +15,13 @@ declare(strict_types=1); use phpOMS\Router\RouteVerb; return [ - '^.*/testapp.*$' => [ + '^.*/testapp(\?.*$|$)' => [ [ 'dest' => '\phpOMS\tess\Application\Apps\Testapp\Controller\Controller:testEndpoint', 'verb' => RouteVerb::GET, 'permission' => [ - 'type' => 1, - 'state' => 2, + 'type' => 1, + 'state' => 2, ], ], ], diff --git a/tests/Autoloader.php b/tests/Autoloader.php index 6e249662d..95dd1b74c 100755 --- a/tests/Autoloader.php +++ b/tests/Autoloader.php @@ -75,8 +75,8 @@ class Autoloader */ public static function defaultAutoloader(string $class) : void { - $class = \ltrim($class, '\\'); - $class = \strtr($class, '_\\', '//'); + $class = \ltrim($class, '\\'); + $class = \strtr($class, '_\\', '//'); if (\stripos($class, 'Web/Backend') !== false || \stripos($class, 'Web/Api') !== false) { $class = \is_dir(__DIR__ . '/Web') ? $class : \str_replace('Web/', 'MainRepository/Web/', $class); diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index 1b48ed57b..44c8a78a9 100755 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -1,4 +1,15 @@ [ + 'db' => [ 'core' => [ 'masters' => [ - 'admin' => [ + 'admin' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -80,7 +91,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'insert' => [ + 'insert' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -90,7 +101,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'select' => [ + 'select' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -100,7 +111,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'update' => [ + 'update' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -110,7 +121,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'delete' => [ + 'delete' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -120,7 +131,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'schema' => [ + 'schema' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -132,7 +143,7 @@ $CONFIG = [ ], ], 'postgresql' => [ - 'admin' => [ + 'admin' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -142,7 +153,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'insert' => [ + 'insert' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -152,7 +163,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'select' => [ + 'select' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -162,7 +173,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'update' => [ + 'update' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -172,7 +183,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'delete' => [ + 'delete' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -182,7 +193,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'schema' => [ + 'schema' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -194,37 +205,37 @@ $CONFIG = [ ], ], 'sqlite' => [ - 'admin' => [ + 'admin' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'insert' => [ + 'insert' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'select' => [ + 'select' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'update' => [ + 'update' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'delete' => [ + 'delete' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'schema' => [ + 'schema' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ @@ -232,7 +243,7 @@ $CONFIG = [ ], ], 'mssql' => [ - 'admin' => [ + 'admin' => [ 'db' => 'mssql', /* db type */ 'host' => 'localhost', /* db host address */ 'port' => '1433', /* db host port */ @@ -242,7 +253,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'insert' => [ + 'insert' => [ 'db' => 'mssql', /* db type */ 'host' => 'localhost', /* db host address */ 'port' => '1433', /* db host port */ @@ -252,7 +263,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'select' => [ + 'select' => [ 'db' => 'mssql', /* db type */ 'host' => 'localhost', /* db host address */ 'port' => '1433', /* db host port */ @@ -262,7 +273,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'update' => [ + 'update' => [ 'db' => 'mssql', /* db type */ 'host' => 'localhost', /* db host address */ 'port' => '1433', /* db host port */ @@ -272,7 +283,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'delete' => [ + 'delete' => [ 'db' => 'mssql', /* db type */ 'host' => 'localhost', /* db host address */ 'port' => '1433', /* db host port */ @@ -282,7 +293,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'schema' => [ + 'schema' => [ 'db' => 'mssql', /* db type */ 'host' => 'localhost', /* db host address */ 'port' => '1433', /* db host port */ @@ -322,16 +333,16 @@ $CONFIG = [ 'password' => '123456', ], ], - 'log' => [ + 'log' => [ 'file' => [ 'path' => __DIR__ . '/Logs', ], ], - 'page' => [ + 'page' => [ 'root' => '/', 'https' => false, ], - 'app' => [ + 'app' => [ 'path' => __DIR__, 'default' => [ 'app' => 'Backend', @@ -350,7 +361,7 @@ $CONFIG = [ ], ], ], - 'socket' => [ + 'socket' => [ 'master' => [ 'host' => '127.0.0.1', 'limit' => 300, @@ -360,7 +371,7 @@ $CONFIG = [ 'language' => [ 'en', ], - 'apis' => [ + 'apis' => [ ], ]; diff --git a/tests/Business/Finance/FinanceFormulasTest.php b/tests/Business/Finance/FinanceFormulasTest.php index 54d2b1b59..dcf12e886 100755 --- a/tests/Business/Finance/FinanceFormulasTest.php +++ b/tests/Business/Finance/FinanceFormulasTest.php @@ -121,13 +121,13 @@ final class FinanceFormulasTest extends \PHPUnit\Framework\TestCase * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ - public function testAnnutiyPaymentFactorPV() : void + public function testAnnuityPaymentFactorPV() : void { $expected = 0.21216; $r = 0.02; $n = 5; - $p = FinanceFormulas::getAnnutiyPaymentFactorPV($r, $n); + $p = FinanceFormulas::getAnnuityPaymentFactorPV($r, $n); self::assertEqualsWithDelta(\round($expected, 5), \round($p, 5), 0.01); self::assertEqualsWithDelta($n, FinanceFormulas::getNumberOfAPFPV($p, $r), 0.01); @@ -314,8 +314,8 @@ final class FinanceFormulasTest extends \PHPUnit\Framework\TestCase $C = \round(FinanceFormulas::getCompoundInterest($P, $r, $t), 2); self::assertEqualsWithDelta(\round($expected, 2), $C, 0.01); - self::assertEqualsWithDelta($P, FinanceFormulas::getPrincipalOfCompundInterest($C, $r, $t), 0.1); - self::assertEqualsWithDelta($t, (int) \round(FinanceFormulas::getPeriodsOfCompundInterest($P, $C, $r), 0), 0.01); + self::assertEqualsWithDelta($P, FinanceFormulas::getPrincipalOfCompoundInterest($C, $r, $t), 0.1); + self::assertEqualsWithDelta($t, (int) \round(FinanceFormulas::getPeriodsOfCompoundInterest($P, $C, $r), 0), 0.01); } /** diff --git a/tests/DataStorage/Cache/Connection/FileCacheTest.php b/tests/DataStorage/Cache/Connection/FileCacheTest.php index 9eb29ed49..b2cf55ac3 100755 --- a/tests/DataStorage/Cache/Connection/FileCacheTest.php +++ b/tests/DataStorage/Cache/Connection/FileCacheTest.php @@ -66,9 +66,9 @@ final class FileCacheTest extends \PHPUnit\Framework\TestCase self::assertNull($this->cache->get('test')); self::assertEquals( [ - 'status' => CacheStatus::OK, - 'count' => 0, - 'size' => 0, + 'status' => CacheStatus::OK, + 'count' => 0, + 'size' => 0, ], $this->cache->stats() ); @@ -237,7 +237,7 @@ final class FileCacheTest extends \PHPUnit\Framework\TestCase self::assertEquals([], $this->cache->getLike('key\d')); } - public function testExpiredDelteLike() : void + public function testExpiredDeleteLike() : void { $this->cache->set('key1', 'testVal1', 2); $this->cache->set('key2', 'testVal2', 2); @@ -339,9 +339,9 @@ final class FileCacheTest extends \PHPUnit\Framework\TestCase self::assertEquals( [ - 'status' => CacheStatus::OK, - 'count' => 2, - 'size' => 17, + 'status' => CacheStatus::OK, + 'count' => 2, + 'size' => 17, ], $this->cache->stats() ); @@ -365,9 +365,9 @@ final class FileCacheTest extends \PHPUnit\Framework\TestCase self::assertEquals( [ - 'status' => CacheStatus::OK, - 'count' => 0, - 'size' => 0, + 'status' => CacheStatus::OK, + 'count' => 0, + 'size' => 0, ], $this->cache->stats() ); diff --git a/tests/DataStorage/Cache/Connection/MemCachedTest.php b/tests/DataStorage/Cache/Connection/MemCachedTest.php index fe8614030..db3ff6c14 100755 --- a/tests/DataStorage/Cache/Connection/MemCachedTest.php +++ b/tests/DataStorage/Cache/Connection/MemCachedTest.php @@ -63,9 +63,9 @@ final class MemCachedTest extends \PHPUnit\Framework\TestCase self::assertEquals(11211, $this->cache->getPort()); self::assertEquals( [ - 'status' => CacheStatus::OK, - 'count' => 0, - 'size' => 0, + 'status' => CacheStatus::OK, + 'count' => 0, + 'size' => 0, ], $this->cache->stats() ); @@ -321,7 +321,7 @@ final class MemCachedTest extends \PHPUnit\Framework\TestCase self::assertTrue($this->cache->flushAll()); self::assertNull($this->cache->get('key5')); - // Carefull memcached is dumb and keeps expired elements which were not acessed after flushing in stat + // Careful memcached is dumb and keeps expired elements which were not acessed after flushing in stat self::assertGreaterThanOrEqual(0, $this->cache->stats()['count']); self::assertGreaterThanOrEqual(0, $this->cache->stats()['size']); } diff --git a/tests/DataStorage/Database/DataMapperAbstractTest.php b/tests/DataStorage/Database/DataMapperAbstractTest.php index daed7cbbc..ceb2b0873 100755 --- a/tests/DataStorage/Database/DataMapperAbstractTest.php +++ b/tests/DataStorage/Database/DataMapperAbstractTest.php @@ -197,7 +197,7 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase public function testCreate() : void { self::assertGreaterThan(0, BaseModelMapper::create()->execute($this->model)); - self::assertGreaterThan(0, $this->model->getId()); + self::assertGreaterThan(0, $this->model->id); } public function testCreateNullModel() : void @@ -212,9 +212,9 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase public function testCreateAlreadyCreatedModel() : void { self::assertGreaterThan(0, $id = BaseModelMapper::create()->execute($this->model)); - self::assertGreaterThan(0, $this->model->getId()); + self::assertGreaterThan(0, $this->model->id); self::assertEquals($id, BaseModelMapper::create()->execute($this->model)); - self::assertEquals($id, $this->model->getId()); + self::assertEquals($id, $this->model->id); } public function testCreateHasManyRelation() : void @@ -256,7 +256,7 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase ->where('id', $id) ->execute(); - self::assertEquals($this->model->getId(), $modelR->getId()); + self::assertEquals($this->model->id, $modelR->id); self::assertEquals($this->model->string, $modelR->string); self::assertEquals($this->model->compress, $modelR->compress); self::assertEquals($this->model->getPString(), $modelR->getPString()); @@ -334,7 +334,7 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase $id2 = BaseModelMapper::create()->execute($model2); $by = BaseModelMapper::get()->where('string', '456')->execute(); - self::assertEquals($model2->getId(), $by->getId()); + self::assertEquals($model2->id, $by->id); } public function testGetNewest() : void @@ -349,7 +349,7 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase $id2 = BaseModelMapper::create()->execute($model2); $newest = BaseModelMapper::getAll()->sort('id', OrderType::DESC)->limit(1)->execute(); - self::assertEquals($id2, \reset($newest)->getId()); + self::assertEquals($id2, \reset($newest)->id); } public function testGetNullModel() : void diff --git a/tests/DataStorage/Database/Query/BuilderTest.php b/tests/DataStorage/Database/Query/BuilderTest.php index bca777833..0defa7035 100755 --- a/tests/DataStorage/Database/Query/BuilderTest.php +++ b/tests/DataStorage/Database/Query/BuilderTest.php @@ -85,7 +85,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase $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 = \strtr($sql, '[]', $iS . $iE); + $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); diff --git a/tests/DataStorage/Database/Schema/Grammar/MysqlGrammarTest.php b/tests/DataStorage/Database/Schema/Grammar/MysqlGrammarTest.php index dc43f93ef..bc1315f34 100755 --- a/tests/DataStorage/Database/Schema/Grammar/MysqlGrammarTest.php +++ b/tests/DataStorage/Database/Schema/Grammar/MysqlGrammarTest.php @@ -78,7 +78,7 @@ final class MysqlGrammarTest extends \PHPUnit\Framework\TestCase ); } - $delete = new Builder($this->con); + $delete = new Builder($this->con); $delete->dropTable('test') ->dropTable('test_foreign') ->execute(); @@ -101,7 +101,7 @@ final class MysqlGrammarTest extends \PHPUnit\Framework\TestCase self::assertContains('test', $tables); self::assertContains('test_foreign', $tables); - $delete = new Builder($this->con); + $delete = new Builder($this->con); $delete->dropTable('test') ->dropTable('test_foreign') ->execute(); diff --git a/tests/DataStorage/Database/TestModel/BaseModel.php b/tests/DataStorage/Database/TestModel/BaseModel.php index 5c5453b99..7c6a6c117 100755 --- a/tests/DataStorage/Database/TestModel/BaseModel.php +++ b/tests/DataStorage/Database/TestModel/BaseModel.php @@ -90,7 +90,7 @@ class BaseModel $this->belongsToOne = new BelongsToModel(); $this->serializable = new class() implements SerializableInterface { - public $value = ''; + public $value = ''; public function serialize() : string { diff --git a/tests/DataStorage/Database/TestModel/BaseModelMapper.php b/tests/DataStorage/Database/TestModel/BaseModelMapper.php index 6a7030a4d..6809192b3 100755 --- a/tests/DataStorage/Database/TestModel/BaseModelMapper.php +++ b/tests/DataStorage/Database/TestModel/BaseModelMapper.php @@ -25,23 +25,23 @@ class BaseModelMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'test_base_id' => ['name' => 'test_base_id', 'type' => 'int', 'internal' => 'id'], - 'test_base_string' => ['name' => 'test_base_string', 'type' => 'string', 'internal' => 'string', 'autocomplete' => true], - 'test_base_compress' => ['name' => 'test_base_compress', 'type' => 'compress', 'internal' => 'compress',], - 'test_base_pstring' => ['name' => 'test_base_pstring', 'type' => 'pstring', 'internal' => 'pstring', 'private' => true], - 'test_base_int' => ['name' => 'test_base_int', 'type' => 'int', 'internal' => 'int'], - 'test_base_bool' => ['name' => 'test_base_bool', 'type' => 'bool', 'internal' => 'bool'], - 'test_base_null' => ['name' => 'test_base_null', 'type' => 'int', 'internal' => 'null'], - 'test_base_float' => ['name' => 'test_base_float', 'type' => 'float', 'internal' => 'float'], - 'test_base_json' => ['name' => 'test_base_json', 'type' => 'Json', 'internal' => 'json'], - 'test_base_json_serializable' => ['name' => 'test_base_json_serializable', 'type' => 'Json', 'internal' => 'jsonSerializable'], - 'test_base_serializable' => ['name' => 'test_base_serializable', 'type' => 'Serializable', 'internal' => 'serializable'], - 'test_base_datetime' => ['name' => 'test_base_datetime', 'type' => 'DateTime', 'internal' => 'datetime'], - 'test_base_datetime_null' => ['name' => 'test_base_datetime_null', 'type' => 'DateTime', 'internal' => 'datetime_null'], - 'test_base_owns_one_self' => ['name' => 'test_base_owns_one_self', 'type' => 'int', 'internal' => 'ownsOneSelf'], - 'test_base_belongs_to_one' => ['name' => 'test_base_belongs_to_one', 'type' => 'int', 'internal' => 'belongsToOne'], - 'test_base_owns_onep_self' => ['name' => 'test_base_owns_onep_self', 'type' => 'int', 'internal' => 'ownsOneSelfPrivate', 'private' => true], - 'test_base_belongs_top_one' => ['name' => 'test_base_belongs_top_one', 'type' => 'int', 'internal' => 'belongsToOnePrivate', 'private' => true], + 'test_base_id' => ['name' => 'test_base_id', 'type' => 'int', 'internal' => 'id'], + 'test_base_string' => ['name' => 'test_base_string', 'type' => 'string', 'internal' => 'string', 'autocomplete' => true], + 'test_base_compress' => ['name' => 'test_base_compress', 'type' => 'compress', 'internal' => 'compress',], + 'test_base_pstring' => ['name' => 'test_base_pstring', 'type' => 'pstring', 'internal' => 'pstring', 'private' => true], + 'test_base_int' => ['name' => 'test_base_int', 'type' => 'int', 'internal' => 'int'], + 'test_base_bool' => ['name' => 'test_base_bool', 'type' => 'bool', 'internal' => 'bool'], + 'test_base_null' => ['name' => 'test_base_null', 'type' => 'int', 'internal' => 'null'], + 'test_base_float' => ['name' => 'test_base_float', 'type' => 'float', 'internal' => 'float'], + 'test_base_json' => ['name' => 'test_base_json', 'type' => 'Json', 'internal' => 'json'], + 'test_base_json_serializable' => ['name' => 'test_base_json_serializable', 'type' => 'Json', 'internal' => 'jsonSerializable'], + 'test_base_serializable' => ['name' => 'test_base_serializable', 'type' => 'Serializable', 'internal' => 'serializable'], + 'test_base_datetime' => ['name' => 'test_base_datetime', 'type' => 'DateTime', 'internal' => 'datetime'], + 'test_base_datetime_null' => ['name' => 'test_base_datetime_null', 'type' => 'DateTime', 'internal' => 'datetime_null'], + 'test_base_owns_one_self' => ['name' => 'test_base_owns_one_self', 'type' => 'int', 'internal' => 'ownsOneSelf'], + 'test_base_belongs_to_one' => ['name' => 'test_base_belongs_to_one', 'type' => 'int', 'internal' => 'belongsToOne'], + 'test_base_owns_onep_self' => ['name' => 'test_base_owns_onep_self', 'type' => 'int', 'internal' => 'ownsOneSelfPrivate', 'private' => true], + 'test_base_belongs_top_one' => ['name' => 'test_base_belongs_top_one', 'type' => 'int', 'internal' => 'belongsToOnePrivate', 'private' => true], ]; /** diff --git a/tests/Dispatcher/DispatcherTest.php b/tests/Dispatcher/DispatcherTest.php index 9d9937d12..2af67ec07 100755 --- a/tests/Dispatcher/DispatcherTest.php +++ b/tests/Dispatcher/DispatcherTest.php @@ -39,7 +39,7 @@ final class DispatcherTest extends \PHPUnit\Framework\TestCase */ protected function setUp() : void { - $this->app = new class() extends ApplicationAbstract { + $this->app = new class() extends ApplicationAbstract { protected string $appName = 'Api'; }; diff --git a/tests/Localization/Defaults/CityMapperTest.php b/tests/Localization/Defaults/CityMapperTest.php index 647170efb..cf9cb420d 100755 --- a/tests/Localization/Defaults/CityMapperTest.php +++ b/tests/Localization/Defaults/CityMapperTest.php @@ -33,8 +33,8 @@ final class CityMapperTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() : void { self::$con = new SqliteConnection([ - 'db' => 'sqlite', - 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), + 'db' => 'sqlite', + 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), ]); self::$con->connect(); diff --git a/tests/Localization/Defaults/CountryMapperTest.php b/tests/Localization/Defaults/CountryMapperTest.php index 403bfdc65..9ea15f43f 100755 --- a/tests/Localization/Defaults/CountryMapperTest.php +++ b/tests/Localization/Defaults/CountryMapperTest.php @@ -33,8 +33,8 @@ final class CountryMapperTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() : void { self::$con = new SqliteConnection([ - 'db' => 'sqlite', - 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), + 'db' => 'sqlite', + 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), ]); self::$con->connect(); diff --git a/tests/Localization/Defaults/CountryTest.php b/tests/Localization/Defaults/CountryTest.php index 2d678bfb9..ee5c76381 100755 --- a/tests/Localization/Defaults/CountryTest.php +++ b/tests/Localization/Defaults/CountryTest.php @@ -33,7 +33,7 @@ final class CountryTest extends \PHPUnit\Framework\TestCase public function testDefaults() : void { $obj = new Country(); - self::assertEquals(0, $obj->getId()); + self::assertEquals(0, $obj->id); self::assertEquals('', $obj->getName()); self::assertEquals('', $obj->getCode2()); self::assertEquals('', $obj->getCode3()); diff --git a/tests/Localization/Defaults/CurrencyMapperTest.php b/tests/Localization/Defaults/CurrencyMapperTest.php index ce42e7c81..6c576276c 100755 --- a/tests/Localization/Defaults/CurrencyMapperTest.php +++ b/tests/Localization/Defaults/CurrencyMapperTest.php @@ -33,8 +33,8 @@ final class CurrencyMapperTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() : void { self::$con = new SqliteConnection([ - 'db' => 'sqlite', - 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), + 'db' => 'sqlite', + 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), ]); self::$con->connect(); diff --git a/tests/Localization/Defaults/IbanMapperTest.php b/tests/Localization/Defaults/IbanMapperTest.php index 477dcb63d..f4dcecd3b 100755 --- a/tests/Localization/Defaults/IbanMapperTest.php +++ b/tests/Localization/Defaults/IbanMapperTest.php @@ -33,8 +33,8 @@ final class IbanMapperTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() : void { self::$con = new SqliteConnection([ - 'db' => 'sqlite', - 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), + 'db' => 'sqlite', + 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), ]); self::$con->connect(); @@ -51,7 +51,7 @@ final class IbanMapperTest extends \PHPUnit\Framework\TestCase { /** @var Iban $obj */ $obj = IbanMapper::get()->where('id', 22)->execute(); - self::assertEquals('DE', $obj->getCountry()); + self::assertEquals('DE', $obj->country); self::assertEquals(22, $obj->getChars()); self::assertEquals('18n', $obj->getBban()); self::assertEquals('DEkk bbbb bbbb cccc cccc cc', $obj->getFields()); diff --git a/tests/Localization/Defaults/IbanTest.php b/tests/Localization/Defaults/IbanTest.php index 041247d79..bbf92365f 100755 --- a/tests/Localization/Defaults/IbanTest.php +++ b/tests/Localization/Defaults/IbanTest.php @@ -33,7 +33,7 @@ final class IbanTest extends \PHPUnit\Framework\TestCase public function testDefaults() : void { $obj = new Iban(); - self::assertEquals('', $obj->getCountry()); + self::assertEquals('', $obj->country); self::assertEquals(2, $obj->getChars()); self::assertEquals('', $obj->getBban()); self::assertEquals('', $obj->getFields()); diff --git a/tests/Localization/Defaults/LanguageMapperTest.php b/tests/Localization/Defaults/LanguageMapperTest.php index 0b9758858..fd96411f2 100755 --- a/tests/Localization/Defaults/LanguageMapperTest.php +++ b/tests/Localization/Defaults/LanguageMapperTest.php @@ -33,8 +33,8 @@ final class LanguageMapperTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() : void { self::$con = new SqliteConnection([ - 'db' => 'sqlite', - 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), + 'db' => 'sqlite', + 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), ]); self::$con->connect(); diff --git a/tests/Localization/Defaults/LanguageTest.php b/tests/Localization/Defaults/LanguageTest.php index 000d36ac4..bfafe2464 100755 --- a/tests/Localization/Defaults/LanguageTest.php +++ b/tests/Localization/Defaults/LanguageTest.php @@ -33,7 +33,7 @@ final class LanguageTest extends \PHPUnit\Framework\TestCase public function testDefaults() : void { $obj = new Language(); - self::assertEquals(0, $obj->getId()); + self::assertEquals(0, $obj->id); self::assertEquals('', $obj->getName()); self::assertEquals('', $obj->getNative()); self::assertEquals('', $obj->getCode2()); diff --git a/tests/Localization/LocalizationTest.php b/tests/Localization/LocalizationTest.php index 980f0e9a5..1e670bec7 100755 --- a/tests/Localization/LocalizationTest.php +++ b/tests/Localization/LocalizationTest.php @@ -48,11 +48,11 @@ final class LocalizationTest extends \PHPUnit\Framework\TestCase */ public function testDefault() : void { - self::assertEquals(0, $this->localization->getId()); + self::assertEquals(0, $this->localization->id); self::assertTrue(ISO3166TwoEnum::isValidValue($this->localization->country)); self::assertTrue(TimeZoneEnumArray::isValidValue($this->localization->getTimezone())); self::assertTrue(ISO639x1Enum::isValidValue($this->localization->language)); - self::assertTrue(ISO4217CharEnum::isValidValue($this->localization->getCurrency())); + self::assertTrue(ISO4217CharEnum::isValidValue($this->localization->currency)); self::assertEquals('0', $this->localization->getCurrencyFormat()); self::assertEquals('.', $this->localization->getDecimal()); self::assertEquals(',', $this->localization->getThousands()); @@ -66,18 +66,6 @@ final class LocalizationTest extends \PHPUnit\Framework\TestCase self::assertEquals([], $this->localization->getVolume()); } - /** - * @testdox Setting a invalid language code throws InvalidEnumValue - * @covers phpOMS\Localization\Localization - * @group framework - */ - public function testInvalidLanguage() : void - { - $this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class); - - $this->localization->setLanguage('abc'); - } - /** * @testdox Setting a invalid country code throws InvalidEnumValue * @covers phpOMS\Localization\Localization @@ -102,18 +90,6 @@ final class LocalizationTest extends \PHPUnit\Framework\TestCase $this->localization->setTimezone('abc'); } - /** - * @testdox Setting a invalid currency code throws InvalidEnumValue - * @covers phpOMS\Localization\Localization - * @group framework - */ - public function testInvalidCurrency() : void - { - $this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class); - - $this->localization->setCurrency('abc'); - } - /** * @testdox Setting a invalid angle throws InvalidEnumValue * @covers phpOMS\Localization\Localization @@ -160,28 +136,6 @@ final class LocalizationTest extends \PHPUnit\Framework\TestCase self::assertEquals(TimeZoneEnumArray::get(315), $this->localization->getTimezone()); } - /** - * @testdox The language can be set and returned - * @covers phpOMS\Localization\Localization - * @group framework - */ - public function testLanguageInputOutput() : void - { - $this->localization->setLanguage(ISO639x1Enum::_DE); - self::assertEquals(ISO639x1Enum::_DE, $this->localization->language); - } - - /** - * @testdox The currency can be set and returned - * @covers phpOMS\Localization\Localization - * @group framework - */ - public function testCurrencyInputOutput() : void - { - $this->localization->setCurrency(ISO4217CharEnum::_EUR); - self::assertEquals(ISO4217CharEnum::_EUR, $this->localization->getCurrency()); - } - /** * @testdox The datetime can be set and returned * @covers phpOMS\Localization\Localization @@ -322,7 +276,7 @@ final class LocalizationTest extends \PHPUnit\Framework\TestCase public function testLocalizationFromLanguageCode() : void { $l11n = Localization::fromLanguage(ISO639x1Enum::_DE); - self::assertEquals(ISO4217CharEnum::_EUR, $l11n->getCurrency()); + self::assertEquals(ISO4217CharEnum::_EUR, $l11n->currency); } /** @@ -333,7 +287,7 @@ final class LocalizationTest extends \PHPUnit\Framework\TestCase public function testLocalizationLoading() : void { $this->localization->loadFromLanguage(ISO639x1Enum::_DE); - self::assertEquals(ISO4217CharEnum::_EUR, $this->localization->getCurrency()); + self::assertEquals(ISO4217CharEnum::_EUR, $this->localization->currency); } /** @@ -360,7 +314,7 @@ final class LocalizationTest extends \PHPUnit\Framework\TestCase public function testInvalidCountryLocalizationLoading() : void { $this->localization->loadFromLanguage(ISO639x1Enum::_DE, 'ABC'); - self::assertEquals(ISO4217CharEnum::_EUR, $this->localization->getCurrency()); + self::assertEquals(ISO4217CharEnum::_EUR, $this->localization->currency); } /** @@ -371,6 +325,6 @@ final class LocalizationTest extends \PHPUnit\Framework\TestCase public function testMissingLocalizationLoading() : void { $this->localization->loadFromLanguage(ISO639x1Enum::_AA); - self::assertEquals(ISO4217CharEnum::_USD, $this->localization->getCurrency()); + self::assertEquals(ISO4217CharEnum::_USD, $this->localization->currency); } } diff --git a/tests/Message/HeaderAbstractTest.php b/tests/Message/HeaderAbstractTest.php index f2f3c9ea3..c303e4100 100755 --- a/tests/Message/HeaderAbstractTest.php +++ b/tests/Message/HeaderAbstractTest.php @@ -48,7 +48,7 @@ final class HeaderAbstractTest extends \PHPUnit\Framework\TestCase return true; } - public function get(string $key = null) : array + public function get(?string $key = null) : array { return []; } diff --git a/tests/Message/Http/HttpRequestTest.php b/tests/Message/Http/HttpRequestTest.php index f62d2f485..b90fb5d4b 100755 --- a/tests/Message/Http/HttpRequestTest.php +++ b/tests/Message/Http/HttpRequestTest.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace phpOMS\tests\Message\Http; -use phpOMS\Localization\ISO639x1Enum; use phpOMS\Localization\Localization; use phpOMS\Message\Http\BrowserType; use phpOMS\Message\Http\HttpRequest; @@ -150,21 +149,6 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase self::assertEquals('http://www.google.com/test/path', $request->__toString()); } - /** - * @testdox The request langauge can be returned - * @covers phpOMS\Message\Http\HttpRequest - * @group framework - */ - public function testLangaugeOutput() : void - { - $request = new HttpRequest(new HttpUri('http://www.google.com/test/path'), $l11n = new Localization()); - - $request->header->l11n = new Localization(); - $request->header->l11n->setLanguage(ISO639x1Enum::_DE); - - self::assertEquals(ISO639x1Enum::_DE, $request->header->l11n->language); - } - /** * @testdox The url hashes for the different paths get correctly generated * @covers phpOMS\Message\Http\HttpRequest @@ -231,7 +215,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase */ public function testDataJsonRead() : void { - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $data = [ 1, 2, 3, @@ -250,7 +234,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase */ public function testEmptyDataJsonRead() : void { - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); self::assertEquals([], $request->getDataJson('def')); } @@ -262,7 +246,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase */ public function testInvalidDataJsonRead() : void { - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $data = [ "0" => 1, "1" => 2, "2" => 3, @@ -281,7 +265,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase */ public function testDataList() : void { - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $data = [ 1, 2, 3, @@ -299,7 +283,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase */ public function testEmptyDataList() : void { - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); self::assertEquals([], $request->getDataList('def')); } @@ -311,7 +295,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase */ public function testDataLike() : void { - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $data = 'this is a test'; @@ -327,7 +311,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase */ public function testInvalidDataLikeMatch() : void { - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $data = 'this is a test'; diff --git a/tests/Message/Http/HttpResponseTest.php b/tests/Message/Http/HttpResponseTest.php index 571c327ad..0352ccf50 100755 --- a/tests/Message/Http/HttpResponseTest.php +++ b/tests/Message/Http/HttpResponseTest.php @@ -14,8 +14,6 @@ declare(strict_types=1); namespace phpOMS\tests\Message\Http; -use phpOMS\Localization\ISO639x1Enum; -use phpOMS\Localization\Localization; use phpOMS\Message\Http\HttpResponse; use phpOMS\System\MimeType; @@ -105,19 +103,6 @@ final class HttpResponseTest extends \PHPUnit\Framework\TestCase self::assertEquals($start, \ob_get_level()); } - /** - * @testdox The response langauge can be returned - * @covers phpOMS\Message\Http\HttpResponse - * @group framework - */ - public function testLangaugeOutput() : void - { - $this->response->header->l11n = new Localization(); - $this->response->header->l11n->setLanguage(ISO639x1Enum::_DE); - - self::assertEquals(ISO639x1Enum::_DE, $this->response->header->l11n->language); - } - /** * @testdox Response data can be turned into an array * @covers phpOMS\Message\Http\HttpResponse diff --git a/tests/Message/Mail/MailHandlerMailTrait.php b/tests/Message/Mail/MailHandlerMailTrait.php index 81b554660..d49c729c3 100755 --- a/tests/Message/Mail/MailHandlerMailTrait.php +++ b/tests/Message/Mail/MailHandlerMailTrait.php @@ -308,10 +308,10 @@ trait MailHandlerMailTrait $mail->confirmationAddress = 'test1@jingga.app'; $mail->setFrom('test1@jingga.app', 'Dennis Eichhorn'); $mail->addTo('test@jingga.app', 'Dennis Eichhorn'); - $mail->subject = 'testSendICalAltWithMail'; - $mail->body = 'Ical test'; - $mail->bodyAlt = 'Ical test'; - $mail->ical = 'BEGIN:VCALENDAR' + $mail->subject = 'testSendICalAltWithMail'; + $mail->body = 'Ical test'; + $mail->bodyAlt = 'Ical test'; + $mail->ical = 'BEGIN:VCALENDAR' . "\r\nVERSION:2.0" . "\r\nPRODID:-//phpOMS//Karaka Calendar//EN" . $methodLine @@ -366,10 +366,10 @@ trait MailHandlerMailTrait $mail->setFrom('test1@jingga.app', 'Dennis Eichhorn'); $mail->addTo('test@jingga.app', 'Dennis Eichhorn'); $mail->addAttachment(__DIR__ . '/files/logo.png', 'logo'); - $mail->subject = 'testSendICalAltAttachmentWithMail'; - $mail->body = 'Ical test'; - $mail->bodyAlt = 'Ical test'; - $mail->ical = 'BEGIN:VCALENDAR' + $mail->subject = 'testSendICalAltAttachmentWithMail'; + $mail->body = 'Ical test'; + $mail->bodyAlt = 'Ical test'; + $mail->ical = 'BEGIN:VCALENDAR' . "\r\nVERSION:2.0" . "\r\nPRODID:-//phpOMS//Karaka Calendar//EN" . $methodLine diff --git a/tests/Message/Mail/MailHandlerSendmailTrait.php b/tests/Message/Mail/MailHandlerSendmailTrait.php index 9e07c1481..737e33bdf 100755 --- a/tests/Message/Mail/MailHandlerSendmailTrait.php +++ b/tests/Message/Mail/MailHandlerSendmailTrait.php @@ -282,10 +282,10 @@ trait MailHandlerSendmailTrait $mail->confirmationAddress = 'test1@jingga.app'; $mail->setFrom('test1@jingga.app', 'Dennis Eichhorn'); $mail->addTo('test@jingga.app', 'Dennis Eichhorn'); - $mail->subject = 'testSendICalAltWithSendmail'; - $mail->body = 'Ical test'; - $mail->bodyAlt = 'Ical test'; - $mail->ical = 'BEGIN:VCALENDAR' + $mail->subject = 'testSendICalAltWithSendmail'; + $mail->body = 'Ical test'; + $mail->bodyAlt = 'Ical test'; + $mail->ical = 'BEGIN:VCALENDAR' . "\r\nVERSION:2.0" . "\r\nPRODID:-//phpOMS//Karaka Calendar//EN" . $methodLine @@ -338,10 +338,10 @@ trait MailHandlerSendmailTrait $mail->setFrom('test1@jingga.app', 'Dennis Eichhorn'); $mail->addTo('test@jingga.app', 'Dennis Eichhorn'); $mail->addAttachment(__DIR__ . '/files/logo.png', 'logo'); - $mail->subject = 'testSendICalAltAttachmentWithSendmail'; - $mail->body = 'Ical test'; - $mail->bodyAlt = 'Ical test'; - $mail->ical = 'BEGIN:VCALENDAR' + $mail->subject = 'testSendICalAltAttachmentWithSendmail'; + $mail->body = 'Ical test'; + $mail->bodyAlt = 'Ical test'; + $mail->ical = 'BEGIN:VCALENDAR' . "\r\nVERSION:2.0" . "\r\nPRODID:-//phpOMS//Karaka Calendar//EN" . $methodLine diff --git a/tests/Message/Mail/MailHandlerSmtpTrait.php b/tests/Message/Mail/MailHandlerSmtpTrait.php index e14d2cff2..5a3e516c4 100755 --- a/tests/Message/Mail/MailHandlerSmtpTrait.php +++ b/tests/Message/Mail/MailHandlerSmtpTrait.php @@ -391,10 +391,10 @@ trait MailHandlerSmtpTrait $mail->confirmationAddress = 'test1@jingga.app'; $mail->setFrom('test1@jingga.app', 'Dennis Eichhorn'); $mail->addTo('test@jingga.app', 'Dennis Eichhorn'); - $mail->subject = 'testSendICalAltWithSmtp'; - $mail->body = 'Ical test'; - $mail->bodyAlt = 'Ical test'; - $mail->ical = 'BEGIN:VCALENDAR' + $mail->subject = 'testSendICalAltWithSmtp'; + $mail->body = 'Ical test'; + $mail->bodyAlt = 'Ical test'; + $mail->ical = 'BEGIN:VCALENDAR' . "\r\nVERSION:2.0" . "\r\nPRODID:-//phpOMS//Karaka Calendar//EN" . $methodLine @@ -456,10 +456,10 @@ trait MailHandlerSmtpTrait $mail->setFrom('test1@jingga.app', 'Dennis Eichhorn'); $mail->addTo('test@jingga.app', 'Dennis Eichhorn'); $mail->addAttachment(__DIR__ . '/files/logo.png', 'logo'); - $mail->subject = 'testSendICalAltAttachmentWithSmtp'; - $mail->body = 'Ical test'; - $mail->bodyAlt = 'Ical test'; - $mail->ical = 'BEGIN:VCALENDAR' + $mail->subject = 'testSendICalAltAttachmentWithSmtp'; + $mail->body = 'Ical test'; + $mail->bodyAlt = 'Ical test'; + $mail->ical = 'BEGIN:VCALENDAR' . "\r\nVERSION:2.0" . "\r\nPRODID:-//phpOMS//Karaka Calendar//EN" . $methodLine diff --git a/tests/Message/Mail/MailHandlerTest.php b/tests/Message/Mail/MailHandlerTest.php index 0e5f40a7d..540ea0c68 100755 --- a/tests/Message/Mail/MailHandlerTest.php +++ b/tests/Message/Mail/MailHandlerTest.php @@ -42,9 +42,9 @@ final class MailHandlerTest extends \PHPUnit\Framework\TestCase 'countryName' => 'DE', 'stateOrProvinceName' => 'Hesse', 'localityName' => 'Frankfurt', - 'organizationName' => 'Karaka', + 'organizationName' => 'Jingga', 'organizationalUnitName' => 'Framework', - 'commonName' => 'Karaka Test', + 'commonName' => 'Jingga Test', 'emailAddress' => 'test@jingga.app', ]; $keyconfig = [ diff --git a/tests/Model/Html/HeadTest.php b/tests/Model/Html/HeadTest.php index 1639c91b1..4aea21376 100755 --- a/tests/Model/Html/HeadTest.php +++ b/tests/Model/Html/HeadTest.php @@ -43,7 +43,7 @@ final class HeadTest extends \PHPUnit\Framework\TestCase { self::assertInstanceOf('\phpOMS\Model\Html\Meta', $this->head->meta); self::assertEquals('', $this->head->title); - self::assertEquals('en', $this->head->getLanguage()); + self::assertEquals('en', $this->head->language); self::assertEquals([], $this->head->getStyleAll()); self::assertEquals([], $this->head->getScriptAll()); self::assertEquals('', $this->head->renderStyle()); @@ -86,17 +86,6 @@ final class HeadTest extends \PHPUnit\Framework\TestCase self::assertEquals(['key' => 'console.log("msg");'], $this->head->getScriptAll()); } - /** - * @testdox The language can be set and returned - * @covers phpOMS\Model\Html\Head - * @group framework - */ - public function testLanguageInputOutput() : void - { - $this->head->setLanguage('en'); - self::assertEquals('en', $this->head->getLanguage()); - } - /** * @testdox The assets can be set and rendered * @covers phpOMS\Model\Html\Head diff --git a/tests/Model/Message/NotifyTest.php b/tests/Model/Message/NotifyTest.php index b6335f910..40a17e6ab 100755 --- a/tests/Model/Message/NotifyTest.php +++ b/tests/Model/Message/NotifyTest.php @@ -48,7 +48,7 @@ final class NotifyTest extends \PHPUnit\Framework\TestCase $obj->delay = 3; $obj->stay = 5; $obj->level = NotificationLevel::ERROR; - $obj->message ='msg'; + $obj->message = 'msg'; $obj->title = 'title'; self::assertEquals([ diff --git a/tests/Module/InstallerAbstractTest.php b/tests/Module/InstallerAbstractTest.php index d66f88ab9..d3e1c4e02 100755 --- a/tests/Module/InstallerAbstractTest.php +++ b/tests/Module/InstallerAbstractTest.php @@ -61,12 +61,12 @@ final class InstallerAbstractTest extends \PHPUnit\Framework\TestCase public function get( mixed $ids = null, - string | array $names = null, - int $unit = null, - int $app = null, - string $module = null, - int $group = null, - int $account = null + string | array|null $names = null, + ?int $unit = null, + ?int $app = null, + ?string $module = null, + ?int $group = null, + ?int $account = null ) : mixed { return null; diff --git a/tests/Module/ModuleAbstractTest.php b/tests/Module/ModuleAbstractTest.php index 99cbdf223..063e11a4d 100755 --- a/tests/Module/ModuleAbstractTest.php +++ b/tests/Module/ModuleAbstractTest.php @@ -26,7 +26,6 @@ use phpOMS\tests\DataStorage\Database\TestModel\BaseModel; use phpOMS\tests\DataStorage\Database\TestModel\BaseModelMapper; use phpOMS\tests\DataStorage\Database\TestModel\ManyToManyRelModel; use phpOMS\tests\DataStorage\Database\TestModel\ManyToManyRelModelMapper; -use phpOMS\Uri\HttpUri; /** * @testdox phpOMS\tests\Module\ModuleAbstractTest: Abstract module @@ -102,7 +101,7 @@ final class ModuleAbstractTest extends \PHPUnit\Framework\TestCase $model1 = BaseModelMapper::get()->where('id', 1)->execute(); $model2 = ManyToManyRelModelMapper::get()->where('id', 1)->execute(); - $this->createModelRelation(1, $model1->getId(), $model2->id, BaseModelMapper::class, 'hasManyRelations', '', '127.0.0.1'); + $this->createModelRelation(1, $model1->id, $model2->id, BaseModelMapper::class, 'hasManyRelations', '', '127.0.0.1'); } public function deleteRelationDB() : void @@ -110,7 +109,7 @@ final class ModuleAbstractTest extends \PHPUnit\Framework\TestCase $model1 = BaseModelMapper::get()->where('id', 1)->execute(); $model2 = ManyToManyRelModelMapper::get()->where('id', 1)->execute(); - $this->deleteModelRelation(1, $model1->getId(), $model2->id, BaseModelMapper::class, 'hasManyRelations', '', '127.0.0.1'); + $this->deleteModelRelation(1, $model1->id, $model2->id, BaseModelMapper::class, 'hasManyRelations', '', '127.0.0.1'); } public function creates() : void @@ -246,7 +245,7 @@ final class ModuleAbstractTest extends \PHPUnit\Framework\TestCase */ public function testFillJson() : void { - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $response = new HttpResponse(); $this->module->fillJson($request, $response, 'OK', 'Test Title', 'Test Message!', [1, 'test string', 'bool' => true]); @@ -269,7 +268,7 @@ final class ModuleAbstractTest extends \PHPUnit\Framework\TestCase */ public function testFillJsonRaw() : void { - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $response = new HttpResponse(); $this->module->fillJsonRaw($request, $response, [1, 'test string', 'bool' => true]); diff --git a/tests/Module/ModuleInfoTest.php b/tests/Module/ModuleInfoTest.php index 23964bfe3..0b749a749 100755 --- a/tests/Module/ModuleInfoTest.php +++ b/tests/Module/ModuleInfoTest.php @@ -112,7 +112,7 @@ final class ModuleInfoTest extends \PHPUnit\Framework\TestCase $info = new ModuleInfo(__DIR__ . '/info-test.json'); $info->load(); - $testObj = new class() { + $testObj = new class() { public $test = 1; public function test() : void diff --git a/tests/Module/ModuleManagerTest.php b/tests/Module/ModuleManagerTest.php index 60adacf9c..79776bf28 100755 --- a/tests/Module/ModuleManagerTest.php +++ b/tests/Module/ModuleManagerTest.php @@ -45,7 +45,7 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase */ protected function setUp() : void { - $this->app = new class() extends ApplicationAbstract { + $this->app = new class() extends ApplicationAbstract { protected string $appName = 'Api'; }; @@ -153,7 +153,7 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase self::assertTrue($this->moduleManager->activate('TestModule')); // this is normally done in the ApiController - $module->setStatus(ModuleStatus::ACTIVE); + $module->status = ModuleStatus::ACTIVE; ModuleMapper::update()->execute($module); $queryLoad = new Builder($this->app->dbPool->get('insert')); diff --git a/tests/Router/SocketRouterTest.php b/tests/Router/SocketRouterTest.php index 72d7ebcdb..6d29465b9 100755 --- a/tests/Router/SocketRouterTest.php +++ b/tests/Router/SocketRouterTest.php @@ -108,7 +108,7 @@ final class SocketRouterTest extends \PHPUnit\Framework\TestCase */ public function testDynamicRouteAdding() : void { - $this->router->add('^.*backends_admin -settings=general.*$', 'Controller:test'); + $this->router->add('^.*backends_admin -settings=general(\?.*$|$)', 'Controller:test'); self::assertEquals( [['dest' => 'Controller:test']], $this->router->route('backends_admin -settings=general -t 123') @@ -219,7 +219,7 @@ final class SocketRouterTest extends \PHPUnit\Framework\TestCase public function testDataValidation() : void { $this->router->add( - '^.*backends_admin -settings=general.*$', + '^.*backends_admin -settings=general(\?.*$|$)', 'Controller:test', validation: ['test_pattern' => '/^[a-z]*$/'] ); @@ -238,7 +238,7 @@ final class SocketRouterTest extends \PHPUnit\Framework\TestCase public function testInvalidDataValidation() : void { $this->router->add( - '^.*backends_admin -settings=general.*$', + '^.*backends_admin -settings=general(\?.*$|$)', 'Controller:test', validation: ['test_pattern' => '/^[a-z]*$/'] ); @@ -257,7 +257,7 @@ final class SocketRouterTest extends \PHPUnit\Framework\TestCase public function testDataFromPattern() : void { $this->router->add( - '^.*-settings=general.*$', + '^.*-settings=general(\?.*$|$)', 'Controller:test', dataPattern: '/^.*?(settings)=([a-z]*).*?$/' ); diff --git a/tests/Router/WebRouterTest.php b/tests/Router/WebRouterTest.php index ebe3ac000..11b55137d 100755 --- a/tests/Router/WebRouterTest.php +++ b/tests/Router/WebRouterTest.php @@ -142,7 +142,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase */ public function testDynamicRouteAdding() : void { - $this->router->add('^.*/backends/admin/settings/general.*$', 'Controller:test', RouteVerb::GET | RouteVerb::SET); + $this->router->add('^.*/backends/admin/settings/general(\?.*$|$)', 'Controller:test', RouteVerb::GET | RouteVerb::SET); self::assertEquals( [['dest' => 'Controller:test']], $this->router->route( @@ -318,7 +318,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase public function testDataValidation() : void { $this->router->add( - '^.*/backends/admin/settings/general.*$', + '^.*/backends/admin/settings/general(\?.*$|$)', 'Controller:test', RouteVerb::GET | RouteVerb::SET, false, @@ -335,14 +335,14 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase } /** - * @testdox A data validation pattern invalidates missmatches + * @testdox A data validation pattern invalidates miss-matches * @covers phpOMS\Router\WebRouter * @group framework */ public function testInvalidDataValidation() : void { $this->router->add( - '^.*/backends/admin/settings/general.*$', + '^.*/backends/admin/settings/general(\?.*$|$)', 'Controller:test', RouteVerb::GET | RouteVerb::SET, false, @@ -366,7 +366,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase public function testDataFromPattern() : void { $this->router->add( - '^.*/backends/admin.*$', + '^.*/backends/admin(\?.*$|$)', 'Controller:test', RouteVerb::GET | RouteVerb::SET, false, diff --git a/tests/Router/socketRouterTestFile.php b/tests/Router/socketRouterTestFile.php index 9fb5e48d0..3a4b22f4e 100755 --- a/tests/Router/socketRouterTestFile.php +++ b/tests/Router/socketRouterTestFile.php @@ -1,7 +1,7 @@ [ + '^.*backend_admin -settings=general(\?.*$|$)' => [ 0 => [ 'dest' => '\Modules\Admin\Controller:viewSettingsGeneral', ], diff --git a/tests/Router/socketRouterTestFilePermission.php b/tests/Router/socketRouterTestFilePermission.php index 359f24003..6e33a2e90 100755 --- a/tests/Router/socketRouterTestFilePermission.php +++ b/tests/Router/socketRouterTestFilePermission.php @@ -4,13 +4,13 @@ declare(strict_types=1); use phpOMS\Account\PermissionType; return [ - '^.*backend_admin -settings=general.*$' => [ + '^.*backend_admin -settings=general(\?.*$|$)' => [ 0 => [ 'dest' => '\Modules\Admin\Controller:viewSettingsGeneral', 'permission' => [ - 'module' => 'TEST', - 'type' => PermissionType::READ, - 'category' => 1, + 'module' => 'TEST', + 'type' => PermissionType::READ, + 'category' => 1, ], ], ], diff --git a/tests/Router/webRouteTestCsrf.php b/tests/Router/webRouteTestCsrf.php index 693807819..43edd600e 100755 --- a/tests/Router/webRouteTestCsrf.php +++ b/tests/Router/webRouteTestCsrf.php @@ -1,7 +1,7 @@ [ + '^.*/backend/admin/settings/csrf(\?.*$|$)' => [ 0 => [ 'dest' => '\Modules\Admin\Controller:viewCsrf', 'verb' => 1, diff --git a/tests/Router/webRouterTestFile.php b/tests/Router/webRouterTestFile.php index a6945522a..7f4fb925c 100755 --- a/tests/Router/webRouterTestFile.php +++ b/tests/Router/webRouterTestFile.php @@ -1,7 +1,7 @@ [ + '^.*/backend/admin/settings/general(\?.*$|$)' => [ 0 => [ 'dest' => '\Modules\Admin\Controller:viewSettingsGeneral', 'verb' => 1, diff --git a/tests/Router/webRouterTestFilePermission.php b/tests/Router/webRouterTestFilePermission.php index b44c375c5..5441e72bf 100755 --- a/tests/Router/webRouterTestFilePermission.php +++ b/tests/Router/webRouterTestFilePermission.php @@ -5,14 +5,14 @@ use phpOMS\Account\PermissionType; use phpOMS\Router\RouteVerb; return [ - '^.*/backend/admin/settings/general.*$' => [ + '^.*/backend/admin/settings/general(\?.*$|$)' => [ 0 => [ 'dest' => '\Modules\Admin\Controller:viewSettingsGeneral', 'verb' => RouteVerb::GET, 'permission' => [ - 'module' => 'TEST', - 'type' => PermissionType::READ, - 'category' => 1, + 'module' => 'TEST', + 'type' => PermissionType::READ, + 'category' => 1, ], ], ], diff --git a/tests/Security/EncryptionHelperTest.php b/tests/Security/EncryptionHelperTest.php index c3c82bc05..017dbb862 100644 --- a/tests/Security/EncryptionHelperTest.php +++ b/tests/Security/EncryptionHelperTest.php @@ -49,8 +49,8 @@ final class EncryptionHelperTest extends \PHPUnit\Framework\TestCase public function testFileEncryption() : void { - if (\is_file(__DIR__ . '/encrytped.txt')) { - \unlink(__DIR__ . '/encrytped.txt'); + if (\is_file(__DIR__ . '/encrypted.txt')) { + \unlink(__DIR__ . '/encrypted.txt'); } if (\is_file(__DIR__ . '/decrypted.txt')) { @@ -58,22 +58,22 @@ final class EncryptionHelperTest extends \PHPUnit\Framework\TestCase } $key = EncryptionHelper::createSharedKey(); - self::assertTrue(EncryptionHelper::encryptFile(__DIR__ . '/plain.txt', __DIR__ . '/encrytped.txt', $key)); + self::assertTrue(EncryptionHelper::encryptFile(__DIR__ . '/plain.txt', __DIR__ . '/encrypted.txt', $key)); self::assertNotEquals( \file_get_contents(__DIR__ . '/plain.txt'), - \file_get_contents(__DIR__ . '/encrytped.txt') + \file_get_contents(__DIR__ . '/encrypted.txt') ); - self::assertTrue(EncryptionHelper::decryptFile(__DIR__ . '/encrytped.txt', __DIR__ . '/decrypted.txt', $key)); + self::assertTrue(EncryptionHelper::decryptFile(__DIR__ . '/encrypted.txt', __DIR__ . '/decrypted.txt', $key)); self::assertEquals( \file_get_contents(__DIR__ . '/plain.txt'), \file_get_contents(__DIR__ . '/decrypted.txt') ); - if (\is_file(__DIR__ . '/encrytped.txt')) { - \unlink(__DIR__ . '/encrytped.txt'); + if (\is_file(__DIR__ . '/encrypted.txt')) { + \unlink(__DIR__ . '/encrypted.txt'); } if (\is_file(__DIR__ . '/decrypted.txt')) { diff --git a/tests/Security/GuardTest.php b/tests/Security/GuardTest.php index 89b80078f..8bac47439 100644 --- a/tests/Security/GuardTest.php +++ b/tests/Security/GuardTest.php @@ -56,4 +56,16 @@ final class GuardTest extends \PHPUnit\Framework\TestCase ) ); } + + /** + * @testdox A string can be validated for shell safety + * @covers phpOMS\Security\Guard + * @group framework + */ + public function testIsShellSafe() : void + { + self::assertTrue(Guard::isShellSafe('asdf')); + self::assertFalse(Guard::isShellSafe('&#;`|*?~<>^()[]{}$\\')); + self::assertFalse(Guard::isShellSafe('™')); + } } diff --git a/tests/Socket/Client/ClientTest.php b/tests/Socket/Client/ClientTest.php index 719c3cfc1..c850dee93 100755 --- a/tests/Socket/Client/ClientTest.php +++ b/tests/Socket/Client/ClientTest.php @@ -59,18 +59,18 @@ final class ClientTest extends \PHPUnit\Framework\TestCase protected string $appName = 'Socket'; }; - $this->app->logger = new FileLogger(__DIR__ . '/client.log', false); - $this->app->dbPool = $GLOBALS['dbpool']; - $this->app->unitId = 1; - $this->app->cachePool = new CachePool($this->app->dbPool); - $this->app->accountManager = new AccountManager($GLOBALS['session']); - $this->app->appSettings = new CoreSettings(); - $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/'); - $this->app->dispatcher = new Dispatcher($this->app); - $this->app->eventManager = new EventManager($this->app->dispatcher); + $this->app->logger = new FileLogger(__DIR__ . '/client.log', false); + $this->app->dbPool = $GLOBALS['dbpool']; + $this->app->unitId = 1; + $this->app->cachePool = new CachePool($this->app->dbPool); + $this->app->accountManager = new AccountManager($GLOBALS['session']); + $this->app->appSettings = new CoreSettings(); + $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/'); + $this->app->dispatcher = new Dispatcher($this->app); + $this->app->eventManager = new EventManager($this->app->dispatcher); $this->app->eventManager->importFromFile(__DIR__ . '/../../../Socket/Hooks.php'); - $this->app->l11nManager = new L11nManager(); - $this->app->router = new SocketRouter(); + $this->app->l11nManager = new L11nManager(); + $this->app->router = new SocketRouter(); } protected function tearDown() : void diff --git a/tests/Socket/Client/ClientTestHelper.php b/tests/Socket/Client/ClientTestHelper.php index 84700ab90..1728af467 100755 --- a/tests/Socket/Client/ClientTestHelper.php +++ b/tests/Socket/Client/ClientTestHelper.php @@ -49,18 +49,18 @@ $app = new class() extends ApplicationAbstract protected string $appName = 'Socket'; }; -$app->logger = FileLogger::getInstance(__DIR__ . '/server.log', true); -$app->dbPool = $GLOBALS['dbpool']; -$app->unitId = 1; -$app->cachePool = new CachePool($app->dbPool); -$app->accountManager = new AccountManager($GLOBALS['session']); -$app->appSettings = new CoreSettings($app->dbPool->get()); -$app->moduleManager = new ModuleManager($app, __DIR__ . '/../../../../Modules/'); -$app->dispatcher = new Dispatcher($app); -$app->eventManager = new EventManager($app->dispatcher); +$app->logger = FileLogger::getInstance(__DIR__ . '/server.log', true); +$app->dbPool = $GLOBALS['dbpool']; +$app->unitId = 1; +$app->cachePool = new CachePool($app->dbPool); +$app->accountManager = new AccountManager($GLOBALS['session']); +$app->appSettings = new CoreSettings($app->dbPool->get()); +$app->moduleManager = new ModuleManager($app, __DIR__ . '/../../../../Modules/'); +$app->dispatcher = new Dispatcher($app); +$app->eventManager = new EventManager($app->dispatcher); $app->eventManager->importFromFile(__DIR__ . '/../../../Socket/Hooks.php'); -$app->l11nManager = new L11nManager(); -$app->router = new SocketRouter(); +$app->l11nManager = new L11nManager(); +$app->router = new SocketRouter(); $socket = new Server($app); $socket->create('127.0.0.1', $config['socket']['master']['port']); diff --git a/tests/Socket/Server/ServerTest.php b/tests/Socket/Server/ServerTest.php index 247415a4e..a44349699 100755 --- a/tests/Socket/Server/ServerTest.php +++ b/tests/Socket/Server/ServerTest.php @@ -59,18 +59,18 @@ final class ServerTest extends \PHPUnit\Framework\TestCase protected string $appName = 'Socket'; }; - $this->app->logger = new FileLogger(__DIR__ . '/server.log', false); - $this->app->dbPool = $GLOBALS['dbpool']; - $this->app->unitId = 1; - $this->app->cachePool = new CachePool($this->app->dbPool); - $this->app->accountManager = new AccountManager($GLOBALS['session']); - $this->app->appSettings = new CoreSettings(); - $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/'); - $this->app->dispatcher = new Dispatcher($this->app); - $this->app->eventManager = new EventManager($this->app->dispatcher); + $this->app->logger = new FileLogger(__DIR__ . '/server.log', false); + $this->app->dbPool = $GLOBALS['dbpool']; + $this->app->unitId = 1; + $this->app->cachePool = new CachePool($this->app->dbPool); + $this->app->accountManager = new AccountManager($GLOBALS['session']); + $this->app->appSettings = new CoreSettings(); + $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/'); + $this->app->dispatcher = new Dispatcher($this->app); + $this->app->eventManager = new EventManager($this->app->dispatcher); $this->app->eventManager->importFromFile(__DIR__ . '/../../../Socket/Hooks.php'); - $this->app->l11nManager = new L11nManager(); - $this->app->router = new SocketRouter(); + $this->app->l11nManager = new L11nManager(); + $this->app->router = new SocketRouter(); } protected function tearDown() : void diff --git a/tests/Stdlib/Base/AddressTypeTest.php b/tests/Stdlib/Base/AddressTypeTest.php index f1e89e61e..931513cf3 100755 --- a/tests/Stdlib/Base/AddressTypeTest.php +++ b/tests/Stdlib/Base/AddressTypeTest.php @@ -27,7 +27,7 @@ final class AddressTypeTest extends \PHPUnit\Framework\TestCase */ public function testEnumCount() : void { - self::assertCount(8, AddressType::getconstants()); + self::assertCount(8, AddressType::getConstants()); } /** @@ -50,7 +50,6 @@ final class AddressTypeTest extends \PHPUnit\Framework\TestCase self::assertEquals(3, AddressType::SHIPPING); self::assertEquals(4, AddressType::BILLING); self::assertEquals(5, AddressType::WORK); - self::assertEquals(6, AddressType::CONTRACT); self::assertEquals(7, AddressType::OTHER); self::assertEquals(8, AddressType::EDUCATION); } diff --git a/tests/Stdlib/Base/LocationTest.php b/tests/Stdlib/Base/LocationTest.php index 08bd21eb1..d5e4dd2f3 100755 --- a/tests/Stdlib/Base/LocationTest.php +++ b/tests/Stdlib/Base/LocationTest.php @@ -53,11 +53,11 @@ final class LocationTest extends \PHPUnit\Framework\TestCase self::assertEquals('', $this->location->postal); self::assertEquals('', $this->location->city); - self::assertEquals('XX', $this->location->getCountry()); + self::assertEquals('XX', $this->location->country); self::assertEquals('', $this->location->address); self::assertEquals('', $this->location->state); - self::assertEquals(0, $this->location->getId()); - self::assertEquals(AddressType::HOME, $this->location->getType()); + self::assertEquals(0, $this->location->id); + self::assertEquals(AddressType::HOME, $this->location->type); self::assertEquals($expected, $this->location->toArray()); self::assertEquals($expected, $this->location->jsonSerialize()); } @@ -73,17 +73,6 @@ final class LocationTest extends \PHPUnit\Framework\TestCase self::assertEquals('0123456789', $this->location->postal); } - /** - * @testdox The type can be set and returned - * @covers phpOMS\Stdlib\Base\Location - * @group framework - */ - public function testTypeInputOutput() : void - { - $this->location->setType(AddressType::BUSINESS); - self::assertEquals(AddressType::BUSINESS, $this->location->getType()); - } - /** * @testdox The city can be set and returned * @covers phpOMS\Stdlib\Base\Location @@ -103,7 +92,7 @@ final class LocationTest extends \PHPUnit\Framework\TestCase public function testCountryInputOutput() : void { $this->location->setCountry('Country'); - self::assertEquals('Country', $this->location->getCountry()); + self::assertEquals('Country', $this->location->country); } /** @@ -145,8 +134,8 @@ final class LocationTest extends \PHPUnit\Framework\TestCase 'lon' => 11.2, ]; - $this->location->postal = '0123456789'; - $this->location->setType(AddressType::BUSINESS); + $this->location->postal = '0123456789'; + $this->location->type = AddressType::BUSINESS; $this->location->city = 'city'; $this->location->address = 'Some address here'; $this->location->state = 'This is a state 123'; @@ -174,8 +163,8 @@ final class LocationTest extends \PHPUnit\Framework\TestCase 'lon' => 11.2, ]; - $this->location->postal = '0123456789'; - $this->location->setType(AddressType::BUSINESS); + $this->location->postal = '0123456789'; + $this->location->type = AddressType::BUSINESS; $this->location->city = 'city'; $this->location->address = 'Some address here'; $this->location->state = 'This is a state 123'; diff --git a/tests/System/File/Local/FileTest.php b/tests/System/File/Local/FileTest.php index b7b2fd361..47a0b6c23 100755 --- a/tests/System/File/Local/FileTest.php +++ b/tests/System/File/Local/FileTest.php @@ -562,7 +562,7 @@ final class FileTest extends \PHPUnit\Framework\TestCase \unlink($testFile); } - $newPath = __DIR__ . '/test2.txt'; + $newPath = __DIR__ . '/test2.txt'; if (\is_file($newPath)) { \unlink($newPath); } diff --git a/tests/Utils/Converter/EnergyPowerTypeTest.php b/tests/Utils/Converter/EnergyPowerTypeTest.php index 708e36149..e8b3106e0 100755 --- a/tests/Utils/Converter/EnergyPowerTypeTest.php +++ b/tests/Utils/Converter/EnergyPowerTypeTest.php @@ -45,13 +45,13 @@ final class EnergyPowerTypeTest extends \PHPUnit\Framework\TestCase */ public function testEnums() : void { - self::assertEquals('kWh', EnergyPowerType::KILOWATT_HOUERS); - self::assertEquals('MWh', EnergyPowerType::MEGAWATT_HOUERS); + self::assertEquals('kWh', EnergyPowerType::KILOWATT_HOURS); + self::assertEquals('MWh', EnergyPowerType::MEGAWATT_HOURS); self::assertEquals('kt', EnergyPowerType::KILOTONS); - self::assertEquals('J', EnergyPowerType::JOULS); + self::assertEquals('J', EnergyPowerType::JOULES); self::assertEquals('Cal', EnergyPowerType::CALORIES); self::assertEquals('BTU', EnergyPowerType::BTU); - self::assertEquals('kJ', EnergyPowerType::KILOJOULS); + self::assertEquals('kJ', EnergyPowerType::KILOJOULES); self::assertEquals('thmEC', EnergyPowerType::THERMEC); self::assertEquals('Nm', EnergyPowerType::NEWTON_METERS); } diff --git a/tests/Utils/Converter/MeasurementTest.php b/tests/Utils/Converter/MeasurementTest.php index 9523eca04..5b49243cf 100755 --- a/tests/Utils/Converter/MeasurementTest.php +++ b/tests/Utils/Converter/MeasurementTest.php @@ -245,7 +245,7 @@ final class MeasurementTest extends \PHPUnit\Framework\TestCase } /** - * @testdox Filesizes can be converted + * @testdox File sizes can be converted * @covers phpOMS\Utils\Converter\Measurement * @group framework */ @@ -490,7 +490,7 @@ final class MeasurementTest extends \PHPUnit\Framework\TestCase { $this->expectException(\InvalidArgumentException::class); - Measurement::convertEnergy(1.1, 'invalid', EnergyPowerType::JOULS); + Measurement::convertEnergy(1.1, 'invalid', EnergyPowerType::JOULES); } /** @@ -502,7 +502,7 @@ final class MeasurementTest extends \PHPUnit\Framework\TestCase { $this->expectException(\InvalidArgumentException::class); - Measurement::convertEnergy(1.1, EnergyPowerType::JOULS, 'invalid'); + Measurement::convertEnergy(1.1, EnergyPowerType::JOULES, 'invalid'); } /** diff --git a/tests/Utils/PermutationTest.php b/tests/Utils/PermutationTest.php index c1cf8a984..ddf1f6599 100755 --- a/tests/Utils/PermutationTest.php +++ b/tests/Utils/PermutationTest.php @@ -36,8 +36,8 @@ final class PermutationTest extends \PHPUnit\Framework\TestCase $permutations = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']; $permutations2 = [['a', 'b', 'c'], ['a', 'c', 'b'], ['b', 'a', 'c'], ['b', 'c', 'a'], ['c', 'a', 'b'], ['c', 'b', 'a']]; - self::assertEquals($permutations, Permutation::permut($arr)); - self::assertEquals($permutations2, Permutation::permut($arr, [], false)); + self::assertEquals($permutations, Permutation::permuteAll($arr)); + self::assertEquals($permutations2, Permutation::permuteAll($arr, [], false)); } /** @@ -68,9 +68,9 @@ final class PermutationTest extends \PHPUnit\Framework\TestCase * @covers phpOMS\Utils\Permutation * @group framework */ - public function testPermutate() : void + public function testPermute() : void { - self::assertEquals(['c', 'b', 'a'], Permutation::permutate(['a', 'b', 'c'], [2, 1, 1])); + self::assertEquals(['c', 'b', 'a'], Permutation::permuteByKey(['a', 'b', 'c'], [2, 1, 1])); } /** @@ -82,6 +82,6 @@ final class PermutationTest extends \PHPUnit\Framework\TestCase { $this->expectException(\OutOfBoundsException::class); - Permutation::permutate('abc', [2, 1, 1, 6]); + Permutation::permuteByKey('abc', [2, 1, 1, 6]); } } diff --git a/tests/Utils/StringUtilsTest.php b/tests/Utils/StringUtilsTest.php index f09a31c3e..531266491 100755 --- a/tests/Utils/StringUtilsTest.php +++ b/tests/Utils/StringUtilsTest.php @@ -229,16 +229,4 @@ final class StringUtilsTest extends \PHPUnit\Framework\TestCase StringUtils::createDiffMarkup($original, $new) ); } - - /** - * @testdox A string can be validated for shell safety - * @covers phpOMS\Utils\StringUtils - * @group framework - */ - public function testIsShellSafe() : void - { - self::assertTrue(StringUtils::isShellSafe('asdf')); - self::assertFalse(StringUtils::isShellSafe('&#;`|*?~<>^()[]{}$\\')); - self::assertFalse(StringUtils::isShellSafe('™')); - } } diff --git a/tests/Utils/TaskSchedule/TaskAbstractTest.php b/tests/Utils/TaskSchedule/TaskAbstractTest.php index 6ecefb5c7..31f8ab72f 100755 --- a/tests/Utils/TaskSchedule/TaskAbstractTest.php +++ b/tests/Utils/TaskSchedule/TaskAbstractTest.php @@ -54,7 +54,7 @@ final class TaskAbstractTest extends \PHPUnit\Framework\TestCase { self::assertEquals('', $this->class->getId()); self::assertEquals('', $this->class->getCommand()); - self::assertEquals(TaskStatus::ACTIVE, $this->class->getStatus()); + self::assertEquals(TaskStatus::ACTIVE, $this->class->status); self::assertInstanceOf('\DateTime', $this->class->getNextRunTime()); self::assertInstanceOf('\DateTime', $this->class->getLastRuntime()); self::assertEquals('', $this->class->getComment()); @@ -83,17 +83,6 @@ final class TaskAbstractTest extends \PHPUnit\Framework\TestCase self::assertEquals('Interval', $this->class->getInterval()); } - /** - * @testdox The status can be set and returned - * @covers phpOMS\Utils\TaskSchedule\TaskAbstract - * @group framework - */ - public function testStatusInputOutput() : void - { - $this->class->setStatus(TaskStatus::FINISHED); - self::assertEquals(TaskStatus::FINISHED, $this->class->getStatus()); - } - /** * @testdox The comment can be set and returned * @covers phpOMS\Utils\TaskSchedule\TaskAbstract diff --git a/tests/Utils/TestUtilsClass.php b/tests/Utils/TestUtilsClass.php index 9ebe0230a..46cdf4a71 100755 --- a/tests/Utils/TestUtilsClass.php +++ b/tests/Utils/TestUtilsClass.php @@ -16,11 +16,11 @@ namespace phpOMS\tests\Utils; class TestUtilsClass { - private $a = 1; + private $a = 1; protected $b = 2; - public $c = 3; + public $c = 3; - public $d = '4'; + public $d = '4'; }