Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: v3 #318

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"license": "MIT",
"require": {
"ext-zip": "*",
"illuminate/support": ">= 8",
"justinrainbow/json-schema": "^5.2",
"myparcelnl/sdk": ">= 7",
"php": ">=7.1.0",
"php-di/php-di": ">= 6",
"psr/log": "^1 || ^2 || ^3",
Expand Down Expand Up @@ -72,4 +72,4 @@
"pestphp/pest-plugin": true
}
}
}
}
19 changes: 0 additions & 19 deletions config/pdk-services.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

declare(strict_types=1);

use MyParcelNL\Pdk\Account\Contract\AccountRepositoryInterface;
use MyParcelNL\Pdk\Account\Contract\AccountSettingsServiceInterface;
use MyParcelNL\Pdk\Account\Service\AccountSettingsService;
use MyParcelNL\Pdk\Api\Contract\ApiServiceInterface;
use MyParcelNL\Pdk\Api\Service\MyParcelApiService;
use MyParcelNL\Pdk\App\Account\Contract\PdkAccountRepositoryInterface;
use MyParcelNL\Pdk\App\Api\Contract\PdkActionsServiceInterface;
use MyParcelNL\Pdk\App\Api\Service\PdkActionsService;
use MyParcelNL\Pdk\App\Cart\Contract\CartCalculationServiceInterface;
Expand Down Expand Up @@ -52,9 +50,7 @@
use MyParcelNL\Pdk\Notification\Service\NotificationService;
use MyParcelNL\Pdk\Platform\PlatformManager;
use MyParcelNL\Pdk\Platform\PlatformManagerInterface;
use MyParcelNL\Pdk\Settings\Contract\PdkSettingsRepositoryInterface;
use MyParcelNL\Pdk\Settings\Contract\SettingsManagerInterface;
use MyParcelNL\Pdk\Settings\Contract\SettingsRepositoryInterface;
use MyParcelNL\Pdk\Settings\SettingsManager;
use MyParcelNL\Pdk\Shipment\Contract\DropOffServiceInterface;
use MyParcelNL\Pdk\Shipment\Service\DropOffService;
Expand All @@ -63,7 +59,6 @@
use MyParcelNL\Pdk\Types\Contract\TriStateServiceInterface;
use MyParcelNL\Pdk\Types\Service\TriStateService;
use function DI\autowire;
use function DI\factory;

/**
* Pre-defined services.
Expand Down Expand Up @@ -189,20 +184,6 @@
*/
TriStateServiceInterface::class => autowire(TriStateService::class),

/**
* @todo remove in v3.0.0
*/
PdkAccountRepositoryInterface::class => factory(function () {
return \MyParcelNL\Pdk\Facade\Pdk::get(AccountRepositoryInterface::class);
}),

/**
* @todo remove in v3.0.0
*/
PdkSettingsRepositoryInterface::class => factory(function () {
return \MyParcelNL\Pdk\Facade\Pdk::get(SettingsRepositoryInterface::class);
}),

/**
* Handles executing pdk actions.
*/
Expand Down
15 changes: 2 additions & 13 deletions config/pdk-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
use MyParcelNL\Pdk\Language\Contract\LanguageServiceInterface;
use MyParcelNL\Pdk\Logger\Contract\PdkLoggerInterface;
use MyParcelNL\Pdk\Settings\Contract\PdkSettingsRepositoryInterface;
use Psr\Log\LoggerInterface;
use function DI\autowire;
use function DI\get;
use function DI\value;

/**
Expand Down Expand Up @@ -137,18 +135,9 @@
/**
* Handles logging.
*
* @see \MyParcelNL\Pdk\Logger\AbstractLogger
* @deprecated Will be removed in v3.0.0. Use PdkLoggerInterface instead.
* @see \MyParcelNL\Pdk\Logger\AbstractLogger
*/

LoggerInterface::class => autowire(),

/**
* Handles logging.
*
* @see \MyParcelNL\Pdk\Logger\AbstractLogger
*/
PdkLoggerInterface::class => get(LoggerInterface::class),
PdkLoggerInterface::class => autowire(),

