diff --git a/Api/Shipping/DHL/DHLInternationalShipping.php b/Api/Shipping/DHL/DHLInternationalShipping.php index bafc1e4e1..8a39619c0 100644 --- a/Api/Shipping/DHL/DHLInternationalShipping.php +++ b/Api/Shipping/DHL/DHLInternationalShipping.php @@ -213,7 +213,7 @@ final class DHLInternationalShipping implements ShippingInterface $status = AuthStatus::LIMIT_EXCEEDED; break; case 200: - $this->token = $response->getData('access_token') ?? ''; + $this->token = $response->getDataString('access_token') ?? ''; $this->expire->setTimestamp($this->expire->getTimestamp() + ((int) $response->getData('expires_in'))); $status = AuthStatus::OK; @@ -275,6 +275,7 @@ final class DHLInternationalShipping implements ShippingInterface array $data ) : array { + return []; } /** @@ -282,6 +283,7 @@ final class DHLInternationalShipping implements ShippingInterface */ public function cancel(string $shipment, array $packages = []) : bool { + return false; } /** @@ -294,7 +296,7 @@ final class DHLInternationalShipping implements ShippingInterface $httpUri = new HttpUri($uri); $httpUri->addQuery('trackingnumber', $shipment); - $httpUri->addQuery('limit', 10); + $httpUri->addQuery('limit', '10'); // @todo implement: express, parcel-de, ecommerce, dgf, parcel-uk, post-de, sameday, freight, parcel-nl, parcel-pl, dsc, ecommerce-europe, svb //$httpUri->addQuery('service', ''); diff --git a/Api/Shipping/DHL/DHLParcelDEShipping.php b/Api/Shipping/DHL/DHLParcelDEShipping.php index c2b226be9..23a636fe3 100644 --- a/Api/Shipping/DHL/DHLParcelDEShipping.php +++ b/Api/Shipping/DHL/DHLParcelDEShipping.php @@ -507,7 +507,7 @@ final class DHLParcelDEShipping implements ShippingInterface $httpUri = new HttpUri($uri); $httpUri->addQuery('trackingnumber', $shipment); - $httpUri->addQuery('limit', 10); + $httpUri->addQuery('limit', '10'); // @todo implement: express, parcel-de, ecommerce, dgf, parcel-uk, post-de, sameday, freight, parcel-nl, parcel-pl, dsc, ecommerce-europe, svb //$httpUri->addQuery('service', ''); diff --git a/Api/Shipping/DHL/DHLeCommerceShipping.php b/Api/Shipping/DHL/DHLeCommerceShipping.php index 2990683f1..bc3ef10e5 100644 --- a/Api/Shipping/DHL/DHLeCommerceShipping.php +++ b/Api/Shipping/DHL/DHLeCommerceShipping.php @@ -14,7 +14,9 @@ declare(strict_types=1); namespace phpOMS\Api\Shipping\DHL; +use phpOMS\Api\Shipping\AuthStatus; use phpOMS\Api\Shipping\ShippingInterface; +use phpOMS\Message\Http\HttpRequest; /** * Shipment api. @@ -27,6 +29,86 @@ use phpOMS\Api\Shipping\ShippingInterface; * @see Tracking: https://developer.dhl.com/api-reference/shipment-tracking#get-started-section/ * @since 1.0.0 */ -final class DHLParcelDEShipping implements ShippingInterface +final class DHLeCommerceShipping implements ShippingInterface { + /** + * {@inheritdoc} + */ + public function authLogin( + string $login, string $password, + ?string $client = null, + ?string $payload = null + ) : int + { + return AuthStatus::FAILED; + } + + /** + * {@inheritdoc} + */ + public function authRedirectLogin( + string $client, + ?string $redirect = null, + array $payload = [] + ) : HttpRequest + { + return new HttpRequest(); + } + + /** + * {@inheritdoc} + */ + public function tokenFromRedirect( + string $login, string $password, + HttpRequest $redirect + ) : int + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function authApiKey(string $key) : int + { + return AuthStatus::FAILED; + } + + /** + * {@inheritdoc} + */ + public function refreshToken() : int + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function ship( + array $sender, + array $shipFrom, + array $receiver, + array $package, + array $data + ) : array + { + return []; + } + + /** + * {@inheritdoc} + */ + public function cancel(string $shipment, array $packages = []) : bool + { + return false; + } + + /** + * {@inheritdoc} + */ + public function track(string $shipment) : array + { + return []; + } } diff --git a/Api/Shipping/DPD/DPDShipping.php b/Api/Shipping/DPD/DPDShipping.php index 1c9f36d66..8b33ad7a0 100644 --- a/Api/Shipping/DPD/DPDShipping.php +++ b/Api/Shipping/DPD/DPDShipping.php @@ -14,7 +14,9 @@ declare(strict_types=1); namespace phpOMS\Api\Shipping\DPD; +use phpOMS\Api\Shipping\AuthStatus; use phpOMS\Api\Shipping\ShippingInterface; +use phpOMS\Message\Http\HttpRequest; /** * Shipment api. @@ -28,4 +30,84 @@ use phpOMS\Api\Shipping\ShippingInterface; */ final class DPDShipping implements ShippingInterface { + /** + * {@inheritdoc} + */ + public function authLogin( + string $login, string $password, + ?string $client = null, + ?string $payload = null + ) : int + { + return AuthStatus::FAILED; + } + + /** + * {@inheritdoc} + */ + public function authRedirectLogin( + string $client, + ?string $redirect = null, + array $payload = [] + ) : HttpRequest + { + return new HttpRequest(); + } + + /** + * {@inheritdoc} + */ + public function tokenFromRedirect( + string $login, string $password, + HttpRequest $redirect + ) : int + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function authApiKey(string $key) : int + { + return AuthStatus::FAILED; + } + + /** + * {@inheritdoc} + */ + public function refreshToken() : int + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function ship( + array $sender, + array $shipFrom, + array $receiver, + array $package, + array $data + ) : array + { + return []; + } + + /** + * {@inheritdoc} + */ + public function cancel(string $shipment, array $packages = []) : bool + { + return false; + } + + /** + * {@inheritdoc} + */ + public function track(string $shipment) : array + { + return []; + } } diff --git a/Api/Shipping/Fedex/FedexShipping.php b/Api/Shipping/Fedex/FedexShipping.php index 0f99bac11..058830d56 100644 --- a/Api/Shipping/Fedex/FedexShipping.php +++ b/Api/Shipping/Fedex/FedexShipping.php @@ -14,7 +14,9 @@ declare(strict_types=1); namespace phpOMS\Api\Shipping\Fedex; +use phpOMS\Api\Shipping\AuthStatus; use phpOMS\Api\Shipping\ShippingInterface; +use phpOMS\Message\Http\HttpRequest; /** * Shipment api. @@ -27,4 +29,84 @@ use phpOMS\Api\Shipping\ShippingInterface; */ final class FedexShipping implements ShippingInterface { + /** + * {@inheritdoc} + */ + public function authLogin( + string $login, string $password, + ?string $client = null, + ?string $payload = null + ) : int + { + return AuthStatus::FAILED; + } + + /** + * {@inheritdoc} + */ + public function authRedirectLogin( + string $client, + ?string $redirect = null, + array $payload = [] + ) : HttpRequest + { + return new HttpRequest(); + } + + /** + * {@inheritdoc} + */ + public function tokenFromRedirect( + string $login, string $password, + HttpRequest $redirect + ) : int + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function authApiKey(string $key) : int + { + return AuthStatus::FAILED; + } + + /** + * {@inheritdoc} + */ + public function refreshToken() : int + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function ship( + array $sender, + array $shipFrom, + array $receiver, + array $package, + array $data + ) : array + { + return []; + } + + /** + * {@inheritdoc} + */ + public function cancel(string $shipment, array $packages = []) : bool + { + return false; + } + + /** + * {@inheritdoc} + */ + public function track(string $shipment) : array + { + return []; + } } diff --git a/Api/Shipping/RoyalMail/RoyalMailShipping.php b/Api/Shipping/RoyalMail/RoyalMailShipping.php index 4d6fe0a0d..8c5c638e4 100644 --- a/Api/Shipping/RoyalMail/RoyalMailShipping.php +++ b/Api/Shipping/RoyalMail/RoyalMailShipping.php @@ -14,7 +14,9 @@ declare(strict_types=1); namespace phpOMS\Api\Shipping\RoyalMail; +use phpOMS\Api\Shipping\AuthStatus; use phpOMS\Api\Shipping\ShippingInterface; +use phpOMS\Message\Http\HttpRequest; /** * Shipment api. @@ -27,4 +29,84 @@ use phpOMS\Api\Shipping\ShippingInterface; */ final class RoyalMailShipping implements ShippingInterface { + /** + * {@inheritdoc} + */ + public function authLogin( + string $login, string $password, + ?string $client = null, + ?string $payload = null + ) : int + { + return AuthStatus::FAILED; + } + + /** + * {@inheritdoc} + */ + public function authRedirectLogin( + string $client, + ?string $redirect = null, + array $payload = [] + ) : HttpRequest + { + return new HttpRequest(); + } + + /** + * {@inheritdoc} + */ + public function tokenFromRedirect( + string $login, string $password, + HttpRequest $redirect + ) : int + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function authApiKey(string $key) : int + { + return AuthStatus::FAILED; + } + + /** + * {@inheritdoc} + */ + public function refreshToken() : int + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function ship( + array $sender, + array $shipFrom, + array $receiver, + array $package, + array $data + ) : array + { + return []; + } + + /** + * {@inheritdoc} + */ + public function cancel(string $shipment, array $packages = []) : bool + { + return false; + } + + /** + * {@inheritdoc} + */ + public function track(string $shipment) : array + { + return []; + } } diff --git a/Api/Shipping/ShippingInterface.php b/Api/Shipping/ShippingInterface.php index df96b2495..2346f6b9f 100644 --- a/Api/Shipping/ShippingInterface.php +++ b/Api/Shipping/ShippingInterface.php @@ -46,10 +46,10 @@ interface ShippingInterface /** * Create request for authentication using login and password * - * @param string $login Login name/email - * @param string $password Password - * @param string $client Client id - * @param array $payload Other payload data + * @param string $login Login name/email + * @param string $password Password + * @param null|string $client Client id + * @param null|string $payload Other payload data * * @return int Returns auth status * diff --git a/Api/Shipping/TNT/TNTShipping.php b/Api/Shipping/TNT/TNTShipping.php index 728c36390..eeb2faa8a 100644 --- a/Api/Shipping/TNT/TNTShipping.php +++ b/Api/Shipping/TNT/TNTShipping.php @@ -14,7 +14,9 @@ declare(strict_types=1); namespace phpOMS\Api\Shipping\TNT; +use phpOMS\Api\Shipping\AuthStatus; use phpOMS\Api\Shipping\ShippingInterface; +use phpOMS\Message\Http\HttpRequest; /** * Shipment api. @@ -27,4 +29,84 @@ use phpOMS\Api\Shipping\ShippingInterface; */ final class TNTShipping implements ShippingInterface { + /** + * {@inheritdoc} + */ + public function authLogin( + string $login, string $password, + ?string $client = null, + ?string $payload = null + ) : int + { + return AuthStatus::FAILED; + } + + /** + * {@inheritdoc} + */ + public function authRedirectLogin( + string $client, + ?string $redirect = null, + array $payload = [] + ) : HttpRequest + { + return new HttpRequest(); + } + + /** + * {@inheritdoc} + */ + public function tokenFromRedirect( + string $login, string $password, + HttpRequest $redirect + ) : int + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function authApiKey(string $key) : int + { + return AuthStatus::FAILED; + } + + /** + * {@inheritdoc} + */ + public function refreshToken() : int + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function ship( + array $sender, + array $shipFrom, + array $receiver, + array $package, + array $data + ) : array + { + return []; + } + + /** + * {@inheritdoc} + */ + public function cancel(string $shipment, array $packages = []) : bool + { + return false; + } + + /** + * {@inheritdoc} + */ + public function track(string $shipment) : array + { + return []; + } } diff --git a/Api/Shipping/UPS/UPSShipping.php b/Api/Shipping/UPS/UPSShipping.php index 2c77eb0f3..727a9afed 100644 --- a/Api/Shipping/UPS/UPSShipping.php +++ b/Api/Shipping/UPS/UPSShipping.php @@ -150,7 +150,6 @@ final class UPSShipping implements ShippingInterface /** * Refresh token expiration. * - * @var \DateTime * @since 1.0.0 */ public function __construct() @@ -179,7 +178,11 @@ final class UPSShipping implements ShippingInterface $request->setMethod(RequestMethod::POST); $request->setData('grant_type', 'client_credentials'); $request->header->set('Content-Type', MimeType::M_POST); - $request->header->set('x-merchant-id', $client); + + if ($client !== null) { + $request->header->set('x-merchant-id', $client); + } + $request->header->set('Authorization', 'Basic ' . \base64_encode($login . ':' . $password)); $this->expire = new \DateTime('now'); @@ -198,7 +201,7 @@ final class UPSShipping implements ShippingInterface $status = AuthStatus::LIMIT_EXCEEDED; break; case 200: - $this->token = $response->getData('access_token') ?? ''; + $this->token = $response->getDataString('access_token') ?? ''; $this->expire->setTimestamp($this->expire->getTimestamp() + ((int) $response->getData('expires_in'))); $status = AuthStatus::OK; @@ -276,8 +279,8 @@ final class UPSShipping implements ShippingInterface $status = AuthStatus::LIMIT_EXCEEDED; break; case 200: - $this->token = $response->getData('access_token') ?? ''; - $this->refreshToken = $response->getData('refresh_token') ?? ''; + $this->token = $response->getDataString('access_token') ?? ''; + $this->refreshToken = $response->getDataString('refresh_token') ?? ''; $this->expire->setTimestamp($this->expire->getTimestamp() + ((int) $response->getData('expires_in'))); $this->refreshExpire->setTimestamp($this->refreshExpire->getTimestamp() + ((int) $response->getData('refresh_token_expires_in'))); @@ -330,8 +333,8 @@ final class UPSShipping implements ShippingInterface $status = AuthStatus::LIMIT_EXCEEDED; break; case 200: - $this->token = $response->getData('access_token') ?? ''; - $this->refreshToken = $response->getData('refresh_token') ?? ''; + $this->token = $response->getDataString('access_token') ?? ''; + $this->refreshToken = $response->getDataString('refresh_token') ?? ''; $this->expire->setTimestamp($this->expire->getTimestamp() + ((int) $response->getData('expires_in'))); $this->refreshExpire->setTimestamp($this->refreshExpire->getTimestamp() + ((int) $response->getData('refresh_token_expires_in'))); @@ -398,7 +401,7 @@ final class UPSShipping implements ShippingInterface return []; } - $services = $response->getDataArray('services'); + $services = $response->getDataArray('services') ?? []; $transits = []; foreach ($services as $service) { @@ -665,7 +668,7 @@ final class UPSShipping implements ShippingInterface return false; } - return ($response->getData('VoidShipmentResponse')['Response']['ResponseStatus']['Code'] ?? '0') === '1'; + return ($response->getDataArray('VoidShipmentResponse')['Response']['ResponseStatus']['Code'] ?? '0') === '1'; } /** diff --git a/Api/Shipping/Usps/UspsShipping.php b/Api/Shipping/Usps/UspsShipping.php index 165e9cf5c..455c44e17 100644 --- a/Api/Shipping/Usps/UspsShipping.php +++ b/Api/Shipping/Usps/UspsShipping.php @@ -14,7 +14,9 @@ declare(strict_types=1); namespace phpOMS\Api\Shipping\Usps; +use phpOMS\Api\Shipping\AuthStatus; use phpOMS\Api\Shipping\ShippingInterface; +use phpOMS\Message\Http\HttpRequest; /** * Shipment api. @@ -27,4 +29,84 @@ use phpOMS\Api\Shipping\ShippingInterface; */ final class UspsShipping implements ShippingInterface { + /** + * {@inheritdoc} + */ + public function authLogin( + string $login, string $password, + ?string $client = null, + ?string $payload = null + ) : int + { + return AuthStatus::FAILED; + } + + /** + * {@inheritdoc} + */ + public function authRedirectLogin( + string $client, + ?string $redirect = null, + array $payload = [] + ) : HttpRequest + { + return new HttpRequest(); + } + + /** + * {@inheritdoc} + */ + public function tokenFromRedirect( + string $login, string $password, + HttpRequest $redirect + ) : int + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function authApiKey(string $key) : int + { + return AuthStatus::FAILED; + } + + /** + * {@inheritdoc} + */ + public function refreshToken() : int + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function ship( + array $sender, + array $shipFrom, + array $receiver, + array $package, + array $data + ) : array + { + return []; + } + + /** + * {@inheritdoc} + */ + public function cancel(string $shipment, array $packages = []) : bool + { + return false; + } + + /** + * {@inheritdoc} + */ + public function track(string $shipment) : array + { + return []; + } } diff --git a/Localization/BaseStringL11n.php b/Localization/BaseStringL11n.php index 5b371cf18..17bebc279 100755 --- a/Localization/BaseStringL11n.php +++ b/Localization/BaseStringL11n.php @@ -40,7 +40,7 @@ class BaseStringL11n implements \JsonSerializable */ public string $name = ''; - // @todo this feels like $name and $type accomplish the same thing + // @todo Karaka/phpOMS#357 this feels like $name and $type accomplish the same thing // maybe we can always use $type and remove $name. // This would require some smart mapper adjustment where the name is part of the l11n model, // maybe use the path definition in the mapper which is used by arrays (e.g. type/name) diff --git a/Localization/ISO3166Trait.php b/Localization/ISO3166Trait.php index 1a8ef9e09..39aa6ffd4 100644 --- a/Localization/ISO3166Trait.php +++ b/Localization/ISO3166Trait.php @@ -322,7 +322,7 @@ trait ISO3166Trait case 'g8': return [ self::_USA, self::_GBR, self::_FRA, self::_DEU, self::_ITA, - self::_CAN, self::_RUS, self::_JAP, + self::_CAN, self::_RUS, self::_JPN, ]; case 'p5': return [ diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index b3c88d536..f9cac264f 100755 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -251,9 +251,11 @@ abstract class RequestAbstract implements MessageInterface { $key = \mb_strtolower($key); - return empty($this->data[$key] ?? null) + $timestamp = empty($this->data[$key] ?? null) ? null - : \strtotime((string) $this->data[$key]); + : (int) \strtotime((string) $this->data[$key]); + + return $timestamp === false ? null : $timestamp; } /** diff --git a/Stdlib/Tree/BinarySearchTree.php b/Stdlib/Tree/BinarySearchTree.php index 93a92e07e..f5fe8779e 100644 --- a/Stdlib/Tree/BinarySearchTree.php +++ b/Stdlib/Tree/BinarySearchTree.php @@ -249,7 +249,7 @@ class BinarySearchTree $temp = null; if ($node->left === null) { - $temp = $node->right->root; + $temp = $node->right?->root; if ($temp === null) { return; } diff --git a/Uri/Argument.php b/Uri/Argument.php index ce35d8d81..8ad4b6898 100755 --- a/Uri/Argument.php +++ b/Uri/Argument.php @@ -119,7 +119,7 @@ final class Argument implements UriInterface /** * Uri query. * - * @var array + * @var array * @since 1.0.0 */ private array $query = []; diff --git a/Uri/HttpUri.php b/Uri/HttpUri.php index 7c82a2fd3..95c50ed2f 100755 --- a/Uri/HttpUri.php +++ b/Uri/HttpUri.php @@ -121,7 +121,7 @@ final class HttpUri implements UriInterface /** * Uri query. * - * @var array + * @var array * @since 1.0.0 */ private array $query = []; @@ -386,14 +386,14 @@ final class HttpUri implements UriInterface /** * Add query parameter * - * @param string $key Parameter key - * @param mixed $value Value (null = omitted) + * @param string $key Parameter key + * @param null|string $value Value (null = omitted) * * @return void * * @since 1.0.0 */ - public function addQuery(string $key, mixed $value = null) : void + public function addQuery(string $key, ?string $value = null) : void { $key = \strtolower($key); $this->query[$key] = $value; diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index ddb131f97..ad22286a2 100755 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -29,7 +29,7 @@ final class UriFactory /** * Dynamic query elements. * - * @var string[] + * @var array * @since 1.0.0 */ private static array $uri = []; @@ -105,15 +105,15 @@ final class UriFactory /** * Set global query replacements. * - * @param string $key Replacement key - * @param string $value Replacement value - * @param bool $overwrite Overwrite if already exists + * @param string $key Replacement key + * @param null|string $value Replacement value + * @param bool $overwrite Overwrite if already exists * * @return bool * * @since 1.0.0 */ - public static function setQuery(string $key, string $value, bool $overwrite = false) : bool + public static function setQuery(string $key, ?string $value, bool $overwrite = false) : bool { if ($overwrite || !isset(self::$uri[$key])) { self::$uri[$key] = $value; diff --git a/Uri/UriInterface.php b/Uri/UriInterface.php index ec8ec6088..66efac66e 100755 --- a/Uri/UriInterface.php +++ b/Uri/UriInterface.php @@ -173,7 +173,7 @@ interface UriInterface /** * Get query array. * - * @return string[] + * @return array * * @since 1.0.0 */ diff --git a/Utils/Parser/Markdown/Markdown.php b/Utils/Parser/Markdown/Markdown.php index e520abfee..1966520ec 100755 --- a/Utils/Parser/Markdown/Markdown.php +++ b/Utils/Parser/Markdown/Markdown.php @@ -530,9 +530,9 @@ class Markdown $this->blockTypes['['][] = 'Checkbox'; } - // Embeding - if ($this->options['embeding'] ?? false) { - $this->inlineTypes['['][] = 'Embeding'; + // Embedding + if ($this->options['embedding'] ?? false) { + $this->inlineTypes['['][] = 'Embedding'; } // Map @@ -649,19 +649,17 @@ class Markdown */ public function contentsList($typeReturn = 'html') : string { - if (\strtolower($typeReturn) === 'html') { - $result = ''; - if (!empty($this->contentsListString)) { - // Parses the ToC list in markdown to HTML - $result = $this->body($this->contentsListString); - } - - return $result; - } elseif (\strtolower($typeReturn) === 'json') { + if (\strtolower($typeReturn) === 'json') { return \json_encode($this->contentsListArray); } - return $this->contentsList('html'); + $result = ''; + if (!empty($this->contentsListString)) { + // Parses the ToC list in markdown to HTML + $result = $this->body($this->contentsListString); + } + + return $result; } /** @@ -1323,7 +1321,7 @@ class Markdown } /** - * Handle embeding + * Handle embedding * * @param array{text:string, context:string, before:string} $excerpt Inline data * @@ -1331,9 +1329,9 @@ class Markdown * * @since 1.0.0 */ - protected function inlineEmbeding(array $excerpt) : ?array + protected function inlineEmbedding(array $excerpt) : ?array { - if (!($this->options['embeding'] ?? false) + if (!($this->options['embedding'] ?? false) || !(\str_starts_with($excerpt['text'], '[video') || \str_starts_with($excerpt['text'], '[audio')) || (!($video = (\preg_match('/\[video.*src="([^"]*)".*\]/', $excerpt['text'], $matches) === 1)) && !($audio = (\preg_match('/\[audio.*src="([^"]*)".*\]/', $excerpt['text'], $matches) === 1))) @@ -1785,7 +1783,7 @@ class Markdown $state = $this->options['math'] ?? false; if (!$state - || ($state && !\preg_match('/^(? 2, @@ -1882,14 +1880,12 @@ class Markdown return null; } - $text = \substr($line['body'], 4); - return [ 'element' => [ 'name' => 'pre', 'element' => [ 'name' => 'code', - 'text' => $text, + 'text' => \substr($line['body'], 4), ], ], ]; @@ -3176,22 +3172,19 @@ class Markdown $this->initBlacklist(); } - $this->anchorDuplicates[$str] = isset($this->anchorDuplicates[$str]) ? ++$this->anchorDuplicates[$str] : 0; + do { + $this->anchorDuplicates[$str] = isset($this->anchorDuplicates[$str]) ? ++$this->anchorDuplicates[$str] : 0; - $newStr = $str; + $newStr = $str; - if (($count = $this->anchorDuplicates[$str]) === 0) { - return $newStr; - } + if (($count = $this->anchorDuplicates[$str]) === 0) { + return $newStr; + } - $newStr .= '-' . $count; + $newStr .= '-' . $count; + } while(isset($this->anchorDuplicates[$newStr])); - // increment until conversion doesn't produce new duplicates anymore - if (isset($this->anchorDuplicates[$newStr])) { - $newStr = $this->incrementAnchorId($str); - } else { - $this->anchorDuplicates[$newStr] = 0; - } + $this->anchorDuplicates[$newStr] = 0; return $newStr; } @@ -4475,7 +4468,7 @@ class Markdown } /** - * Handle element recursiveley + * Handle element recursively * * @param string|\Closure $closure Closure for handling element * @param array $element Element to handle @@ -4500,7 +4493,7 @@ class Markdown } /** - * Handle element recursiveley + * Handle element recursively * * @param string|\Closure $closure Closure for handling element * @param array $element Element to handle @@ -4536,7 +4529,7 @@ class Markdown protected function element(array $element) : string { if ($this->safeMode) { - $element = $this->sanitiseElement($element); + $element = $this->sanitizeElement($element); } // identity map if element has no handler @@ -4691,7 +4684,7 @@ class Markdown * * @since 1.0.0 */ - protected function sanitiseElement(array $element) : array + protected function sanitizeElement(array $element) : array { static $goodAttribute = '/^[a-zA-Z0-9][a-zA-Z0-9-_]*+$/'; static $safeUrlNameToAtt = [ diff --git a/Utils/TaskSchedule/Cron.php b/Utils/TaskSchedule/Cron.php index 13c2ad9b1..e3b98a063 100755 --- a/Utils/TaskSchedule/Cron.php +++ b/Utils/TaskSchedule/Cron.php @@ -206,8 +206,10 @@ class Cron extends SchedulerAbstract $elements = \array_merge($elements, $interval); $elements[] = \trim(\substr($line, $len = (\strlen(\implode(' ', $interval)) + 1), $comment - $len - 1)); - $jobs[] = $job = CronJob::createWith($elements); - $job->setStatus($line[0] === '#' ? TaskStatus::INACTIVE : TaskStatus::ACTIVE); + $job = CronJob::createWith($elements); + $job->status = $line[0] === '#' ? TaskStatus::INACTIVE : TaskStatus::ACTIVE; + + $jobs[] = $job; } $line = \fgets($fp); diff --git a/Utils/TaskSchedule/Schedule.php b/Utils/TaskSchedule/Schedule.php index b00f6b7e5..d0ec5dfcf 100755 --- a/Utils/TaskSchedule/Schedule.php +++ b/Utils/TaskSchedule/Schedule.php @@ -45,7 +45,7 @@ class Schedule extends TaskAbstract */ $job = new self($jobData[1], $jobData[8], $jobData[7]); - $job->setStatus((int) $jobData[3]); + $job->status = (int) $jobData[3]; if (DateTime::isValid($jobData[2])) { $job->setNextRunTime(new \DateTime($jobData[2]));