/**
* Exposes frontend api url and endpoints.
Expand Down
31 changes: 11 additions & 20 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,67 @@

$ignoreErrors = [];
$ignoreErrors[] = [
// identifier: isset.offset
'message' => '#^Offset \'date\' on array\\{date\\: string, timezone\\: string, timezone_type\\: int\\} in isset\\(\\) always exists and is not nullable\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Base/Model/Model.php',
];
$ignoreErrors[] = [
// identifier: return.phpDocType
'message' => '#^PHPDoc tag @return with type void is incompatible with native type string\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Base/Model/Model.php',
];
$ignoreErrors[] = [
// identifier: assign.propertyType
'message' => '#^Static property MyParcelNL\\\\Pdk\\\\Base\\\\PdkBootstrapper\\:\\:\\$pdk \\(MyParcelNL\\\\Pdk\\\\Base\\\\Pdk\\) does not accept MyParcelNL\\\\Pdk\\\\Base\\\\Concern\\\\PdkInterface\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Base/PdkBootstrapper.php',
];
$ignoreErrors[] = [
// identifier: booleanNot.alwaysTrue
'message' => '#^Negated boolean expression is always true\\.$#',
'count' => 2,
'path' => __DIR__ . '/src/Base/Service/CurrencyService.php',
];
$ignoreErrors[] = [
'message' => '#^Negated boolean expression is always false\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Base/Support/Arr.php',
];
$ignoreErrors[] = [
'message' => '#^PHPDoc tag @mixin contains invalid type MyParcelNL\\\\Pdk\\\\Carrier\\\\Concern\\\\HasDeprecatedSubscriptionId\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Carrier/Model/Carrier.php',
];
$ignoreErrors[] = [
// identifier: return.phpDocType
'message' => '#^PHPDoc tag @return with type void is incompatible with native type MyParcelNL\\\\Pdk\\\\Settings\\\\Model\\\\Settings\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Settings/Repository/AbstractPdkSettingsRepository.php',
];
$ignoreErrors[] = [
// identifier: varTag.differentVariable
'message' => '#^Variable \\$existing in PHPDoc tag @var does not match assigned variable \\$id\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Settings/Repository/AbstractPdkSettingsRepository.php',
];
$ignoreErrors[] = [
// identifier: return.phpDocType
'message' => '#^PHPDoc tag @return with type void is incompatible with native type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Shipment/Collection/ShipmentCollection.php',
];
$ignoreErrors[] = [
// identifier: method.notFound
'message' => '#^Call to an undefined method MyParcelNL\\\\Pdk\\\\Api\\\\Contract\\\\ApiServiceInterface\\:\\:getBaseUrl\\(\\)\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Shipment/Repository/ShipmentRepository.php',
];
$ignoreErrors[] = [
// identifier: return.phpDocType
'message' => '#^PHPDoc tag @return with type MyParcelNL\\\\Pdk\\\\Shipment\\\\Collection\\\\ShipmentCollection is incompatible with native type string\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Shipment/Repository/ShipmentRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Property MyParcelNL\\\\Pdk\\\\Shipment\\\\Request\\\\FetchShipmentsRequest\\:\\:\\$ids \\(MyParcelNL\\\\Pdk\\\\Base\\\\Support\\\\Collection\\) does not accept MyParcelNL\\\\Sdk\\\\src\\\\Support\\\\Collection\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Shipment/Request/FetchShipmentsRequest.php',
];
$ignoreErrors[] = [
'message' => '#^Property MyParcelNL\\\\Pdk\\\\Shipment\\\\Request\\\\FetchShipmentsRequest\\:\\:\\$referenceIdentifiers \\(MyParcelNL\\\\Pdk\\\\Base\\\\Support\\\\Collection\\) does not accept MyParcelNL\\\\Sdk\\\\src\\\\Support\\\\Collection\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Shipment/Request/FetchShipmentsRequest.php',
];
$ignoreErrors[] = [
// identifier: nullCoalesce.offset
'message' => '#^Offset \'positions\' on array\\{string, string\\} on left side of \\?\\? does not exist\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Shipment/Request/GetLabelsRequest.php',
];
$ignoreErrors[] = [
// identifier: method.notFound
'message' => '#^Call to an undefined method DateTimeInterface\\:\\:modify\\(\\)\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Shipment/Service/DropOffService.php',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use MyParcelNL\Pdk\Console\Types\Shared\Model\ClassDefinition;
use MyParcelNL\Pdk\Console\Types\Shared\Model\ClassProperty;
use MyParcelNL\Pdk\Tests\Factory\FactoryFactory;
use MyParcelNL\Sdk\src\Support\Str;
use MyParcelNL\Pdk\Base\Support\Str;
use Throwable;

final class ModelFactoryGeneratorService extends AbstractFactoryGeneratorService
Expand Down
2 changes: 1 addition & 1 deletion private/PhpLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use MyParcelNL\Pdk\Console\Types\Shared\Concern\ReportsTiming;
use MyParcelNL\Pdk\Console\Types\Shared\Service\ParsesPhpDocs;
use MyParcelNL\Pdk\Facade\Pdk;
use MyParcelNL\Sdk\src\Support\Str;
use MyParcelNL\Pdk\Base\Support\Str;
use Nette\Loaders\RobotLoader;

final class PhpLoader
Expand Down
2 changes: 1 addition & 1 deletion private/Types/Documentation/DocumentationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use MyParcelNL\Pdk\Console\Types\Shared\AbstractHelperGenerator;
use MyParcelNL\Pdk\Console\Types\Shared\Model\ClassDefinition;
use MyParcelNL\Pdk\Console\Types\Shared\Model\KeyValue;
use MyParcelNL\Sdk\src\Support\Str;
use MyParcelNL\Pdk\Base\Support\Str;
use ReflectionClass;

final class DocumentationGenerator extends AbstractHelperGenerator
Expand Down
2 changes: 1 addition & 1 deletion private/Types/Php/IdeHelperGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use MyParcelNL\Pdk\Console\Types\Shared\Model\KeyValue;
use MyParcelNL\Pdk\Console\Types\Shared\Service\PhpTypeParser;
use MyParcelNL\Pdk\Facade\Pdk;
use MyParcelNL\Sdk\src\Support\Str;
use MyParcelNL\Pdk\Base\Support\Str;
use Symfony\Component\PropertyInfo\Type;

final class IdeHelperGenerator extends AbstractHelperGenerator
Expand Down
3 changes: 1 addition & 2 deletions private/Types/Shared/Concern/UsesCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
use MyParcelNL\Pdk\Console\Storage\ConsoleMemoryCacheStorage;
use MyParcelNL\Pdk\Console\Storage\Contract\ConsoleStorageInterface;
use MyParcelNL\Pdk\Facade\Pdk;
use MyParcelNL\Sdk\src\Support\Str;
use function sprintf;
use MyParcelNL\Pdk\Base\Support\Str;

trait UsesCache
{
Expand Down
3 changes: 1 addition & 2 deletions private/Types/Shared/Service/PhpSourceParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
use MyParcelNL\Pdk\Console\Types\Shared\Concern\ReportsTiming;
use MyParcelNL\Pdk\Console\Types\Shared\Model\ClassDefinition;
use MyParcelNL\Pdk\Console\Types\Shared\Model\KeyValue;
use MyParcelNL\Sdk\src\Support\Str;
use MyParcelNL\Pdk\Base\Support\Str;
use ReflectionClass;
use ReflectionMethod;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use function array_map;

final class PhpSourceParser
{
Expand Down
2 changes: 1 addition & 1 deletion private/Types/Shared/Service/PhpTypeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use MyParcelNL\Pdk\Base\Support\Arr;
use MyParcelNL\Pdk\Base\Support\Collection;
use MyParcelNL\Pdk\Base\Support\Utils;
use MyParcelNL\Sdk\src\Support\Str;
use MyParcelNL\Pdk\Base\Support\Str;
use Symfony\Component\PropertyInfo\Type;

class PhpTypeParser
Expand Down
2 changes: 1 addition & 1 deletion private/Types/TypeScript/TsTypeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use DateTimeImmutable;
use MyParcelNL\Pdk\Base\Support\Arr;
use MyParcelNL\Pdk\Console\Types\Shared\Concern\UsesCache;
use MyParcelNL\Sdk\src\Support\Str;
use MyParcelNL\Pdk\Base\Support\Str;

class TsTypeParser
{
Expand Down
15 changes: 0 additions & 15 deletions src/Account/Contract/AccountRepositoryInterface.php

This file was deleted.

28 changes: 0 additions & 28 deletions src/Account/Model/Shop.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use MyParcelNL\Pdk\Account\Collection\ShopCarrierConfigurationCollection;
use MyParcelNL\Pdk\Base\Contract\Arrayable;
use MyParcelNL\Pdk\Base\Model\Model;
use MyParcelNL\Pdk\Base\Support\Arr;
use MyParcelNL\Pdk\Base\Support\Collection;
use MyParcelNL\Pdk\Carrier\Collection\CarrierCollection;
use MyParcelNL\Pdk\Carrier\Model\Carrier;
Expand All @@ -29,8 +28,6 @@
*/
class Shop extends Model
{
private const DEPRECATED_KEY_CARRIER_OPTIONS = 'carrierOptions';

public $attributes = [
'id' => null,
'accountId' => null,
Expand Down Expand Up @@ -63,31 +60,6 @@ class Shop extends Model
'carrierConfigurations' => ShopCarrierConfigurationCollection::class,
];

protected $deprecated = [
self::DEPRECATED_KEY_CARRIER_OPTIONS => 'carriers',
];

/**
* @param null|array $data
*/
public function __construct(?array $data = null)
{
if (isset($data[self::DEPRECATED_KEY_CARRIER_OPTIONS])) {
$data['carriers'] = array_map(
static function (array $carrierOptions): array {
$rest = Arr::except($carrierOptions, ['carrier']);

return array_merge($rest, $carrierOptions['carrier'] ?? null);
},
$data[self::DEPRECATED_KEY_CARRIER_OPTIONS]
);

unset($data[self::DEPRECATED_KEY_CARRIER_OPTIONS]);
}

parent::__construct($data);
}

/**
* @return array
*/
Expand Down
14 changes: 0 additions & 14 deletions src/Account/Repository/AbstractAccountRepository.php

This file was deleted.

44 changes: 44 additions & 0 deletions src/Api/Concern/DecodesAddressFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace MyParcelNL\Pdk\Api\Concern;

use MyParcelNL\Pdk\Base\Support\Utils;

trait DecodesAddressFields
{
/**
* @param null|array $input
*
* @return null|array
*/
protected function decodeAddress(?array $input): ?array
{
$data = Utils::changeArrayKeysCase($this->filter($input) ?? []);

if (isset($data['street']) || isset($data['number'])) {
$data['address1'] = trim(
implode(' ', [
$data['street'],
$data['number'],
$data['numberSuffix'] ?? $data['boxNumber'] ?? '',
])
);

unset($data['street'], $data['number'], $data['numberSuffix'], $data['boxNumber']);
}

return $data;
}

/**
* @param null|array $item
*
* @return null|array
*/
protected function filter(?array $item): ?array
{
return array_filter($item ?? []) ?: null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use MyParcelNL\Pdk\Webhook\Collection\WebhookSubscriptionCollection;
use MyParcelNL\Pdk\Webhook\Model\WebhookSubscription;
use MyParcelNL\Pdk\Webhook\Repository\WebhookSubscriptionRepository;
use MyParcelNL\Sdk\src\Support\Str;
use MyParcelNL\Pdk\Base\Support\Str;

abstract class AbstractWebhooksAction implements ActionInterface
{
Expand Down
Loading
Loading