diff --git a/.github/workflows/code_samples.yaml b/.github/workflows/code_samples.yaml index 4721bce9f9..138326cc59 100644 --- a/.github/workflows/code_samples.yaml +++ b/.github/workflows/code_samples.yaml @@ -38,6 +38,9 @@ jobs: - name: Run PHPStan analysis run: composer phpstan + - name: Run rector + run: vendor/bin/rector process --dry-run --ansi + code-samples-inclusion-check: name: Check code samples inclusion runs-on: ubuntu-latest diff --git a/code_samples/ai_actions/src/AI/Action/TranscribeAudioAction.php b/code_samples/ai_actions/src/AI/Action/TranscribeAudioAction.php index 49663f2bb3..6ab3027e0f 100644 --- a/code_samples/ai_actions/src/AI/Action/TranscribeAudioAction.php +++ b/code_samples/ai_actions/src/AI/Action/TranscribeAudioAction.php @@ -9,11 +9,8 @@ final class TranscribeAudioAction extends Action { - private Audio $audio; - - public function __construct(Audio $audio) + public function __construct(private readonly Audio $audio) { - $this->audio = $audio; } public function getParameters(): array diff --git a/code_samples/ai_actions/src/AI/ActionType/TranscribeAudioActionType.php b/code_samples/ai_actions/src/AI/ActionType/TranscribeAudioActionType.php index e77e9efb45..d6b4b87f48 100644 --- a/code_samples/ai_actions/src/AI/ActionType/TranscribeAudioActionType.php +++ b/code_samples/ai_actions/src/AI/ActionType/TranscribeAudioActionType.php @@ -12,17 +12,13 @@ use Ibexa\Contracts\ConnectorAi\DataType; use Ibexa\Contracts\Core\Exception\InvalidArgumentException; -final class TranscribeAudioActionType implements ActionTypeInterface +final readonly class TranscribeAudioActionType implements ActionTypeInterface { - public const IDENTIFIER = 'transcribe_audio'; - - /** @var iterable<\Ibexa\Contracts\ConnectorAi\Action\ActionHandlerInterface> */ - private iterable $actionHandlers; + public const string IDENTIFIER = 'transcribe_audio'; /** @param iterable<\Ibexa\Contracts\ConnectorAi\Action\ActionHandlerInterface> $actionHandlers*/ - public function __construct(iterable $actionHandlers) + public function __construct(private iterable $actionHandlers) { - $this->actionHandlers = $actionHandlers; } public function getIdentifier(): string diff --git a/code_samples/ai_actions/src/AI/DataType/Audio.php b/code_samples/ai_actions/src/AI/DataType/Audio.php index 8f9f0f9475..bea562a1c9 100644 --- a/code_samples/ai_actions/src/AI/DataType/Audio.php +++ b/code_samples/ai_actions/src/AI/DataType/Audio.php @@ -11,15 +11,11 @@ */ final class Audio implements DataType { - /** @var non-empty-array */ - private array $base64; - /** * @param non-empty-array $base64 */ - public function __construct(array $base64) + public function __construct(private array $base64) { - $this->base64 = $base64; } public function getBase64(): string diff --git a/code_samples/ai_actions/src/AI/Handler/LLaVaTextToTextActionHandler.php b/code_samples/ai_actions/src/AI/Handler/LLaVaTextToTextActionHandler.php index 71ed36cda0..547a00aa72 100644 --- a/code_samples/ai_actions/src/AI/Handler/LLaVaTextToTextActionHandler.php +++ b/code_samples/ai_actions/src/AI/Handler/LLaVaTextToTextActionHandler.php @@ -12,18 +12,14 @@ use Ibexa\Contracts\ConnectorAi\ActionResponseInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; -final class LLaVaTextToTextActionHandler implements ActionHandlerInterface +final readonly class LLaVaTextToTextActionHandler implements ActionHandlerInterface { - private HttpClientInterface $client; + public const string IDENTIFIER = 'LLaVATextToText'; - private string $host; - - public const IDENTIFIER = 'LLaVATextToText'; - - public function __construct(HttpClientInterface $client, string $host = 'http://localhost:8080') - { - $this->client = $client; - $this->host = $host; + public function __construct( + private HttpClientInterface $client, + private string $host = 'http://localhost:8080' + ) { } public function supports(ActionInterface $action): bool @@ -63,7 +59,7 @@ public function handle(ActionInterface $action, array $context = []): ActionResp ] ); - $output = strip_tags(json_decode($response->getContent(), true)['choices'][0]['message']['content']); + $output = strip_tags((string) json_decode($response->getContent(), true)['choices'][0]['message']['content']); return new TextResponse(new Text([$output])); } diff --git a/code_samples/ai_actions/src/AI/Handler/WhisperAudioToTextActionHandler.php b/code_samples/ai_actions/src/AI/Handler/WhisperAudioToTextActionHandler.php index 1c253249ce..583f75fa54 100644 --- a/code_samples/ai_actions/src/AI/Handler/WhisperAudioToTextActionHandler.php +++ b/code_samples/ai_actions/src/AI/Handler/WhisperAudioToTextActionHandler.php @@ -15,7 +15,7 @@ final class WhisperAudioToTextActionHandler implements ActionHandlerInterface { - private const TIMESTAMP_FORMAT = '/^\[\d{2}:\d{2}\.\d{3} --> \d{2}:\d{2}\.\d{3}]\s*/'; + private const string TIMESTAMP_FORMAT = '/^\[\d{2}:\d{2}\.\d{3} --> \d{2}:\d{2}\.\d{3}]\s*/'; public function supports(ActionInterface $action): bool { @@ -33,7 +33,7 @@ public function handle(ActionInterface $action, array $context = []): ActionResp $language = $action->getRuntimeContext()?->get('languageCode'); if ($language !== null) { - $arguments[] = sprintf('--language=%s', substr($language, 0, 2)); + $arguments[] = sprintf('--language=%s', substr((string) $language, 0, 2)); } $arguments[] = '--output_format=txt'; @@ -72,9 +72,7 @@ private function removeTimestamps(string $text): string { $lines = explode(PHP_EOL, $text); - $processedLines = array_map(static function (string $line): string { - return preg_replace(self::TIMESTAMP_FORMAT, '', $line) ?? ''; - }, $lines); + $processedLines = array_map(static fn (string $line): string => preg_replace(self::TIMESTAMP_FORMAT, '', $line) ?? '', $lines); return implode(PHP_EOL, $processedLines); } diff --git a/code_samples/ai_actions/src/AI/REST/Input/Parser/TranscribeAudio.php b/code_samples/ai_actions/src/AI/REST/Input/Parser/TranscribeAudio.php index 0951c9b732..78520a1e4e 100644 --- a/code_samples/ai_actions/src/AI/REST/Input/Parser/TranscribeAudio.php +++ b/code_samples/ai_actions/src/AI/REST/Input/Parser/TranscribeAudio.php @@ -13,8 +13,8 @@ final class TranscribeAudio extends BaseParser { - public const AUDIO_KEY = 'Audio'; - public const BASE64_KEY = 'base64'; + public const string AUDIO_KEY = 'Audio'; + public const string BASE64_KEY = 'base64'; /** @param array $data */ public function parse(array $data, ParsingDispatcher $parsingDispatcher): TranscribeAudioAction diff --git a/code_samples/ai_actions/src/AI/REST/Output/ValueObjectVisitor/AudioText.php b/code_samples/ai_actions/src/AI/REST/Output/ValueObjectVisitor/AudioText.php index 07b2240db0..1c8277f585 100644 --- a/code_samples/ai_actions/src/AI/REST/Output/ValueObjectVisitor/AudioText.php +++ b/code_samples/ai_actions/src/AI/REST/Output/ValueObjectVisitor/AudioText.php @@ -10,8 +10,11 @@ final class AudioText extends ValueObjectVisitor { - private const OBJECT_IDENTIFIER = 'AudioText'; + private const string OBJECT_IDENTIFIER = 'AudioText'; + /** + * @param \App\AI\REST\Value\AudioText $data + */ public function visit(Visitor $visitor, Generator $generator, $data): void { $mediaType = 'ai.' . self::OBJECT_IDENTIFIER; diff --git a/code_samples/ai_actions/src/AI/REST/Value/TranscribeAudioAction.php b/code_samples/ai_actions/src/AI/REST/Value/TranscribeAudioAction.php index 643b32867e..6e33f288a0 100644 --- a/code_samples/ai_actions/src/AI/REST/Value/TranscribeAudioAction.php +++ b/code_samples/ai_actions/src/AI/REST/Value/TranscribeAudioAction.php @@ -7,18 +7,12 @@ use App\AI\DataType\Audio; use Ibexa\Contracts\ConnectorAi\Action\RuntimeContext; -final class TranscribeAudioAction +final readonly class TranscribeAudioAction { - private Audio $input; - - private RuntimeContext $runtimeContext; - public function __construct( - Audio $input, - RuntimeContext $runtimeContext + private Audio $input, + private RuntimeContext $runtimeContext ) { - $this->input = $input; - $this->runtimeContext = $runtimeContext; } public function getInput(): Audio diff --git a/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php b/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php index cb7ce9bc29..0c6ef19854 100644 --- a/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php +++ b/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php @@ -24,29 +24,13 @@ )] final class ActionConfigurationCreateCommand extends Command { - private ActionConfigurationServiceInterface $actionConfigurationService; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private ActionServiceInterface $actionService; - - private ActionTypeRegistryInterface $actionTypeRegistry; - public function __construct( - ActionConfigurationServiceInterface $actionConfigurationService, - PermissionResolver $permissionResolver, - UserService $userService, - ActionServiceInterface $actionService, - ActionTypeRegistryInterface $actionTypeRegistry + private readonly ActionConfigurationServiceInterface $actionConfigurationService, + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly ActionServiceInterface $actionService, + private readonly ActionTypeRegistryInterface $actionTypeRegistry ) { - $this->actionConfigurationService = $actionConfigurationService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->actionService = $actionService; - $this->actionTypeRegistry = $actionTypeRegistry; - parent::__construct(); } diff --git a/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php b/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php index 5084b61d4e..dee23735e9 100644 --- a/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php +++ b/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php @@ -33,35 +33,16 @@ )] final class AddMissingAltTextCommand extends Command { - private const IMAGE_FIELD_IDENTIFIER = 'image'; - - private ContentService $contentService; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private FieldTypeService $fieldTypeService; - - private ActionServiceInterface $actionService; - - private IOBinarydataHandler $binaryDataHandler; + private const string IMAGE_FIELD_IDENTIFIER = 'image'; public function __construct( - ContentService $contentService, - PermissionResolver $permissionResolver, - UserService $userService, - FieldTypeService $fieldTypeService, - ActionServiceInterface $actionService, - IOBinarydataHandler $binaryDataHandler + private readonly ContentService $contentService, + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly FieldTypeService $fieldTypeService, + private readonly ActionServiceInterface $actionService, + private readonly IOBinarydataHandler $binaryDataHandler ) { - $this->contentService = $contentService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->fieldTypeService = $fieldTypeService; - $this->actionService = $actionService; - $this->binaryDataHandler = $binaryDataHandler; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Command/CartCommand.php b/code_samples/api/commerce/src/Command/CartCommand.php index aedfb50589..d44e01be36 100644 --- a/code_samples/api/commerce/src/Command/CartCommand.php +++ b/code_samples/api/commerce/src/Command/CartCommand.php @@ -27,41 +27,16 @@ )] final class CartCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private CartServiceInterface $cartService; - - private CurrencyServiceInterface $currencyService; - - private ProductServiceInterface $productService; - - private OrderServiceInterface $orderService; - - private ReorderService $reorderService; - - private CartResolverInterface $cartResolver; - public function __construct( - PermissionResolver $permissionResolver, - UserService $userService, - CartServiceInterface $cartService, - CurrencyServiceInterface $currencyService, - ProductServiceInterface $productService, - OrderServiceInterface $orderService, - ReorderService $reorderService, - CartResolverInterface $cartResolver + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly CartServiceInterface $cartService, + private readonly CurrencyServiceInterface $currencyService, + private readonly ProductServiceInterface $productService, + private readonly OrderServiceInterface $orderService, + private readonly ReorderService $reorderService, + private readonly CartResolverInterface $cartResolver ) { - $this->cartService = $cartService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->currencyService = $currencyService; - $this->productService = $productService; - $this->orderService = $orderService; - $this->reorderService = $reorderService; - $this->cartResolver = $cartResolver; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Command/OrderCommand.php b/code_samples/api/commerce/src/Command/OrderCommand.php index 904ff231ee..44b24caef5 100644 --- a/code_samples/api/commerce/src/Command/OrderCommand.php +++ b/code_samples/api/commerce/src/Command/OrderCommand.php @@ -31,21 +31,11 @@ )] final class OrderCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private OrderServiceInterface $orderService; - public function __construct( - PermissionResolver $permissionResolver, - UserService $userService, - OrderServiceInterface $orderService + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly OrderServiceInterface $orderService ) { - $this->orderService = $orderService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Command/PaymentCommand.php b/code_samples/api/commerce/src/Command/PaymentCommand.php index d7f98eeb6e..c2ffc98488 100644 --- a/code_samples/api/commerce/src/Command/PaymentCommand.php +++ b/code_samples/api/commerce/src/Command/PaymentCommand.php @@ -26,29 +26,13 @@ )] final class PaymentCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private PaymentServiceInterface $paymentService; - - private OrderServiceInterface $orderService; - - private PaymentMethodServiceInterface $paymentMethodService; - public function __construct( - PermissionResolver $permissionResolver, - UserService $userService, - PaymentServiceInterface $paymentService, - OrderServiceInterface $orderService, - PaymentMethodServiceInterface $paymentMethodService, + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly PaymentServiceInterface $paymentService, + private readonly OrderServiceInterface $orderService, + private readonly PaymentMethodServiceInterface $paymentMethodService, ) { - $this->paymentService = $paymentService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->orderService = $orderService; - $this->paymentMethodService = $paymentMethodService; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Command/PaymentMethodCommand.php b/code_samples/api/commerce/src/Command/PaymentMethodCommand.php index 0d26d03de0..4f4d6054e7 100644 --- a/code_samples/api/commerce/src/Command/PaymentMethodCommand.php +++ b/code_samples/api/commerce/src/Command/PaymentMethodCommand.php @@ -24,21 +24,11 @@ )] final class PaymentMethodCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private PaymentMethodServiceInterface $paymentMethodService; - public function __construct( - PermissionResolver $permissionResolver, - UserService $userService, - PaymentMethodServiceInterface $paymentMethodService + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly PaymentMethodServiceInterface $paymentMethodService ) { - $this->paymentMethodService = $paymentMethodService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Command/ShipmentCommand.php b/code_samples/api/commerce/src/Command/ShipmentCommand.php index 35dbfe7dfc..6dc246ee3e 100644 --- a/code_samples/api/commerce/src/Command/ShipmentCommand.php +++ b/code_samples/api/commerce/src/Command/ShipmentCommand.php @@ -27,29 +27,13 @@ )] final class ShipmentCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private ShipmentServiceInterface $shipmentService; - - private ShippingMethodServiceInterface $shippingMethodService; - - private OrderServiceInterface $orderService; - public function __construct( - PermissionResolver $permissionResolver, - UserService $userService, - ShipmentServiceInterface $shipmentService, - ShippingMethodServiceInterface $shippingMethodService, - OrderServiceInterface $orderService + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly ShipmentServiceInterface $shipmentService, + private readonly ShippingMethodServiceInterface $shippingMethodService, + private readonly OrderServiceInterface $orderService ) { - $this->shipmentService = $shipmentService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->shippingMethodService = $shippingMethodService; - $this->orderService = $orderService; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Command/ShippingMethodCommand.php b/code_samples/api/commerce/src/Command/ShippingMethodCommand.php index 23f25286f9..85368142f8 100644 --- a/code_samples/api/commerce/src/Command/ShippingMethodCommand.php +++ b/code_samples/api/commerce/src/Command/ShippingMethodCommand.php @@ -23,25 +23,12 @@ )] final class ShippingMethodCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private ShippingMethodServiceInterface $shippingMethodService; - - private RegionServiceInterface $regionService; - public function __construct( - PermissionResolver $permissionResolver, - UserService $userService, - ShippingMethodServiceInterface $shippingMethodService, - RegionServiceInterface $regionService + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly ShippingMethodServiceInterface $shippingMethodService, + private readonly RegionServiceInterface $regionService ) { - $this->shippingMethodService = $shippingMethodService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->regionService = $regionService; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Controller/CustomCheckoutController.php b/code_samples/api/commerce/src/Controller/CustomCheckoutController.php index 79ec15a75c..6dead11eb5 100644 --- a/code_samples/api/commerce/src/Controller/CustomCheckoutController.php +++ b/code_samples/api/commerce/src/Controller/CustomCheckoutController.php @@ -11,14 +11,10 @@ class CustomCheckoutController extends Controller { - private CartServiceInterface $cartService; - - private CheckoutServiceInterface $checkoutService; - - public function __construct(CartServiceInterface $cartService, CheckoutServiceInterface $checkoutService) - { - $this->cartService = $cartService; - $this->checkoutService = $checkoutService; + public function __construct( + private readonly CartServiceInterface $cartService, + private readonly CheckoutServiceInterface $checkoutService + ) { } public function showContentAction(): Response diff --git a/code_samples/api/migration/src/Command/MigrationCommand.php b/code_samples/api/migration/src/Command/MigrationCommand.php index 862170007a..df0bf887b5 100644 --- a/code_samples/api/migration/src/Command/MigrationCommand.php +++ b/code_samples/api/migration/src/Command/MigrationCommand.php @@ -14,12 +14,8 @@ )] final class MigrationCommand extends Command { - private MigrationService $migrationService; - - public function __construct(MigrationService $migrationService) + public function __construct(private readonly MigrationService $migrationService) { - $this->migrationService = $migrationService; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/AttributeCommand.php b/code_samples/api/product_catalog/src/Command/AttributeCommand.php index 609238328d..ee4d97b659 100644 --- a/code_samples/api/product_catalog/src/Command/AttributeCommand.php +++ b/code_samples/api/product_catalog/src/Command/AttributeCommand.php @@ -19,37 +19,15 @@ )] final class AttributeCommand extends Command { - private AttributeGroupServiceInterface $attributeGroupService; - - private LocalAttributeGroupServiceInterface $localAttributeGroupService; - - private AttributeDefinitionServiceInterface $attributeDefinitionService; - - private LocalAttributeDefinitionServiceInterface $localAttributeDefinitionService; - - private AttributeTypeServiceInterface $attributeTypeService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - public function __construct( - LocalAttributeDefinitionServiceInterface $localAttributeDefinitionService, - AttributeDefinitionServiceInterface $attributeDefinitionService, - AttributeGroupServiceInterface $attributeGroupService, - LocalAttributeGroupServiceInterface $localAttributeGroupService, - AttributeTypeServiceInterface $attributeTypeService, - UserService $userService, - PermissionResolver $permissionResolver + private readonly LocalAttributeDefinitionServiceInterface $localAttributeDefinitionService, + private readonly AttributeDefinitionServiceInterface $attributeDefinitionService, + private readonly AttributeGroupServiceInterface $attributeGroupService, + private readonly LocalAttributeGroupServiceInterface $localAttributeGroupService, + private readonly AttributeTypeServiceInterface $attributeTypeService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver ) { - $this->localAttributeGroupService = $localAttributeGroupService; - $this->attributeGroupService = $attributeGroupService; - $this->attributeTypeService = $attributeTypeService; - $this->attributeDefinitionService = $attributeDefinitionService; - $this->localAttributeDefinitionService = $localAttributeDefinitionService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/CatalogCommand.php b/code_samples/api/product_catalog/src/Command/CatalogCommand.php index 800aa3deae..eef9eb1d62 100644 --- a/code_samples/api/product_catalog/src/Command/CatalogCommand.php +++ b/code_samples/api/product_catalog/src/Command/CatalogCommand.php @@ -24,25 +24,12 @@ )] final class CatalogCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private ProductServiceInterface $productService; - - private CatalogServiceInterface $catalogService; - public function __construct( - UserService $userService, - PermissionResolver $permissionResolver, - ProductServiceInterface $productService, - CatalogServiceInterface $catalogService + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly ProductServiceInterface $productService, + private readonly CatalogServiceInterface $catalogService ) { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->productService = $productService; - $this->catalogService = $catalogService; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/CurrencyCommand.php b/code_samples/api/product_catalog/src/Command/CurrencyCommand.php index 04f11d6d49..8162fadede 100644 --- a/code_samples/api/product_catalog/src/Command/CurrencyCommand.php +++ b/code_samples/api/product_catalog/src/Command/CurrencyCommand.php @@ -18,18 +18,11 @@ )] final class CurrencyCommand extends Command { - private CurrencyServiceInterface $currencyService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(CurrencyServiceInterface $currencyService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->currencyService = $currencyService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly CurrencyServiceInterface $currencyService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php b/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php index 7d67874e29..aa9ed43d9e 100644 --- a/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php @@ -19,25 +19,12 @@ )] final class ProductAssetCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private ProductServiceInterface $productService; - - private AssetServiceInterface $assetService; - public function __construct( - UserService $userService, - PermissionResolver $permissionResolver, - ProductServiceInterface $productService, - AssetServiceInterface $assetService + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly ProductServiceInterface $productService, + private readonly AssetServiceInterface $assetService ) { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->productService = $productService; - $this->assetService = $assetService; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/ProductCommand.php b/code_samples/api/product_catalog/src/Command/ProductCommand.php index d58a537f89..a231d9ddd0 100644 --- a/code_samples/api/product_catalog/src/Command/ProductCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductCommand.php @@ -24,33 +24,14 @@ )] final class ProductCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private ProductTypeServiceInterface $productTypeService; - - private ProductServiceInterface $productService; - - private LocalProductServiceInterface $localProductService; - - private ProductAvailabilityServiceInterface $productAvailabilityService; - public function __construct( - UserService $userService, - PermissionResolver $permissionResolver, - ProductTypeServiceInterface $productTypeService, - ProductServiceInterface $productService, - LocalProductServiceInterface $localProductService, - ProductAvailabilityServiceInterface $productAvailabilityService + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly ProductTypeServiceInterface $productTypeService, + private readonly ProductServiceInterface $productService, + private readonly LocalProductServiceInterface $localProductService, + private readonly ProductAvailabilityServiceInterface $productAvailabilityService ) { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->productService = $productService; - $this->productTypeService = $productTypeService; - $this->localProductService = $localProductService; - $this->productAvailabilityService = $productAvailabilityService; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php b/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php index ce874bfe77..0a3c40ecbb 100644 --- a/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php @@ -27,33 +27,14 @@ )] final class ProductPriceCommand extends Command { - private ProductPriceServiceInterface $productPriceService; - - private PriceResolverInterface $priceResolver; - - private ProductServiceInterface $productService; - - private CurrencyServiceInterface $currencyService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - public function __construct( - CurrencyServiceInterface $currencyService, - ProductServiceInterface $productService, - ProductPriceServiceInterface $productPriceService, - PriceResolverInterface $priceResolver, - UserService $userService, - PermissionResolver $permissionResolver + private readonly CurrencyServiceInterface $currencyService, + private readonly ProductServiceInterface $productService, + private readonly ProductPriceServiceInterface $productPriceService, + private readonly PriceResolverInterface $priceResolver, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver ) { - $this->currencyService = $currencyService; - $this->productPriceService = $productPriceService; - $this->priceResolver = $priceResolver; - $this->productService = $productService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php b/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php index 71af92cf14..467658e78c 100644 --- a/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php @@ -16,18 +16,11 @@ )] final class ProductTypeCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private ProductTypeServiceInterface $productTypeService; - - public function __construct(UserService $userService, PermissionResolver $permissionResolver, ProductTypeServiceInterface $productTypeService) - { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->productTypeService = $productTypeService; - + public function __construct( + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly ProductTypeServiceInterface $productTypeService + ) { parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php b/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php index 6d7bcf789a..3b685a7fc4 100644 --- a/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php @@ -21,25 +21,12 @@ )] final class ProductVariantCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private ProductServiceInterface $productService; - - private LocalProductServiceInterface $localProductService; - public function __construct( - UserService $userService, - PermissionResolver $permissionResolver, - ProductServiceInterface $productService, - LocalProductServiceInterface $localProductService + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly ProductServiceInterface $productService, + private readonly LocalProductServiceInterface $localProductService ) { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->productService = $productService; - $this->localProductService = $localProductService; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/VatCommand.php b/code_samples/api/product_catalog/src/Command/VatCommand.php index 8cd7bd265b..fc5ee046c6 100644 --- a/code_samples/api/product_catalog/src/Command/VatCommand.php +++ b/code_samples/api/product_catalog/src/Command/VatCommand.php @@ -17,25 +17,12 @@ )] final class VatCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private VatServiceInterface $vatService; - - private RegionServiceInterface $regionService; - public function __construct( - UserService $userService, - PermissionResolver $permissionResolver, - VatServiceInterface $vatService, - RegionServiceInterface $regionService + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly VatServiceInterface $vatService, + private readonly RegionServiceInterface $regionService ) { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->vatService = $vatService; - $this->regionService = $regionService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php b/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php index 3025e68e4f..94f045dbb8 100644 --- a/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php +++ b/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php @@ -11,30 +11,19 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:add_language' + name: 'doc:add_language', + description: 'Lists available languages and add Polish.' )] class AddLanguageCommand extends Command { - private LanguageService $languageService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(LanguageService $languageService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->languageService = $languageService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly LanguageService $languageService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } - protected function configure(): void - { - $this->setDescription('Lists available languages and add Polish.'); - } - protected function execute(InputInterface $input, OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); diff --git a/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php b/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php index 6d7d99c498..4b5d4728f5 100644 --- a/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php @@ -13,32 +13,23 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:add_location' + name: 'doc:add_location', + description: 'Add a Location to content item and hides it.' )] class AddLocationToContentCommand extends Command { - private ContentService $contentService; - - private LocationService $locationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, LocationService $locationService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->contentService = $contentService; - $this->locationService = $locationService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly ContentService $contentService, + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } protected function configure(): void { $this - ->setDescription('Add a Location to content item and hides it.') ->setDefinition([ new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), new InputArgument('parentLocationId', InputArgument::REQUIRED, 'Parent Location ID'), diff --git a/code_samples/api/public_php_api/src/Command/BookmarkCommand.php b/code_samples/api/public_php_api/src/Command/BookmarkCommand.php index 072185599a..4032f40133 100644 --- a/code_samples/api/public_php_api/src/Command/BookmarkCommand.php +++ b/code_samples/api/public_php_api/src/Command/BookmarkCommand.php @@ -16,15 +16,10 @@ )] class BookmarkCommand extends Command { - private BookmarkService $bookmarkService; - - private LocationService $locationService; - - public function __construct(BookmarkService $bookmarkService, LocationService $locationService) - { - $this->bookmarkService = $bookmarkService; - $this->locationService = $locationService; - + public function __construct( + private readonly BookmarkService $bookmarkService, + private readonly LocationService $locationService + ) { parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php b/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php index b3a39049a3..9f88f6ee9e 100644 --- a/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php +++ b/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php @@ -11,23 +11,19 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:browse_locations' + name: 'doc:browse_locations', + description: 'Lists all descendants of the Location' )] class BrowseLocationsCommand extends Command { - private LocationService $locationService; - - public function __construct(LocationService $locationService) + public function __construct(private readonly LocationService $locationService) { - $this->locationService = $locationService; - parent::__construct(); } protected function configure(): void { $this - ->setDescription('Lists all descendants of the Location') ->setDefinition([ new InputArgument('locationId', InputArgument::REQUIRED, 'Location ID to browse from'), ]); diff --git a/code_samples/api/public_php_api/src/Command/CalendarCommand.php b/code_samples/api/public_php_api/src/Command/CalendarCommand.php index ea46cf7088..174a2fa3e6 100644 --- a/code_samples/api/public_php_api/src/Command/CalendarCommand.php +++ b/code_samples/api/public_php_api/src/Command/CalendarCommand.php @@ -13,28 +13,21 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:calendar' + name: 'doc:calendar', + description: 'Lists Calendar event in the provided time range and reschedules them.' )] class CalendarCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private CalendarServiceInterface $calendarService; - - public function __construct(PermissionResolver $permissionResolver, UserService $userService, CalendarServiceInterface $calendarService) - { - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->calendarService = $calendarService; - + public function __construct( + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly CalendarServiceInterface $calendarService + ) { parent::__construct(); } public function configure(): void { - $this->setDescription('Lists Calendar event in the provided time range and reschedules them.'); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/code_samples/api/public_php_api/src/Command/CreateContentCommand.php b/code_samples/api/public_php_api/src/Command/CreateContentCommand.php index be1ca6db5a..620c0932c6 100644 --- a/code_samples/api/public_php_api/src/Command/CreateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateContentCommand.php @@ -19,24 +19,13 @@ )] class CreateContentCommand extends Command { - private ContentService $contentService; - - private ContentTypeService $contentTypeService; - - private LocationService $locationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, ContentTypeService $contentTypeService, LocationService $locationService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->contentService = $contentService; - $this->contentTypeService = $contentTypeService; - $this->locationService = $locationService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly ContentService $contentService, + private readonly ContentTypeService $contentTypeService, + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php b/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php index 7a86405849..2f9a9b694a 100644 --- a/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php @@ -18,18 +18,11 @@ )] class CreateContentTypeCommand extends Command { - private ContentTypeService $contentTypeService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentTypeService $contentTypeService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->contentTypeService = $contentTypeService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly ContentTypeService $contentTypeService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } @@ -56,7 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int try { $contentTypeGroup = $this->contentTypeService->loadContentTypeGroupByIdentifier($groupIdentifier); - } catch (NotFoundException $e) { + } catch (NotFoundException) { $output->writeln("Content type group with identifier $groupIdentifier not found"); return self::FAILURE; diff --git a/code_samples/api/public_php_api/src/Command/CreateImageCommand.php b/code_samples/api/public_php_api/src/Command/CreateImageCommand.php index 5aae67c0ef..201b1d980b 100644 --- a/code_samples/api/public_php_api/src/Command/CreateImageCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateImageCommand.php @@ -20,24 +20,13 @@ )] class CreateImageCommand extends Command { - private ContentService $contentService; - - private ContentTypeService $contentTypeService; - - private LocationService $locationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, ContentTypeService $contentTypeService, LocationService $locationService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->contentService = $contentService; - $this->contentTypeService = $contentTypeService; - $this->locationService = $locationService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly ContentService $contentService, + private readonly ContentTypeService $contentTypeService, + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } @@ -67,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int [ 'path' => $file, 'fileSize' => filesize($file), - 'fileName' => basename($file), + 'fileName' => basename((string) $file), 'alternativeText' => $name, ] ); diff --git a/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php b/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php index 7aa74ffd89..6c58ceeea6 100644 --- a/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php @@ -16,18 +16,11 @@ )] class DeleteContentCommand extends Command { - private LocationService $locationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(LocationService $locationService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->locationService = $locationService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/FilterCommand.php b/code_samples/api/public_php_api/src/Command/FilterCommand.php index c4f6b26515..09f1afdd35 100644 --- a/code_samples/api/public_php_api/src/Command/FilterCommand.php +++ b/code_samples/api/public_php_api/src/Command/FilterCommand.php @@ -14,22 +14,18 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:filter' + name: 'doc:filter', + description: 'Returns children of the provided Location, sorted by name in descending order.' )] class FilterCommand extends Command { - private ContentService $contentService; - - public function __construct(ContentService $contentService) + public function __construct(private readonly ContentService $contentService) { - $this->contentService = $contentService; - parent::__construct(); } public function configure(): void { - $this->setDescription('Returns children of the provided Location, sorted by name in descending order.'); $this->setDefinition([ new InputArgument('parentLocationId', InputArgument::REQUIRED, 'ID of the parent Location'), ]); diff --git a/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php b/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php index e7f68046fa..f1f05b5b23 100644 --- a/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php @@ -14,22 +14,18 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:filter_location' + name: 'doc:filter_location', + description: 'Returns children of the provided Location, sorted by name in descending order.' )] class FilterLocationCommand extends Command { - private LocationService $locationService; - - public function __construct(LocationService $locationService) + public function __construct(private readonly LocationService $locationService) { - $this->locationService = $locationService; - parent::__construct(); } public function configure(): void { - $this->setDescription('Returns children of the provided Location, sorted by name in descending order.'); $this->setDefinition([ new InputArgument('parentLocationId', InputArgument::REQUIRED, 'ID of the parent Location'), ]); diff --git a/code_samples/api/public_php_api/src/Command/FindComplexCommand.php b/code_samples/api/public_php_api/src/Command/FindComplexCommand.php index fdf2d72cb1..a60e28a59c 100644 --- a/code_samples/api/public_php_api/src/Command/FindComplexCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindComplexCommand.php @@ -14,26 +14,21 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:find_complex' + name: 'doc:find_complex', + description: 'Lists content belonging to the provided content type.' )] class FindComplexCommand extends Command { - private SearchService $searchService; - - private LocationService $locationService; - - public function __construct(SearchService $searchService, LocationService $locationService) - { - $this->searchService = $searchService; - $this->locationService = $locationService; - + public function __construct( + private readonly SearchService $searchService, + private readonly LocationService $locationService + ) { parent::__construct(); } protected function configure(): void { $this - ->setDescription('Lists content belonging to the provided content type.') ->setDefinition([ new InputArgument('locationId', InputArgument::REQUIRED, ''), new InputArgument('contentTypeIdentifier', InputArgument::REQUIRED, 'Content type identifier'), diff --git a/code_samples/api/public_php_api/src/Command/FindContentCommand.php b/code_samples/api/public_php_api/src/Command/FindContentCommand.php index 881a10d87a..ff72d55a46 100644 --- a/code_samples/api/public_php_api/src/Command/FindContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindContentCommand.php @@ -12,23 +12,19 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:find_content' + name: 'doc:find_content', + description: 'Lists content belonging to the provided content type.' )] class FindContentCommand extends Command { - private SearchService $searchService; - - public function __construct(SearchService $searchService) + public function __construct(private readonly SearchService $searchService) { - $this->searchService = $searchService; - parent::__construct(); } protected function configure(): void { $this - ->setDescription('Lists content belonging to the provided content type.') ->setDefinition([ new InputArgument('contentTypeIdentifier', InputArgument::REQUIRED, 'Content type identifier'), ]); diff --git a/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php b/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php index 0910cf7a01..c663e92917 100644 --- a/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php @@ -11,23 +11,19 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:find_in_trash' + name: 'doc:find_in_trash', + description: 'Lists content in Trash belonging to the provided content type.' )] class FindInTrashCommand extends Command { - private TrashService $trashService; - - public function __construct(TrashService $trashService) + public function __construct(private readonly TrashService $trashService) { - $this->trashService = $trashService; - parent::__construct(); } protected function configure(): void { $this - ->setDescription('Lists content in Trash belonging to the provided content type.') ->setDefinition([ new InputArgument('contentTypeId', InputArgument::REQUIRED, 'Content type ID'), ]); diff --git a/code_samples/api/public_php_api/src/Command/FindUrlCommand.php b/code_samples/api/public_php_api/src/Command/FindUrlCommand.php index c5b1b13aa7..082834e250 100644 --- a/code_samples/api/public_php_api/src/Command/FindUrlCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindUrlCommand.php @@ -14,31 +14,19 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:find_url' + name: 'doc:find_url', + description: 'Finds all valid URLs in the provided Section.' )] class FindUrlCommand extends Command { - private URLService $urlService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(URLService $URLService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->urlService = $URLService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly URLService $urlService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } - protected function configure(): void - { - $this - ->setDescription('Finds all valid URLs in the provided Section.'); - } - protected function execute(InputInterface $input, OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); diff --git a/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php b/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php index b8de4edf94..664d0a85fb 100644 --- a/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php @@ -13,25 +13,16 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:find_with_aggregation' + name: 'doc:find_with_aggregation', + description: 'Counts content per content type and the value of Selection Field.' )] class FindWithAggregationCommand extends Command { - private SearchService $searchService; - - public function __construct(SearchService $searchService) + public function __construct(private readonly SearchService $searchService) { - $this->searchService = $searchService; - parent::__construct(); } - protected function configure(): void - { - $this - ->setDescription('Counts content per content type and the value of Selection Field.'); - } - protected function execute(InputInterface $input, OutputInterface $output): int { $query = new LocationQuery(); diff --git a/code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php b/code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php index 2f05b2c9b9..54589ca95d 100644 --- a/code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php +++ b/code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php @@ -16,21 +16,12 @@ )] final class FormSubmissionCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private FormSubmissionServiceInterface $formSubmissionService; - - private ContentService $contentService; - - public function __construct(UserService $userService, PermissionResolver $permissionResolver, FormSubmissionServiceInterface $formSubmissionService, ContentService $contentService) - { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->formSubmissionService = $formSubmissionService; - $this->contentService = $contentService; - + public function __construct( + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly FormSubmissionServiceInterface $formSubmissionService, + private readonly ContentService $contentService + ) { parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/HideLocationCommand.php b/code_samples/api/public_php_api/src/Command/HideLocationCommand.php index 86ba8dc96a..2ad1d224ad 100644 --- a/code_samples/api/public_php_api/src/Command/HideLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/HideLocationCommand.php @@ -12,29 +12,22 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:hide' + name: 'doc:hide', + description: 'Hides and reveals again selected Location.' )] class HideLocationCommand extends Command { - private LocationService $locationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(LocationService $locationService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->locationService = $locationService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } protected function configure(): void { $this - ->setDescription('Hides and reveals again selected Location.') ->setDefinition([ new InputArgument('location_id', InputArgument::REQUIRED, 'Location ID'), ]); diff --git a/code_samples/api/public_php_api/src/Command/MoveContentCommand.php b/code_samples/api/public_php_api/src/Command/MoveContentCommand.php index 12b9f3e95f..50b760fa96 100644 --- a/code_samples/api/public_php_api/src/Command/MoveContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/MoveContentCommand.php @@ -12,29 +12,22 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:move_content' + name: 'doc:move_content', + description: 'Moves the selected Location with its subtree.' )] class MoveContentCommand extends Command { - private LocationService $locationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(LocationService $locationService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->locationService = $locationService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } protected function configure(): void { $this - ->setDescription('Moves the selected Location with its subtree.') ->setDefinition([ new InputArgument('locationId', InputArgument::REQUIRED, 'Location to copy'), new InputArgument('targetLocationId', InputArgument::REQUIRED, 'Target to copy or move to'), diff --git a/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php b/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php index a7da6a3ffc..5c133c6743 100644 --- a/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php +++ b/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php @@ -13,32 +13,23 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:object_state' + name: 'doc:object_state', + description: 'Creates OS group with provided States and assigned the Lock OS to provided content item' )] class ObjectStateCommand extends Command { - private ContentService $contentService; - - private UserService $userService; - - private ObjectStateService $objectStateService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, UserService $userService, ObjectStateService $objectStateService, PermissionResolver $permissionResolver) - { - $this->contentService = $contentService; - $this->userService = $userService; - $this->objectStateService = $objectStateService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly ContentService $contentService, + private readonly UserService $userService, + private readonly ObjectStateService $objectStateService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } protected function configure(): void { $this - ->setDescription('Creates OS group with provided States and assigned the Lock OS to provided content item') ->setDefinition([ new InputArgument('objectStateGroupIdentifier', InputArgument::REQUIRED, 'Identifier of new OG group to create'), new InputArgument('objectStateIdentifier', InputArgument::REQUIRED, 'Identifier(s) of a new Object State'), @@ -58,7 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($objectState->getName()); $objectStateGroupIdentifier = $input->getArgument('objectStateGroupIdentifier'); - $objectStateIdentifierList = explode(',', $input->getArgument('objectStateIdentifier')); + $objectStateIdentifierList = explode(',', (string) $input->getArgument('objectStateIdentifier')); $objectStateGroupStruct = $this->objectStateService->newObjectStateGroupCreateStruct($objectStateGroupIdentifier); $objectStateGroupStruct->defaultLanguageCode = 'eng-GB'; diff --git a/code_samples/api/public_php_api/src/Command/SectionCommand.php b/code_samples/api/public_php_api/src/Command/SectionCommand.php index 1f06cf1152..2ee4e31d2a 100644 --- a/code_samples/api/public_php_api/src/Command/SectionCommand.php +++ b/code_samples/api/public_php_api/src/Command/SectionCommand.php @@ -16,35 +16,24 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:section' + name: 'doc:section', + description: 'Creates new section and adds selected content item to it.' )] class SectionCommand extends Command { - private SectionService $sectionService; - - private UserService $userService; - - private SearchService $searchService; - - private ContentService $contentService; - - private PermissionResolver $permissionResolver; - - public function __construct(SectionService $sectionService, UserService $userService, ContentService $contentService, SearchService $searchService, PermissionResolver $permissionResolver) - { - $this->sectionService = $sectionService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->searchService = $searchService; - $this->contentService = $contentService; - + public function __construct( + private readonly SectionService $sectionService, + private readonly UserService $userService, + private readonly ContentService $contentService, + private readonly SearchService $searchService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } protected function configure(): void { $this - ->setDescription('Creates new section and adds selected content item to it.') ->setDefinition([ new InputArgument('sectionName', InputArgument::REQUIRED, 'Name of the new Section'), new InputArgument('sectionIdentifier', InputArgument::REQUIRED, 'Identifier of the new Section'), diff --git a/code_samples/api/public_php_api/src/Command/SegmentCommand.php b/code_samples/api/public_php_api/src/Command/SegmentCommand.php index 84d29650fb..abf71dad71 100644 --- a/code_samples/api/public_php_api/src/Command/SegmentCommand.php +++ b/code_samples/api/public_php_api/src/Command/SegmentCommand.php @@ -17,25 +17,14 @@ )] class SegmentCommand extends Command { - private SegmentationService $segmentationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(SegmentationService $segmentationService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->segmentationService = $segmentationService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - + public function __construct( + private readonly SegmentationService $segmentationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } - protected function configure(): void - { - } - protected function execute(InputInterface $input, OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); diff --git a/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php b/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php index 1d75a60d5d..081cbabcc5 100644 --- a/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php @@ -12,29 +12,22 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:set_main_location' + name: 'doc:set_main_location', + description: 'Set a Location as content item\'s main' )] class SetMainLocationCommand extends Command { - private ContentService $contentService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->contentService = $contentService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly ContentService $contentService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } protected function configure(): void { $this - ->setDescription('Set a Location as content item\'s main') ->setDefinition([ new InputArgument('contentId', InputArgument::REQUIRED, 'The Content ID'), new InputArgument('locationId', InputArgument::REQUIRED, 'One of the Locations of the Content'), diff --git a/code_samples/api/public_php_api/src/Command/TaxonomyCommand.php b/code_samples/api/public_php_api/src/Command/TaxonomyCommand.php index de0b0bb3b9..2b98a23b6e 100644 --- a/code_samples/api/public_php_api/src/Command/TaxonomyCommand.php +++ b/code_samples/api/public_php_api/src/Command/TaxonomyCommand.php @@ -17,21 +17,11 @@ )] class TaxonomyCommand extends Command { - private TaxonomyServiceInterface $taxonomyService; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - public function __construct( - TaxonomyServiceInterface $taxonomyService, - PermissionResolver $permissionResolver, - UserService $userService + private readonly TaxonomyServiceInterface $taxonomyService, + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService ) { - $this->taxonomyService = $taxonomyService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php b/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php index 0e33007661..c599ca0bbe 100644 --- a/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php @@ -16,18 +16,11 @@ )] class TranslateContentCommand extends Command { - private ContentService $contentService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->contentService = $contentService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly ContentService $contentService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/TrashContentCommand.php b/code_samples/api/public_php_api/src/Command/TrashContentCommand.php index 88a799273b..23bcdf7ad4 100644 --- a/code_samples/api/public_php_api/src/Command/TrashContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/TrashContentCommand.php @@ -18,21 +18,12 @@ )] class TrashContentCommand extends Command { - private LocationService $locationService; - - private UserService $userService; - - private TrashService $trashService; - - private PermissionResolver $permissionResolver; - - public function __construct(LocationService $locationService, UserService $userService, TrashService $trashService, PermissionResolver $permissionResolver) - { - $this->locationService = $locationService; - $this->userService = $userService; - $this->trashService = $trashService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly TrashService $trashService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php b/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php index 4bd45f5569..5783097e29 100644 --- a/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php @@ -12,29 +12,22 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:update_content' + name: 'doc:update_content', + description: 'Update provided content item with a new name' )] class UpdateContentCommand extends Command { - private ContentService $contentService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, UserService $userService, PermissionResolver $permissionResolver) - { - $this->contentService = $contentService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly ContentService $contentService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } protected function configure(): void { $this - ->setDescription('Update provided content item with a new name') ->setDefinition([ new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), new InputArgument('newName', InputArgument::REQUIRED, 'New name for the updated content item'), diff --git a/code_samples/api/public_php_api/src/Command/ViewContentCommand.php b/code_samples/api/public_php_api/src/Command/ViewContentCommand.php index 02ca0536e3..0af99757e7 100644 --- a/code_samples/api/public_php_api/src/Command/ViewContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/ViewContentCommand.php @@ -12,29 +12,22 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:view_content' + name: 'doc:view_content', + description: 'Output Field values on provided content item.' )] class ViewContentCommand extends Command { - private ContentService $contentService; - - private ContentTypeService $contentTypeService; - - private FieldTypeService $fieldTypeService; - - public function __construct(ContentService $contentService, ContentTypeService $contentTypeService, FieldTypeService $fieldTypeService) - { - $this->contentService = $contentService; - $this->contentTypeService = $contentTypeService; - $this->fieldTypeService = $fieldTypeService; - + public function __construct( + private readonly ContentService $contentService, + private readonly ContentTypeService $contentTypeService, + private readonly FieldTypeService $fieldTypeService + ) { parent::__construct(); } protected function configure(): void { $this - ->setDescription('Output Field values on provided content item.') ->setDefinition([ new InputArgument('contentId', InputArgument::REQUIRED, 'Location ID'), ]); diff --git a/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php b/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php index 35d37c56b8..85f2ab7fe3 100644 --- a/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php +++ b/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php @@ -16,38 +16,25 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:view_metadata' + name: 'doc:view_metadata', + description: 'Output various metadata about a content item.' )] class ViewContentMetaDataCommand extends Command { - private ContentService $contentService; - - private LocationService $locationService; - - private URLAliasService $urlAliasService; - - private UserService $userService; - - private ObjectStateService $objectStateService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, LocationService $locationService, URLAliasService $urlAliasService, UserService $userService, ObjectStateService $objectStateService, PermissionResolver $permissionResolver) - { - $this->contentService = $contentService; - $this->locationService = $locationService; - $this->urlAliasService = $urlAliasService; - $this->userService = $userService; - $this->objectStateService = $objectStateService; - $this->permissionResolver = $permissionResolver; - + public function __construct( + private readonly ContentService $contentService, + private readonly LocationService $locationService, + private readonly URLAliasService $urlAliasService, + private readonly UserService $userService, + private readonly ObjectStateService $objectStateService, + private readonly PermissionResolver $permissionResolver + ) { parent::__construct(); } protected function configure(): void { $this - ->setDescription('Output various metadata about a content item.') ->setDefinition([ new InputArgument('contentId', InputArgument::REQUIRED, 'An existing content ID'), ]); diff --git a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php index 60cf29d89a..8fd6f0087a 100644 --- a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php +++ b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php @@ -12,29 +12,22 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:workflow' + name: 'doc:workflow', + description: 'Starts content in the selected workflow and makes the provided transition.' )] class WorkflowCommand extends Command { - private WorkflowServiceInterface $workflowService; - - private WorkflowRegistryInterface $workflowRegistry; - - private ContentService $contentService; - - public function __construct(WorkflowServiceInterface $workflowService, WorkflowRegistryInterface $workflowRegistry, ContentService $contentService) - { - $this->contentService = $contentService; - $this->workflowService = $workflowService; - $this->workflowRegistry = $workflowRegistry; - + public function __construct( + private readonly WorkflowServiceInterface $workflowService, + private readonly WorkflowRegistryInterface $workflowRegistry, + private readonly ContentService $contentService + ) { parent::__construct(); } protected function configure(): void { $this - ->setDescription('Starts content in the selected workflow and makes the provided transition.') ->setDefinition([ new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), new InputArgument('workflowName', InputArgument::REQUIRED, 'Workflow identifier'), diff --git a/code_samples/api/public_php_api/src/Controller/CustomController.php b/code_samples/api/public_php_api/src/Controller/CustomController.php index 19e87da5ec..1f00f31571 100644 --- a/code_samples/api/public_php_api/src/Controller/CustomController.php +++ b/code_samples/api/public_php_api/src/Controller/CustomController.php @@ -10,11 +10,8 @@ class CustomController extends Controller { - private SearchService $searchService; - - public function __construct(SearchService $searchService) + public function __construct(private readonly SearchService $searchService) { - $this->searchService = $searchService; } public function showContentAction(int $locationId): Response diff --git a/code_samples/api/public_php_api/src/Controller/CustomFilterController.php b/code_samples/api/public_php_api/src/Controller/CustomFilterController.php index 7ec661c0cb..07c057262d 100644 --- a/code_samples/api/public_php_api/src/Controller/CustomFilterController.php +++ b/code_samples/api/public_php_api/src/Controller/CustomFilterController.php @@ -10,11 +10,8 @@ class CustomFilterController extends Controller { - private ContentService $contentService; - - public function __construct(ContentService $contentService) + public function __construct(private readonly ContentService $contentService) { - $this->contentService = $contentService; } public function showChildrenAction(ContentView $view): ContentView diff --git a/code_samples/api/public_php_api/src/Controller/PaginationController.php b/code_samples/api/public_php_api/src/Controller/PaginationController.php index cd468ae2be..ea6fad8694 100644 --- a/code_samples/api/public_php_api/src/Controller/PaginationController.php +++ b/code_samples/api/public_php_api/src/Controller/PaginationController.php @@ -13,11 +13,8 @@ class PaginationController extends Controller { - private SearchService $searchService; - - public function __construct(SearchService $searchService) + public function __construct(private readonly SearchService $searchService) { - $this->searchService = $searchService; } public function showContentAction(Request $request, int $locationId): Response diff --git a/code_samples/api/public_php_api/src/EventSubscriber/MyEventSubcriber.php b/code_samples/api/public_php_api/src/EventSubscriber/MyEventSubcriber.php index 8a82af15e9..6b6c76e671 100644 --- a/code_samples/api/public_php_api/src/EventSubscriber/MyEventSubcriber.php +++ b/code_samples/api/public_php_api/src/EventSubscriber/MyEventSubcriber.php @@ -7,7 +7,7 @@ class MyEventSubcriber implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ CopyContentEvent::class => ['onCopyContent', 0], diff --git a/code_samples/api/rest_api/create_image.json.php b/code_samples/api/rest_api/create_image.json.php index 18f70d2f8b..501931004e 100644 --- a/code_samples/api/rest_api/create_image.json.php +++ b/code_samples/api/rest_api/create_image.json.php @@ -95,7 +95,7 @@ echo "\t{$responseArray['ErrorMessage']['errorDescription']}\n"; exit(4); } - } catch (HttpException\DecodingExceptionInterface $exception) { + } catch (HttpException\DecodingExceptionInterface) { } $responseHeaders = $response->getInfo('response_headers'); $error = $responseHeaders[0] ?? $responseCode; @@ -131,7 +131,7 @@ echo "\t{$responseArray['ErrorMessage']['errorDescription']}\n"; exit(8); } - } catch (HttpException\DecodingExceptionInterface $exception) { + } catch (HttpException\DecodingExceptionInterface) { } $responseHeaders = $response->getInfo('response_headers'); $error = $responseHeaders[0] ?? $responseCode; diff --git a/code_samples/api/rest_api/src/Rest/Output/ValueObjectVisitorDispatcher.php b/code_samples/api/rest_api/src/Rest/Output/ValueObjectVisitorDispatcher.php index 39782164fc..1ffd6264f8 100644 --- a/code_samples/api/rest_api/src/Rest/Output/ValueObjectVisitorDispatcher.php +++ b/code_samples/api/rest_api/src/Rest/Output/ValueObjectVisitorDispatcher.php @@ -10,19 +10,18 @@ class ValueObjectVisitorDispatcher // extends BaseValueObjectVisitorDispatcher T { private array $visitors; - private BaseValueObjectVisitorDispatcher $valueObjectVisitorDispatcher; - private Visitor $outputVisitor; private Generator $outputGenerator; - public function __construct(iterable $visitors, BaseValueObjectVisitorDispatcher $valueObjectVisitorDispatcher) - { + public function __construct( + iterable $visitors, + private readonly BaseValueObjectVisitorDispatcher $valueObjectVisitorDispatcher + ) { $this->visitors = []; foreach ($visitors as $type => $visitor) { $this->visitors[$type] = $visitor; } - $this->valueObjectVisitorDispatcher = $valueObjectVisitorDispatcher; } public function setOutputVisitor(Visitor $outputVisitor): void @@ -39,7 +38,7 @@ public function setOutputGenerator(Generator $outputGenerator): void public function visit($data) { - $className = get_class($data); + $className = $data::class; if (isset($this->visitors[$className])) { return $this->visitors[$className]->visit($this->outputVisitor, $this->outputGenerator, $data); } diff --git a/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/Greeting.php b/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/Greeting.php index f909993490..85b9dce847 100644 --- a/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/Greeting.php +++ b/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/Greeting.php @@ -8,6 +8,9 @@ class Greeting extends ValueObjectVisitor { + /** + * @param \App\Rest\Values\Greeting $data + */ public function visit(Visitor $visitor, Generator $generator, $data) { $visitor->setHeader('Content-Type', $generator->getMediaType('Greeting')); diff --git a/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/RestLocation.php b/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/RestLocation.php index 59dbf68fd0..fcc739e4ff 100644 --- a/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/RestLocation.php +++ b/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/RestLocation.php @@ -10,13 +10,11 @@ class RestLocation extends BaseRestLocation { - private URLAliasService $urlAliasService; - - public function __construct(URLAliasService $urlAliasService) + public function __construct(private readonly URLAliasService $urlAliasService) { - $this->urlAliasService = $urlAliasService; } + #[\Override] public function visit(Visitor $visitor, Generator $generator, $data): void { // Not using $generator->startObjectElement to not have the XML Generator adding its own media-type attribute with the default vendor diff --git a/code_samples/api/rest_api/src/Rest/Values/Greeting.php b/code_samples/api/rest_api/src/Rest/Values/Greeting.php index 3052899209..696289feab 100644 --- a/code_samples/api/rest_api/src/Rest/Values/Greeting.php +++ b/code_samples/api/rest_api/src/Rest/Values/Greeting.php @@ -4,13 +4,9 @@ class Greeting { - public string $salutation; - - public string $recipient; - - public function __construct(string $salutation = 'Hello', string $recipient = 'World') - { - $this->salutation = $salutation; - $this->recipient = $recipient; + public function __construct( + public string $salutation = 'Hello', + public string $recipient = 'World' + ) { } } diff --git a/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php b/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php index b6136ff6dd..67478c33fd 100644 --- a/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php +++ b/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php @@ -4,17 +4,14 @@ use DateTime; use DateTimeInterface; -use Ibexa\Calendar\EventSource\InMemoryEventSource; use Ibexa\Contracts\Calendar\EventCollection; use Ibexa\Contracts\Calendar\EventSource\EventSourceInterface; +use Ibexa\Contracts\Calendar\EventSource\InMemoryEventSource; class EventSourceFactory { - private EventType $eventType; - - public function __construct(EventType $eventType) + public function __construct(private readonly EventType $eventType) { - $this->eventType = $eventType; } public function createEventSource(): EventSourceInterface diff --git a/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php b/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php index 12c0370980..dc6be1db5e 100644 --- a/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php +++ b/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php @@ -2,15 +2,15 @@ namespace App\Calendar\Holidays; -use Ibexa\Calendar\EventAction\EventActionCollection; use Ibexa\Contracts\Calendar\Event; +use Ibexa\Contracts\Calendar\EventAction\EventActionCollection; use Ibexa\Contracts\Calendar\EventType\EventTypeInterface; class EventType implements EventTypeInterface { - private const EVENT_TYPE_IDENTIFIER = 'holiday'; + private const string EVENT_TYPE_IDENTIFIER = 'holiday'; - private EventActionCollection $actions; + private readonly EventActionCollection $actions; public function __construct(iterable $actions) { diff --git a/code_samples/back_office/dashboard/article_tab/src/Tab/Dashboard/Everyone/EveryoneArticleTab.php b/code_samples/back_office/dashboard/article_tab/src/Tab/Dashboard/Everyone/EveryoneArticleTab.php index 7c373dae72..9a54be1d5c 100644 --- a/code_samples/back_office/dashboard/article_tab/src/Tab/Dashboard/Everyone/EveryoneArticleTab.php +++ b/code_samples/back_office/dashboard/article_tab/src/Tab/Dashboard/Everyone/EveryoneArticleTab.php @@ -16,20 +16,13 @@ class EveryoneArticleTab extends AbstractTab implements OrderedTabInterface { - protected PagerLocationToDataMapper $pagerLocationToDataMapper; - - protected SearchService $searchService; - public function __construct( Environment $twig, TranslatorInterface $translator, - PagerLocationToDataMapper $pagerLocationToDataMapper, - SearchService $searchService + protected PagerLocationToDataMapper $pagerLocationToDataMapper, + protected SearchService $searchService ) { parent::__construct($twig, $translator); - - $this->pagerLocationToDataMapper = $pagerLocationToDataMapper; - $this->searchService = $searchService; } public function getIdentifier(): string diff --git a/code_samples/back_office/dashboard/src/Command/DashboardCommand.php b/code_samples/back_office/dashboard/src/Command/DashboardCommand.php index 512441effc..b4e4ef02e1 100644 --- a/code_samples/back_office/dashboard/src/Command/DashboardCommand.php +++ b/code_samples/back_office/dashboard/src/Command/DashboardCommand.php @@ -15,25 +15,23 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'doc:dashboard' + name: 'doc:dashboard', + description: 'Set a custom dashboard to user group.' )] class DashboardCommand extends Command { - private DashboardServiceInterface $dashboardService; + private readonly Locationservice $locationService; - private Locationservice $locationService; + private readonly ContentService $contentService; - private ContentService $contentService; + private readonly UserService $userService; - private UserService $userService; - - private PermissionResolver $permissionResolver; + private readonly PermissionResolver $permissionResolver; public function __construct( - DashboardServiceInterface $dashboardService, + private readonly DashboardServiceInterface $dashboardService, Repository $repository ) { - $this->dashboardService = $dashboardService; $this->locationService = $repository->getLocationService(); $this->contentService = $repository->getContentService(); $this->userService = $repository->getUserService(); @@ -44,7 +42,7 @@ public function __construct( public function configure(): void { - $this->setDescription('Set a custom dashboard to user group.') + $this ->addArgument('dashboard', InputArgument::REQUIRED, 'Location ID of the dashboard model') ->addArgument('group', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'User Group Content ID(s)'); } diff --git a/code_samples/back_office/images/src/SvgController.php b/code_samples/back_office/images/src/SvgController.php index b2ea7be6d1..3d44e5b33b 100644 --- a/code_samples/back_office/images/src/SvgController.php +++ b/code_samples/back_office/images/src/SvgController.php @@ -16,22 +16,13 @@ class SvgController extends Controller { - private const CONTENT_TYPE_HEADER = 'image/svg+xml'; - - private ContentService $contentService; - - private IOServiceInterface $ioService; - - private TranslationHelper $translationHelper; + private const string CONTENT_TYPE_HEADER = 'image/svg+xml'; public function __construct( - ContentService $contentService, - IOServiceInterface $ioService, - TranslationHelper $translationHelper + private readonly ContentService $contentService, + private readonly IOServiceInterface $ioService, + private readonly TranslationHelper $translationHelper ) { - $this->contentService = $contentService; - $this->ioService = $ioService; - $this->translationHelper = $translationHelper; } /** diff --git a/code_samples/back_office/images/src/SvgExtension.php b/code_samples/back_office/images/src/SvgExtension.php index 48ef14c583..de6826d22f 100644 --- a/code_samples/back_office/images/src/SvgExtension.php +++ b/code_samples/back_office/images/src/SvgExtension.php @@ -10,26 +10,21 @@ class SvgExtension extends AbstractExtension { - protected RouterInterface $router; - /** * SvgExtension constructor. */ - public function __construct(RouterInterface $router) + public function __construct(protected RouterInterface $router) { - $this->router = $router; } /** * @return \Twig\TwigFunction[] */ + #[\Override] public function getFunctions(): array { return [ - new TwigFunction('ibexa_svg_link', [ - $this, - 'generateLink', - ]), + new TwigFunction('ibexa_svg_link', $this->generateLink(...)), ]; } diff --git a/code_samples/back_office/limitation/src/Security/Limitation/CustomLimitationType.php b/code_samples/back_office/limitation/src/Security/Limitation/CustomLimitationType.php index 06030e605a..42d3a1ca63 100644 --- a/code_samples/back_office/limitation/src/Security/Limitation/CustomLimitationType.php +++ b/code_samples/back_office/limitation/src/Security/Limitation/CustomLimitationType.php @@ -9,7 +9,6 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Core\Repository\Values\User\Limitation; use Ibexa\Contracts\Core\Repository\Values\User\UserReference; -use Ibexa\Contracts\Core\Repository\Values\ValueObject; use Ibexa\Core\Base\Exceptions\InvalidArgumentException; use Ibexa\Core\Base\Exceptions\InvalidArgumentType; use Ibexa\Core\FieldType\ValidationError; @@ -57,7 +56,7 @@ public function buildValue(array $limitationValues): CustomLimitationValue * * @return bool|null */ - public function evaluate(Limitation $value, UserReference $currentUser, ValueObject $object, array $targets = null): ?bool + public function evaluate(Limitation $value, UserReference $currentUser, object $object, array $targets = null): ?bool { if (!$value instanceof CustomLimitationValue) { throw new InvalidArgumentException('$value', 'Must be of type: CustomLimitationValue'); diff --git a/code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php b/code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php index 4feca732a4..dd07d01498 100644 --- a/code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php +++ b/code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php @@ -13,14 +13,10 @@ class AllContentListController extends Controller { - private SearchService $searchService; - - private FormFactory $formFactory; - - public function __construct(SearchService $searchService, FormFactory $formFactory) - { - $this->searchService = $searchService; - $this->formFactory = $formFactory; + public function __construct( + private readonly SearchService $searchService, + private readonly FormFactory $formFactory + ) { } public function listAction(int $page = 1): Response @@ -39,7 +35,7 @@ public function listAction(int $page = 1): Response return $this->render('@ibexadesign/all_content_list.html.twig', [ 'totalCount' => $paginator->getNbResults(), 'articles' => $paginator, - 'form_edit' => $editForm->createView(), + 'form_edit' => $editForm, ]); } } diff --git a/code_samples/back_office/menu/menu_item/src/EventSubscriber/MyMenuSubscriber.php b/code_samples/back_office/menu/menu_item/src/EventSubscriber/MyMenuSubscriber.php index 4b2d2e545a..be803e3d9d 100644 --- a/code_samples/back_office/menu/menu_item/src/EventSubscriber/MyMenuSubscriber.php +++ b/code_samples/back_office/menu/menu_item/src/EventSubscriber/MyMenuSubscriber.php @@ -8,7 +8,7 @@ class MyMenuSubscriber implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ ConfigureMenuEvent::MAIN_MENU => ['onMainMenuConfigure', 0], diff --git a/code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php b/code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php index e89a5c7d81..c1447f80ba 100644 --- a/code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php +++ b/code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php @@ -7,16 +7,13 @@ use Ibexa\Contracts\Core\Repository\Values\Notification\CreateStruct; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -final class ContentPublishEventListener implements EventSubscriberInterface +final readonly class ContentPublishEventListener implements EventSubscriberInterface { - private NotificationService $notificationService; - - public function __construct(NotificationService $notificationService) + public function __construct(private NotificationService $notificationService) { - $this->notificationService = $notificationService; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [PublishVersionEvent::class => 'onPublishVersion']; } diff --git a/code_samples/back_office/notifications/src/Notification/MyRenderer.php b/code_samples/back_office/notifications/src/Notification/MyRenderer.php index cb745cf6ab..b25be7eb98 100644 --- a/code_samples/back_office/notifications/src/Notification/MyRenderer.php +++ b/code_samples/back_office/notifications/src/Notification/MyRenderer.php @@ -11,14 +11,10 @@ class MyRenderer implements NotificationRenderer { - protected Environment $twig; - - protected RouterInterface $router; - - public function __construct(Environment $twig, RouterInterface $router) - { - $this->twig = $twig; - $this->router = $router; + public function __construct( + protected Environment $twig, + protected RouterInterface $router + ) { } public function render(Notification $notification): string diff --git a/code_samples/back_office/online_editor/src/event/subscriber/RichTextBlockSubscriber.php b/code_samples/back_office/online_editor/src/event/subscriber/RichTextBlockSubscriber.php index 6cc97a5edc..924e92ea45 100644 --- a/code_samples/back_office/online_editor/src/event/subscriber/RichTextBlockSubscriber.php +++ b/code_samples/back_office/online_editor/src/event/subscriber/RichTextBlockSubscriber.php @@ -12,15 +12,11 @@ class RichTextBlockSubscriber implements EventSubscriberInterface { - /** @var \Ibexa\FieldTypeRichText\RichText\DOMDocumentFactory */ - private $domDocumentFactory; - /** * @param \Ibexa\FieldTypeRichText\RichText\DOMDocumentFactory $domDocumentFactory */ - public function __construct(DOMDocumentFactory $domDocumentFactory) + public function __construct(private readonly DOMDocumentFactory $domDocumentFactory) { - $this->domDocumentFactory = $domDocumentFactory; } /** diff --git a/code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php b/code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php index 0304243c06..9fe69380df 100644 --- a/code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php +++ b/code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php @@ -15,12 +15,8 @@ class MySuggestionEventSubscriber implements EventSubscriberInterface, LoggerAwa { use LoggerAwareTrait; - private ProductServiceInterface $productService; - - public function __construct( - ProductServiceInterface $productService, - ) { - $this->productService = $productService; + public function __construct(private ProductServiceInterface $productService) + { } public static function getSubscribedEvents(): array @@ -36,14 +32,12 @@ public function onBuildSuggestionCollectionEvent(BuildSuggestionCollectionEvent $suggestionCollection = $event->getSuggestionCollection(); $text = $suggestionQuery->getQuery(); - $words = explode(' ', preg_replace('/\s+/', ' ', $text)); + $words = explode(' ', (string) preg_replace('/\s+/', ' ', $text)); $limit = $suggestionQuery->getLimit(); try { $productQuery = new ProductQuery(null, new Criterion\LogicalOr([ - new Criterion\ProductName(implode(' ', array_map(static function (string $word) { - return "$word*"; - }, $words))), + new Criterion\ProductName(implode(' ', array_map(static fn (string $word) => "$word*", $words))), new Criterion\ProductCode($words), new Criterion\ProductType($words), ]), [], 0, $limit); diff --git a/code_samples/back_office/search/src/Search/Model/Suggestion/ProductSuggestion.php b/code_samples/back_office/search/src/Search/Model/Suggestion/ProductSuggestion.php index a054e5550c..6e8be68e4d 100644 --- a/code_samples/back_office/search/src/Search/Model/Suggestion/ProductSuggestion.php +++ b/code_samples/back_office/search/src/Search/Model/Suggestion/ProductSuggestion.php @@ -7,7 +7,7 @@ class ProductSuggestion extends Suggestion { - private Product $product; + private readonly Product $product; public function __construct( float $score, diff --git a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php index 04cdecaded..82db0c90ef 100644 --- a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php +++ b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php @@ -10,13 +10,10 @@ use JMS\TranslationBundle\Translation\TranslationContainerInterface; use Symfony\Contracts\Translation\TranslatorInterface; -final class SectionNameSortingDefinitionProvider implements SortingDefinitionProviderInterface, TranslationContainerInterface +final readonly class SectionNameSortingDefinitionProvider implements SortingDefinitionProviderInterface, TranslationContainerInterface { - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function getSortingDefinitions(): array diff --git a/code_samples/back_office/settings/src/Setting/Unit.php b/code_samples/back_office/settings/src/Setting/Unit.php index 4a4eeaabe9..dd524ccf85 100644 --- a/code_samples/back_office/settings/src/Setting/Unit.php +++ b/code_samples/back_office/settings/src/Setting/Unit.php @@ -25,17 +25,14 @@ public function getDescription(): string public function getDisplayValue(string $storageValue): string { - switch ($storageValue) { - case self::METRIC_OPTION: - return 'Metric'; - case self::IMPERIAL_OPTION: - return 'Imperial'; - default: - throw new InvalidArgumentException( - '$storageValue', - sprintf('There is no \'%s\' option', $storageValue) - ); - } + return match ($storageValue) { + self::METRIC_OPTION => 'Metric', + self::IMPERIAL_OPTION => 'Imperial', + default => throw new InvalidArgumentException( + '$storageValue', + sprintf('There is no \'%s\' option', $storageValue) + ), + }; } public function getDefaultValue(): string diff --git a/code_samples/back_office/thumbnails/src/Strategy/StaticThumbnailStrategy.php b/code_samples/back_office/thumbnails/src/Strategy/StaticThumbnailStrategy.php index 1cd431c64a..76cd57d9d4 100644 --- a/code_samples/back_office/thumbnails/src/Strategy/StaticThumbnailStrategy.php +++ b/code_samples/back_office/thumbnails/src/Strategy/StaticThumbnailStrategy.php @@ -9,14 +9,10 @@ use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo; use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; -final class StaticThumbnailStrategy implements ThumbnailStrategy +final readonly class StaticThumbnailStrategy implements ThumbnailStrategy { - /** @var string */ - private $staticThumbnail; - - public function __construct(string $staticThumbnail) + public function __construct(private string $staticThumbnail) { - $this->staticThumbnail = $staticThumbnail; } public function getThumbnail(ContentType $contentType, array $fields, ?VersionInfo $versionInfo = null): ?Thumbnail diff --git a/code_samples/customer_portal/src/Corporate/EventSubscriber/ApplicationDetailsViewSubscriber.php b/code_samples/customer_portal/src/Corporate/EventSubscriber/ApplicationDetailsViewSubscriber.php index 16c510d16d..a3aa625019 100644 --- a/code_samples/customer_portal/src/Corporate/EventSubscriber/ApplicationDetailsViewSubscriber.php +++ b/code_samples/customer_portal/src/Corporate/EventSubscriber/ApplicationDetailsViewSubscriber.php @@ -13,15 +13,11 @@ final class ApplicationDetailsViewSubscriber extends AbstractViewSubscriber { - private FormFactoryInterface $formFactory; - public function __construct( SiteAccessServiceInterface $siteAccessService, - FormFactoryInterface $formFactory + private readonly FormFactoryInterface $formFactory ) { parent::__construct($siteAccessService); - - $this->formFactory = $formFactory; } /** diff --git a/code_samples/customer_portal/src/Corporate/EventSubscriber/VerifyStateEventSubscriber.php b/code_samples/customer_portal/src/Corporate/EventSubscriber/VerifyStateEventSubscriber.php index 5091fbee10..54a85470e1 100644 --- a/code_samples/customer_portal/src/Corporate/EventSubscriber/VerifyStateEventSubscriber.php +++ b/code_samples/customer_portal/src/Corporate/EventSubscriber/VerifyStateEventSubscriber.php @@ -15,24 +15,15 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\FormFactoryInterface; -final class VerifyStateEventSubscriber implements EventSubscriberInterface +final readonly class VerifyStateEventSubscriber implements EventSubscriberInterface { - private const VERIFY_STATE = 'verify'; - - private FormFactoryInterface $formFactory; - - private HandlerInterface $applicationStateHandler; - - private TranslatableNotificationHandlerInterface $notificationHandler; + private const string VERIFY_STATE = 'verify'; public function __construct( - FormFactoryInterface $formFactory, - HandlerInterface $applicationStateHandler, - TranslatableNotificationHandlerInterface $notificationHandler + private FormFactoryInterface $formFactory, + private HandlerInterface $applicationStateHandler, + private TranslatableNotificationHandlerInterface $notificationHandler ) { - $this->formFactory = $formFactory; - $this->applicationStateHandler = $applicationStateHandler; - $this->notificationHandler = $notificationHandler; } public static function getSubscribedEvents(): array diff --git a/code_samples/customer_portal/src/Form/VerifyType.php b/code_samples/customer_portal/src/Form/VerifyType.php index 95d4685134..0326c304ac 100644 --- a/code_samples/customer_portal/src/Form/VerifyType.php +++ b/code_samples/customer_portal/src/Form/VerifyType.php @@ -13,9 +13,9 @@ final class VerifyType extends AbstractType { - private const FIELD_APPLICATION = 'application'; - private const FIELD_NOTES = 'notes'; - private const FIELD_VERIFY = 'verify'; + private const string FIELD_APPLICATION = 'application'; + private const string FIELD_NOTES = 'notes'; + private const string FIELD_VERIFY = 'verify'; public function buildForm( FormBuilderInterface $builder, diff --git a/code_samples/data_migration/src/Migrations/Action/AssignSection.php b/code_samples/data_migration/src/Migrations/Action/AssignSection.php index 635658a5e4..876c51491a 100644 --- a/code_samples/data_migration/src/Migrations/Action/AssignSection.php +++ b/code_samples/data_migration/src/Migrations/Action/AssignSection.php @@ -6,16 +6,12 @@ use Ibexa\Migration\ValueObject\Step\Action; -final class AssignSection implements Action +final readonly class AssignSection implements Action { - public const TYPE = 'assign_section'; + public const string TYPE = 'assign_section'; - /** @var string */ - private $sectionIdentifier; - - public function __construct(string $sectionIdentifier) + public function __construct(private string $sectionIdentifier) { - $this->sectionIdentifier = $sectionIdentifier; } /** diff --git a/code_samples/data_migration/src/Migrations/Action/AssignSectionExecutor.php b/code_samples/data_migration/src/Migrations/Action/AssignSectionExecutor.php index 9a19f1ad17..258f3f0d5d 100644 --- a/code_samples/data_migration/src/Migrations/Action/AssignSectionExecutor.php +++ b/code_samples/data_migration/src/Migrations/Action/AssignSectionExecutor.php @@ -8,20 +8,12 @@ use Ibexa\Migration\StepExecutor\ActionExecutor\ExecutorInterface; use Ibexa\Migration\ValueObject; -final class AssignSectionExecutor implements ExecutorInterface +final readonly class AssignSectionExecutor implements ExecutorInterface { - /** @var \Ibexa\Contracts\Core\Repository\SectionService */ - private $sectionService; - - /** @var \Ibexa\Contracts\Core\Repository\ContentService */ - private $contentService; - public function __construct( - ContentService $contentService, - SectionService $sectionService + private ContentService $contentService, + private SectionService $sectionService ) { - $this->sectionService = $sectionService; - $this->contentService = $contentService; } /** diff --git a/code_samples/data_migration/src/Migrations/Step/ReplaceNameStep.php b/code_samples/data_migration/src/Migrations/Step/ReplaceNameStep.php index d846d1b083..64bbe53d68 100644 --- a/code_samples/data_migration/src/Migrations/Step/ReplaceNameStep.php +++ b/code_samples/data_migration/src/Migrations/Step/ReplaceNameStep.php @@ -6,7 +6,7 @@ use Ibexa\Migration\ValueObject\Step\StepInterface; -final class ReplaceNameStep implements StepInterface +final readonly class ReplaceNameStep implements StepInterface { private string $replacement; diff --git a/code_samples/data_migration/src/Migrations/Step/ReplaceNameStepExecutor.php b/code_samples/data_migration/src/Migrations/Step/ReplaceNameStepExecutor.php index 0f033f192c..394e3dfd01 100644 --- a/code_samples/data_migration/src/Migrations/Step/ReplaceNameStepExecutor.php +++ b/code_samples/data_migration/src/Migrations/Step/ReplaceNameStepExecutor.php @@ -12,12 +12,8 @@ final class ReplaceNameStepExecutor extends AbstractStepExecutor { - private ContentService $contentService; - - public function __construct( - ContentService $contentService - ) { - $this->contentService = $contentService; + public function __construct(private readonly ContentService $contentService) + { } protected function doHandle(StepInterface $step) @@ -38,7 +34,7 @@ protected function doHandle(StepInterface $step) continue; } - if (str_contains($field->value, 'Company Name')) { + if (str_contains((string) $field->value, 'Company Name')) { $newValue = str_replace('Company Name', $step->getReplacement(), $field->value); $struct->setField($field->fieldDefIdentifier, new Value($newValue)); } @@ -48,7 +44,7 @@ protected function doHandle(StepInterface $step) $content = $this->contentService->createContentDraft($contentItem->contentInfo); $content = $this->contentService->updateContent($content->getVersionInfo(), $struct); $this->contentService->publishVersion($content->getVersionInfo()); - } catch (\Throwable $e) { + } catch (\Throwable) { // Ignore } } diff --git a/code_samples/discounts/src/Command/ManageDiscountsCommand.php b/code_samples/discounts/src/Command/ManageDiscountsCommand.php index 0471f80201..88755ae611 100644 --- a/code_samples/discounts/src/Command/ManageDiscountsCommand.php +++ b/code_samples/discounts/src/Command/ManageDiscountsCommand.php @@ -23,29 +23,15 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[\Symfony\Component\Console\Attribute\AsCommand(name: 'discounts:manage')] final class ManageDiscountsCommand extends Command { - protected static $defaultName = 'discounts:manage'; - - private DiscountServiceInterface $discountService; - - private DiscountCodeServiceInterface $discountCodeService; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - public function __construct( - UserService $userSerice, - PermissionResolver $permissionResolver, - DiscountServiceInterface $discountService, - DiscountCodeServiceInterface $discountCodeService + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly DiscountServiceInterface $discountService, + private readonly DiscountCodeServiceInterface $discountCodeService ) { - $this->userService = $userSerice; - $this->discountService = $discountService; - $this->discountCodeService = $discountCodeService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Type.php b/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Type.php index 7dc5dc9e53..2219c9ae36 100644 --- a/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Type.php +++ b/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Type.php @@ -19,6 +19,7 @@ public function getFieldTypeIdentifier(): string return 'point2d'; } + #[\Override] public function getSettingsSchema(): array { return [ @@ -31,7 +32,7 @@ public function getSettingsSchema(): array public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data): void { - $definition = $data->fieldDefinition; + $definition = $data->getFieldDefinition(); $fieldForm->add('value', Point2DType::class, [ 'required' => $definition->isRequired, 'label' => $definition->getName(), diff --git a/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Value.php b/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Value.php index 422da756ee..0d9cfa5dcf 100644 --- a/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Value.php +++ b/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Value.php @@ -50,7 +50,7 @@ public function setY(?float $y): void $this->y = $y; } - public function __toString() + public function __toString(): string { return "({$this->x}, {$this->y})"; } diff --git a/code_samples/field_types/2dpoint_ft/steps/step_1/Value.php b/code_samples/field_types/2dpoint_ft/steps/step_1/Value.php index 985a415ab7..7b5b193696 100644 --- a/code_samples/field_types/2dpoint_ft/steps/step_1/Value.php +++ b/code_samples/field_types/2dpoint_ft/steps/step_1/Value.php @@ -7,16 +7,10 @@ final class Value implements ValueInterface { - /** @var float|null */ - private $x; - - /** @var float|null */ - private $y; - - public function __construct(?float $x = null, ?float $y = null) - { - $this->x = $x; - $this->y = $y; + public function __construct( + private ?float $x = null, + private ?float $y = null + ) { } public function getX(): ?float @@ -39,7 +33,7 @@ public function setY(?float $y): void $this->y = $y; } - public function __toString() + public function __toString(): string { return "({$this->x}, {$this->y})"; } diff --git a/code_samples/field_types/2dpoint_ft/steps/step_3/Type.php b/code_samples/field_types/2dpoint_ft/steps/step_3/Type.php index 3619c4e028..9e0bbc346d 100644 --- a/code_samples/field_types/2dpoint_ft/steps/step_3/Type.php +++ b/code_samples/field_types/2dpoint_ft/steps/step_3/Type.php @@ -18,7 +18,7 @@ public function getFieldTypeIdentifier(): string public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data): void { - $definition = $data->fieldDefinition; + $definition = $data->getFieldDefinition(); $fieldForm->add('value', Point2DType::class, [ 'required' => $definition->isRequired, 'label' => $definition->getName(), diff --git a/code_samples/field_types/2dpoint_ft/steps/step_6/Type.php b/code_samples/field_types/2dpoint_ft/steps/step_6/Type.php index 14a5b9209d..617411f67e 100644 --- a/code_samples/field_types/2dpoint_ft/steps/step_6/Type.php +++ b/code_samples/field_types/2dpoint_ft/steps/step_6/Type.php @@ -15,6 +15,7 @@ public function getFieldTypeIdentifier(): string return 'point2d'; } + #[\Override] public function getSettingsSchema(): array { return [ @@ -27,7 +28,7 @@ public function getSettingsSchema(): array public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data): void { - $definition = $data->fieldDefinition; + $definition = $data->getFieldDefinition(); $fieldForm->add('value', Point2DType::class, [ 'required' => $definition->isRequired, 'label' => $definition->getName(), diff --git a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonEngine.php b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonEngine.php index 1467f4d827..60fdf5ca71 100644 --- a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonEngine.php +++ b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonEngine.php @@ -7,16 +7,11 @@ use Ibexa\Contracts\VersionComparison\Engine\FieldTypeComparisonEngine; use Ibexa\Contracts\VersionComparison\FieldType\FieldTypeComparisonValue; use Ibexa\Contracts\VersionComparison\Result\ComparisonResult; -use Ibexa\VersionComparison\Engine\Value\StringComparisonEngine; -final class HelloWorldComparisonEngine implements FieldTypeComparisonEngine +final readonly class HelloWorldComparisonEngine implements FieldTypeComparisonEngine { - /** @var \Ibexa\VersionComparison\Engine\Value\StringComparisonEngine */ - private \Ibexa\VersionComparison\Engine\Value\StringComparisonEngine $stringValueComparisonEngine; - - public function __construct(StringComparisonEngine $stringValueComparisonEngine) + public function __construct(private \Ibexa\VersionComparison\Engine\Value\StringComparisonEngine $stringValueComparisonEngine) { - $this->stringValueComparisonEngine = $stringValueComparisonEngine; } /** diff --git a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonResult.php b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonResult.php index 8c03b8e4d9..a8bab2d2f7 100644 --- a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonResult.php +++ b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonResult.php @@ -7,14 +7,10 @@ use Ibexa\Contracts\VersionComparison\Result\ComparisonResult; use Ibexa\VersionComparison\Result\Value\StringComparisonResult; -final class HelloWorldComparisonResult implements ComparisonResult +final readonly class HelloWorldComparisonResult implements ComparisonResult { - /** @var \Ibexa\VersionComparison\Result\Value\StringComparisonResult */ - private \Ibexa\VersionComparison\Result\Value\StringComparisonResult $stringDiff; - - public function __construct(StringComparisonResult $stringDiff) + public function __construct(private \Ibexa\VersionComparison\Result\Value\StringComparisonResult $stringDiff) { - $this->stringDiff = $stringDiff; } public function getHelloWorldDiff(): StringComparisonResult diff --git a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Type.php b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Type.php index 09db13dd83..62e5e121ae 100644 --- a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Type.php +++ b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Type.php @@ -17,7 +17,7 @@ public function getFieldTypeIdentifier(): string public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data): void { - $definition = $data->fieldDefinition; + $definition = $data->getFieldDefinition(); $fieldForm->add('value', HelloWorldType::class, [ 'required' => $definition->isRequired, diff --git a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Value.php b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Value.php index 80c34031a6..5810b42304 100644 --- a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Value.php +++ b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Value.php @@ -10,7 +10,7 @@ final class Value implements ValueInterface /** * @Assert\NotBlank() */ - private ?string $name; + private ?string $name = null; public function getName(): ?string { @@ -22,7 +22,7 @@ public function setName(?string $name): void $this->name = $name; } - public function __toString() + public function __toString(): string { return "Hello {$this->name}!"; } diff --git a/code_samples/forms/custom_form_attribute/src/FormBuilder/FieldType/Field/Mapper/CheckboxWithRichtextDescriptionFieldMapper.php b/code_samples/forms/custom_form_attribute/src/FormBuilder/FieldType/Field/Mapper/CheckboxWithRichtextDescriptionFieldMapper.php index 710d55279e..015ee0e76e 100644 --- a/code_samples/forms/custom_form_attribute/src/FormBuilder/FieldType/Field/Mapper/CheckboxWithRichtextDescriptionFieldMapper.php +++ b/code_samples/forms/custom_form_attribute/src/FormBuilder/FieldType/Field/Mapper/CheckboxWithRichtextDescriptionFieldMapper.php @@ -10,6 +10,7 @@ class CheckboxWithRichtextDescriptionFieldMapper extends GenericFieldMapper /** * {@inheritdoc} */ + #[\Override] protected function mapFormOptions(Field $field, array $constraints): array { $options = parent::mapFormOptions($field, $constraints); diff --git a/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php b/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php index ab4060a679..a5603b63f6 100644 --- a/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php +++ b/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php @@ -13,7 +13,8 @@ class CheckboxWithRichtextDescriptionType extends AbstractType /** * @return string|null */ - public function getParent() + #[\Override] + public function getParent(): ?string { return CheckboxType::class; } @@ -21,7 +22,8 @@ public function getParent() /** * @return string */ - public function getBlockPrefix() + #[\Override] + public function getBlockPrefix(): string { return 'checkbox_with_richtext_description'; } diff --git a/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php b/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php index bb5101a2fd..4162e9471b 100644 --- a/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php +++ b/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php @@ -10,7 +10,8 @@ class AttributeRichtextDescriptionType extends AbstractType /** * @return string|null */ - public function getParent() + #[\Override] + public function getParent(): ?string { return RichTextType::class; } @@ -18,7 +19,8 @@ public function getParent() /** * @return string */ - public function getBlockPrefix() + #[\Override] + public function getBlockPrefix(): string { return 'field_configuration_attribute_richtext'; } diff --git a/code_samples/forms/custom_form_field/src/FormBuilder/Field/Mapper/CountryFieldMapper.php b/code_samples/forms/custom_form_field/src/FormBuilder/Field/Mapper/CountryFieldMapper.php index 5f7f765243..32d4b9774a 100644 --- a/code_samples/forms/custom_form_field/src/FormBuilder/Field/Mapper/CountryFieldMapper.php +++ b/code_samples/forms/custom_form_field/src/FormBuilder/Field/Mapper/CountryFieldMapper.php @@ -7,6 +7,7 @@ class CountryFieldMapper extends GenericFieldMapper { + #[\Override] protected function mapFormOptions(Field $field, array $constraints): array { $options = parent::mapFormOptions($field, $constraints); diff --git a/code_samples/front/custom_query_type/src/QueryType/LatestContentQueryType.php b/code_samples/front/custom_query_type/src/QueryType/LatestContentQueryType.php index 7dee3868ec..2c73561ddc 100644 --- a/code_samples/front/custom_query_type/src/QueryType/LatestContentQueryType.php +++ b/code_samples/front/custom_query_type/src/QueryType/LatestContentQueryType.php @@ -25,7 +25,7 @@ public function getQuery(array $parameters = []) 'sortClauses' => [ new Query\SortClause\DatePublished(Query::SORT_DESC), ], - 'limit' => isset($parameters['limit']) ? $parameters['limit'] : 10, + 'limit' => $parameters['limit'] ?? 10, ]); } diff --git a/code_samples/front/custom_query_type/src/QueryType/OptionsBasedLatestContentQueryType.php b/code_samples/front/custom_query_type/src/QueryType/OptionsBasedLatestContentQueryType.php index f3b987e6ad..3b0060bfc1 100644 --- a/code_samples/front/custom_query_type/src/QueryType/OptionsBasedLatestContentQueryType.php +++ b/code_samples/front/custom_query_type/src/QueryType/OptionsBasedLatestContentQueryType.php @@ -27,7 +27,7 @@ protected function doGetQuery(array $parameters) 'sortClauses' => [ new Query\SortClause\DatePublished(Query::SORT_DESC), ], - 'limit' => isset($parameters['limit']) ? $parameters['limit'] : 10, + 'limit' => $parameters['limit'] ?? 10, ]); } diff --git a/code_samples/front/embed_content/src/Controller/RelationController.php b/code_samples/front/embed_content/src/Controller/RelationController.php index b0cd9aa5be..eb6ef86903 100644 --- a/code_samples/front/embed_content/src/Controller/RelationController.php +++ b/code_samples/front/embed_content/src/Controller/RelationController.php @@ -8,14 +8,10 @@ class RelationController { - private ContentService $contentService; - - private LocationService $locationService; - - public function __construct(ContentService $contentService, LocationService $locationService) - { - $this->contentService = $contentService; - $this->locationService = $locationService; + public function __construct( + private readonly ContentService $contentService, + private readonly LocationService $locationService + ) { } public function showContentAction(View $view, $locationId): View diff --git a/code_samples/front/layouts/breadcrumbs/src/Controller/BreadcrumbController.php b/code_samples/front/layouts/breadcrumbs/src/Controller/BreadcrumbController.php index e178da4048..b82a4feeed 100644 --- a/code_samples/front/layouts/breadcrumbs/src/Controller/BreadcrumbController.php +++ b/code_samples/front/layouts/breadcrumbs/src/Controller/BreadcrumbController.php @@ -11,14 +11,10 @@ class BreadcrumbController extends Controller { - private LocationService $locationService; - - private SearchService $searchService; - - public function __construct(LocationService $locationService, SearchService $searchService) - { - $this->locationService = $locationService; - $this->searchService = $searchService; + public function __construct( + private readonly LocationService $locationService, + private readonly SearchService $searchService + ) { } public function showBreadcrumbsAction($locationId): Response diff --git a/code_samples/front/layouts/menu/src/Menu/MenuBuilder.php b/code_samples/front/layouts/menu/src/Menu/MenuBuilder.php index 977724de5f..9266372cf2 100644 --- a/code_samples/front/layouts/menu/src/Menu/MenuBuilder.php +++ b/code_samples/front/layouts/menu/src/Menu/MenuBuilder.php @@ -7,11 +7,8 @@ class MenuBuilder { - private FactoryInterface $factory; - - public function __construct(FactoryInterface $factory) + public function __construct(private readonly FactoryInterface $factory) { - $this->factory = $factory; } public function buildMenu(): ItemInterface diff --git a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php index 1519355529..10d0544cf8 100644 --- a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php +++ b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php @@ -11,27 +11,21 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( - name: 'app:view' + name: 'app:view', + description: 'Render the view of a content item' )] class ViewCommand extends Command { - private ContentViewBuilder $contentViewBuilder; - - private TemplateRenderer $templateRenderer; - public function __construct( - ContentViewBuilder $contentViewBuilder, - TemplateRenderer $templateRenderer + private readonly ContentViewBuilder $contentViewBuilder, + private readonly TemplateRenderer $templateRenderer ) { - $this->contentViewBuilder = $contentViewBuilder; - $this->templateRenderer = $templateRenderer; - parent::__construct(); } protected function configure(): void { - $this->setDescription('Render the view of a content item') + $this ->addOption('content-id', 'c', InputOption::VALUE_OPTIONAL, 'Content ID') ->addOption('location-id', 'l', InputOption::VALUE_OPTIONAL, 'Location ID') ->addOption('view-type', 't', InputOption::VALUE_OPTIONAL, 'View Type', 'line'); diff --git a/code_samples/front/shop/checkout/src/Controller/Checkout/OnePageCheckout.php b/code_samples/front/shop/checkout/src/Controller/Checkout/OnePageCheckout.php index f52d8d355b..3bc1896bb3 100644 --- a/code_samples/front/shop/checkout/src/Controller/Checkout/OnePageCheckout.php +++ b/code_samples/front/shop/checkout/src/Controller/Checkout/OnePageCheckout.php @@ -44,7 +44,7 @@ public function __invoke( return $this->render( '@storefront/checkout/checkout.html.twig', [ - 'form' => $form->createView(), + 'form' => $form, 'checkout' => $checkout, ] ); diff --git a/code_samples/front/shop/checkout/src/Controller/Checkout/Step/SelectSeatStepController.php b/code_samples/front/shop/checkout/src/Controller/Checkout/Step/SelectSeatStepController.php index bc36d0fdce..b2479c371a 100644 --- a/code_samples/front/shop/checkout/src/Controller/Checkout/Step/SelectSeatStepController.php +++ b/code_samples/front/shop/checkout/src/Controller/Checkout/Step/SelectSeatStepController.php @@ -30,7 +30,7 @@ public function __invoke( 'layout' => $this->getSeatsLayout(), 'current_step' => $step, 'checkout' => $checkout, - 'form' => $form->createView(), + 'form' => $form, ] ); } diff --git a/code_samples/front/shop/shipping/src/ShippingMethodType/CustomerNotNullValidator.php b/code_samples/front/shop/shipping/src/ShippingMethodType/CustomerNotNullValidator.php index e162d29fc0..da4e59ba1e 100644 --- a/code_samples/front/shop/shipping/src/ShippingMethodType/CustomerNotNullValidator.php +++ b/code_samples/front/shop/shipping/src/ShippingMethodType/CustomerNotNullValidator.php @@ -12,7 +12,7 @@ final class CustomerNotNullValidator implements OptionsValidatorInterface, TranslationContainerInterface { - public const MESSAGE = 'Customer identifier value cannot be null'; + public const string MESSAGE = 'Customer identifier value cannot be null'; public function validateOptions(OptionsBag $options): array { diff --git a/code_samples/front/shop/shipping/src/ShippingMethodType/Form/Type/CustomShippingMethodOptionsType.php b/code_samples/front/shop/shipping/src/ShippingMethodType/Form/Type/CustomShippingMethodOptionsType.php index 365f1a2156..d331e37781 100644 --- a/code_samples/front/shop/shipping/src/ShippingMethodType/Form/Type/CustomShippingMethodOptionsType.php +++ b/code_samples/front/shop/shipping/src/ShippingMethodType/Form/Type/CustomShippingMethodOptionsType.php @@ -13,6 +13,7 @@ final class CustomShippingMethodOptionsType extends AbstractType implements TranslationContainerInterface { + #[\Override] public function getBlockPrefix(): string { return 'ibexa_shipping_method_custom'; diff --git a/code_samples/front/shop/shipping/src/ShippingMethodType/Storage/StorageSchema.php b/code_samples/front/shop/shipping/src/ShippingMethodType/Storage/StorageSchema.php index 4417a749c0..96470cb038 100644 --- a/code_samples/front/shop/shipping/src/ShippingMethodType/Storage/StorageSchema.php +++ b/code_samples/front/shop/shipping/src/ShippingMethodType/Storage/StorageSchema.php @@ -8,7 +8,7 @@ final class StorageSchema extends AbstractOptionsStorageSchema { - public const TABLE_NAME = 'ibexa_shipping_method_region_custom'; - public const COLUMN_ID = 'id'; - public const COLUMN_CUSTOMER_ID = 'customer_id'; + public const string TABLE_NAME = 'ibexa_shipping_method_region_custom'; + public const string COLUMN_ID = 'id'; + public const string COLUMN_CUSTOMER_ID = 'customer_id'; } diff --git a/code_samples/front/shop/storefront/src/EventSubscriber/BreadcrumbsMenuSubscriber.php b/code_samples/front/shop/storefront/src/EventSubscriber/BreadcrumbsMenuSubscriber.php index 5aa1e016f4..5bd8acf1b0 100644 --- a/code_samples/front/shop/storefront/src/EventSubscriber/BreadcrumbsMenuSubscriber.php +++ b/code_samples/front/shop/storefront/src/EventSubscriber/BreadcrumbsMenuSubscriber.php @@ -10,7 +10,7 @@ class BreadcrumbsMenuSubscriber implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ BreadcrumbsMenuBuilder::PRODUCT_MENU => ['onBreadcrumbsMenuConfigure', 0], diff --git a/code_samples/front/view_matcher/src/View/Matcher/Owner.php b/code_samples/front/view_matcher/src/View/Matcher/Owner.php index 106d55bcd7..9c21e12141 100644 --- a/code_samples/front/view_matcher/src/View/Matcher/Owner.php +++ b/code_samples/front/view_matcher/src/View/Matcher/Owner.php @@ -13,14 +13,11 @@ class Owner implements MatcherInterface { - private UserService $userService; - /** @var string[] */ private array $matchingUserLogins; - public function __construct(UserService $userService) + public function __construct(private readonly UserService $userService) { - $this->userService = $userService; } /** diff --git a/code_samples/multisite/automated_translation/src/AutomatedTranslation/AiClient.php b/code_samples/multisite/automated_translation/src/AutomatedTranslation/AiClient.php index e423edb643..e71dc46100 100644 --- a/code_samples/multisite/automated_translation/src/AutomatedTranslation/AiClient.php +++ b/code_samples/multisite/automated_translation/src/AutomatedTranslation/AiClient.php @@ -14,14 +14,10 @@ final class AiClient implements ClientInterface /** @var array */ private array $supportedLanguages; - private ActionServiceInterface $actionService; - - private ActionConfigurationServiceInterface $actionConfigurationService; - - public function __construct(ActionServiceInterface $actionService, ActionConfigurationServiceInterface $actionConfigurationService) - { - $this->actionService = $actionService; - $this->actionConfigurationService = $actionConfigurationService; + public function __construct( + private readonly ActionServiceInterface $actionService, + private readonly ActionConfigurationServiceInterface $actionConfigurationService + ) { } public function setConfiguration(array $configuration): void diff --git a/code_samples/multisite/siteaccess/AcmeExampleExtension.php b/code_samples/multisite/siteaccess/AcmeExampleExtension.php index 3c56d8023a..230b330026 100644 --- a/code_samples/multisite/siteaccess/AcmeExampleExtension.php +++ b/code_samples/multisite/siteaccess/AcmeExampleExtension.php @@ -11,7 +11,7 @@ final class AcmeExampleExtension extends Extension { - public const ACME_CONFIG_DIR = __DIR__ . '/../../../config/acme'; + public const string ACME_CONFIG_DIR = __DIR__ . '/../../../config/acme'; /** * @throws \Exception @@ -54,6 +54,7 @@ static function ($scopeSettings, $currentScope, ContextualizerInterface $context } /** @param array $config */ + #[\Override] public function getConfiguration(array $config, ContainerBuilder $container): Configuration { return new Configuration(); diff --git a/code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php b/code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php index 9a9fe33d03..34604db561 100644 --- a/code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php +++ b/code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php @@ -7,12 +7,14 @@ class MyStringAttributeType extends AbstractType { - public function getParent() + #[\Override] + public function getParent(): ?string { return TextType::class; } - public function getBlockPrefix() + #[\Override] + public function getBlockPrefix(): string { return 'my_string_attribute'; } diff --git a/code_samples/page/custom_page_block/src/Event/Subscriber/BlockEmbedEventEventSubscriber.php b/code_samples/page/custom_page_block/src/Event/Subscriber/BlockEmbedEventEventSubscriber.php index a86ae91b47..157c55ced7 100644 --- a/code_samples/page/custom_page_block/src/Event/Subscriber/BlockEmbedEventEventSubscriber.php +++ b/code_samples/page/custom_page_block/src/Event/Subscriber/BlockEmbedEventEventSubscriber.php @@ -9,11 +9,8 @@ class BlockEmbedEventEventSubscriber implements EventSubscriberInterface { - private ContentService $contentService; - - public function __construct(ContentService $contentService) + public function __construct(private readonly ContentService $contentService) { - $this->contentService = $contentService; } public static function getSubscribedEvents(): array diff --git a/code_samples/page/page_listener/src/Block/Listener/MyBlockListener.php b/code_samples/page/page_listener/src/Block/Listener/MyBlockListener.php index 25aa71cc3e..716cba8645 100644 --- a/code_samples/page/page_listener/src/Block/Listener/MyBlockListener.php +++ b/code_samples/page/page_listener/src/Block/Listener/MyBlockListener.php @@ -8,7 +8,7 @@ class MyBlockListener implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ BlockRenderEvents::getBlockPreRenderEventName('event') => 'onBlockPreRender', diff --git a/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php b/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php index d4c93ccd5f..c53703e2fa 100644 --- a/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php +++ b/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php @@ -23,33 +23,14 @@ )] class ActivityLogContextTestCommand extends Command { - private ActivityLogServiceInterface $activityLogService; - - private ContentService $contentService; - - private ContentTypeService $contentTypeService; - - private EventDispatcherInterface $eventDispatcher; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - public function __construct( - ActivityLogServiceInterface $activityLogService, - ContentService $contentService, - ContentTypeService $contentTypeService, - EventDispatcherInterface $eventDispatcher, - PermissionResolver $permissionResolver, - UserService $userService + private readonly ActivityLogServiceInterface $activityLogService, + private readonly ContentService $contentService, + private readonly ContentTypeService $contentTypeService, + private readonly EventDispatcherInterface $eventDispatcher, + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService ) { - $this->activityLogService = $activityLogService; - $this->contentService = $contentService; - $this->contentTypeService = $contentTypeService; - $this->eventDispatcher = $eventDispatcher; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - parent::__construct(); } diff --git a/code_samples/recent_activity/src/Command/DispatchMyFeatureEventCommand.php b/code_samples/recent_activity/src/Command/DispatchMyFeatureEventCommand.php index 2b6e1baafa..ab8cec0ef0 100644 --- a/code_samples/recent_activity/src/Command/DispatchMyFeatureEventCommand.php +++ b/code_samples/recent_activity/src/Command/DispatchMyFeatureEventCommand.php @@ -16,12 +16,8 @@ )] class DispatchMyFeatureEventCommand extends Command { - private EventDispatcherInterface $eventDispatcher; - - public function __construct(EventDispatcherInterface $eventDispatcher) + public function __construct(private readonly EventDispatcherInterface $eventDispatcher) { - $this->eventDispatcher = $eventDispatcher; - parent::__construct(); } diff --git a/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php b/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php index 52808377f9..8b82da5673 100644 --- a/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php +++ b/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php @@ -21,18 +21,11 @@ )] class MonitorRecentContentCreationCommand extends Command { - private ActivityLogServiceInterface $activityLogService; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - - public function __construct(ActivityLogServiceInterface $activityLogService, PermissionResolver $permissionResolver, UserService $userService) - { - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->activityLogService = $activityLogService; - + public function __construct( + private readonly ActivityLogServiceInterface $activityLogService, + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService + ) { parent::__construct(); } diff --git a/code_samples/recent_activity/src/Event/MyFeatureEvent.php b/code_samples/recent_activity/src/Event/MyFeatureEvent.php index 53dbfcb8cf..84b46ba6c1 100644 --- a/code_samples/recent_activity/src/Event/MyFeatureEvent.php +++ b/code_samples/recent_activity/src/Event/MyFeatureEvent.php @@ -6,14 +6,10 @@ class MyFeatureEvent extends Event { - private object $object; - - private string $action; - - public function __construct(object $object, string $action) - { - $this->object = $object; - $this->action = $action; + public function __construct( + private readonly object $object, + private readonly string $action + ) { } public function getObject(): object diff --git a/code_samples/recent_activity/src/EventSubscriber/MyFeatureEventSubscriber.php b/code_samples/recent_activity/src/EventSubscriber/MyFeatureEventSubscriber.php index ca8a93bcf6..812875614c 100644 --- a/code_samples/recent_activity/src/EventSubscriber/MyFeatureEventSubscriber.php +++ b/code_samples/recent_activity/src/EventSubscriber/MyFeatureEventSubscriber.php @@ -8,11 +8,8 @@ class MyFeatureEventSubscriber implements EventSubscriberInterface { - private ActivityLogServiceInterface $activityLogService; - - public function __construct(ActivityLogServiceInterface $activityLogService) + public function __construct(private readonly ActivityLogServiceInterface $activityLogService) { - $this->activityLogService = $activityLogService; } public static function getSubscribedEvents(): array @@ -26,7 +23,7 @@ public function onMyFeatureEvent(MyFeatureEvent $event): void { /** @var \App\MyFeature\MyFeature $object */ $object = $event->getObject(); - $className = get_class($object); + $className = $object::class; $id = (string)$object->id; $action = $event->getAction(); $activityLog = $this->activityLogService->build($className, $id, $action); diff --git a/code_samples/recent_activity/src/EventSubscriber/MyFeaturePostActivityListLoadEventSubscriber.php b/code_samples/recent_activity/src/EventSubscriber/MyFeaturePostActivityListLoadEventSubscriber.php index 93d87e8a7b..619ff17f6e 100644 --- a/code_samples/recent_activity/src/EventSubscriber/MyFeaturePostActivityListLoadEventSubscriber.php +++ b/code_samples/recent_activity/src/EventSubscriber/MyFeaturePostActivityListLoadEventSubscriber.php @@ -11,12 +11,8 @@ class MyFeaturePostActivityListLoadEventSubscriber implements EventSubscriberInterface { - private MyFeatureService $myFeatureService; - - public function __construct( - MyFeatureService $myFeatureService - ) { - $this->myFeatureService = $myFeatureService; + public function __construct(private readonly MyFeatureService $myFeatureService) + { } public static function getSubscribedEvents(): array @@ -47,7 +43,7 @@ public function loadMyFeature(PostActivityGroupListLoadEvent $event): void } $log->setRelatedObject($visitedIds[$id]); - } catch (NotFoundException|UnauthorizedException $e) { + } catch (NotFoundException|UnauthorizedException) { $visitedIds[$id] = null; } } diff --git a/code_samples/search/custom/src/GroupResolver/ContentTypeGroupGroupResolver.php b/code_samples/search/custom/src/GroupResolver/ContentTypeGroupGroupResolver.php index fd38f72dcb..a707b331c5 100644 --- a/code_samples/search/custom/src/GroupResolver/ContentTypeGroupGroupResolver.php +++ b/code_samples/search/custom/src/GroupResolver/ContentTypeGroupGroupResolver.php @@ -8,13 +8,10 @@ use Ibexa\Contracts\Elasticsearch\ElasticSearch\Index\Group\GroupResolverInterface; use Ibexa\Contracts\Elasticsearch\Mapping\BaseDocument; -final class ContentTypeGroupGroupResolver implements GroupResolverInterface +final readonly class ContentTypeGroupGroupResolver implements GroupResolverInterface { - private Handler $contentTypeHandler; - - public function __construct(Handler $contentTypeHandler) + public function __construct(private Handler $contentTypeHandler) { - $this->contentTypeHandler = $contentTypeHandler; } public function resolveDocumentGroup(BaseDocument $document): string diff --git a/code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationVisitor.php b/code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationVisitor.php index f2d0acfb1e..7782ff33b6 100644 --- a/code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationVisitor.php +++ b/code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationVisitor.php @@ -9,6 +9,9 @@ use Ibexa\Contracts\Elasticsearch\Query\AggregationVisitor; use Ibexa\Contracts\Elasticsearch\Query\LanguageFilter; +/** + * @phpstan-template TRangeAggregation of \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation + */ final class PriorityRangeAggregationVisitor implements AggregationVisitor { public function supports(Aggregation $aggregation, LanguageFilter $languageFilter): bool @@ -17,7 +20,7 @@ public function supports(Aggregation $aggregation, LanguageFilter $languageFilte } /** - * @param \App\Query\Aggregation\PriorityRangeAggregation $aggregation + * @param \App\Query\Aggregation\PriorityRangeAggregation $aggregation * * @return array> */ diff --git a/code_samples/search/custom/src/Query/Aggregation/PriorityRangeAggregation.php b/code_samples/search/custom/src/Query/Aggregation/PriorityRangeAggregation.php index 8f65e1794b..2952020fcd 100644 --- a/code_samples/search/custom/src/Query/Aggregation/PriorityRangeAggregation.php +++ b/code_samples/search/custom/src/Query/Aggregation/PriorityRangeAggregation.php @@ -7,6 +7,11 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\LocationAggregation; +/** + * @phpstan-template TValue + * + * @phpstan-extends \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation + */ final class PriorityRangeAggregation extends AbstractRangeAggregation implements LocationAggregation { } diff --git a/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php b/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php index ba87eda5cf..a81fb9b743 100644 --- a/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php +++ b/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php @@ -24,7 +24,7 @@ public function extract(Aggregation $aggregation, array $languageFilter, stdClas { $entries = []; foreach ($data as $key => $bucket) { - if ($key === 'count' || strpos($key, '_') === false) { + if ($key === 'count' || !str_contains($key, '_')) { continue; } [$from, $to] = explode('_', $key, 2); diff --git a/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php b/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php index d78f1a58f6..4f669dc70f 100644 --- a/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php +++ b/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php @@ -8,6 +8,9 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; use Ibexa\Contracts\Solr\Query\AggregationVisitor; +/** + * @phpstan-template TRangeAggregation of \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation + */ final class PriorityRangeAggregationVisitor implements AggregationVisitor { public function canVisit(Aggregation $aggregation, array $languageFilter): bool @@ -16,7 +19,7 @@ public function canVisit(Aggregation $aggregation, array $languageFilter): bool } /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation $aggregation + * @param \App\Query\Aggregation\PriorityRangeAggregation $aggregation */ public function visit( AggregationVisitor $dispatcherVisitor, @@ -27,7 +30,7 @@ public function visit( foreach ($aggregation->getRanges() as $range) { $from = $this->formatRangeValue($range->getFrom()); $to = $this->formatRangeValue($range->getTo()); - $rangeFacets["${from}_${to}"] = [ + $rangeFacets["{$from}_{$to}"] = [ 'type' => 'query', 'q' => sprintf('priority_i:[%s TO %s}', $from, $to), ]; diff --git a/code_samples/search/custom/src/Query/Criterion/Solr/CameraManufacturerVisitor.php b/code_samples/search/custom/src/Query/Criterion/Solr/CameraManufacturerVisitor.php index f385d5db1d..c4cf00e598 100644 --- a/code_samples/search/custom/src/Query/Criterion/Solr/CameraManufacturerVisitor.php +++ b/code_samples/search/custom/src/Query/Criterion/Solr/CameraManufacturerVisitor.php @@ -10,7 +10,7 @@ final class CameraManufacturerVisitor extends CriterionVisitor { - public function canVisit(CriterionInterface $criterion) + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof CameraManufacturerCriterion; } @@ -18,12 +18,10 @@ public function canVisit(CriterionInterface $criterion) /** * @param \App\Query\Criterion\CameraManufacturerCriterion $criterion */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $expressions = array_map( - function ($value): string { - return 'exif_camera_manufacturer_id:"' . $this->escapeQuote((string) $value) . '"'; - }, + fn ($value): string => 'exif_camera_manufacturer_id:"' . $this->escapeQuote((string) $value) . '"', $criterion->value ); diff --git a/code_samples/search/custom/src/Search/FieldMapper/WebinarEventParentNameFieldMapper.php b/code_samples/search/custom/src/Search/FieldMapper/WebinarEventParentNameFieldMapper.php index d0e79206db..a02e3a04a0 100644 --- a/code_samples/search/custom/src/Search/FieldMapper/WebinarEventParentNameFieldMapper.php +++ b/code_samples/search/custom/src/Search/FieldMapper/WebinarEventParentNameFieldMapper.php @@ -10,16 +10,10 @@ class WebinarEventParentNameFieldMapper extends ContentFieldMapper { - protected ContentHandler $contentHandler; - - protected LocationHandler $locationHandler; - public function __construct( - ContentHandler $contentHandler, - LocationHandler $locationHandler + protected ContentHandler $contentHandler, + protected LocationHandler $locationHandler ) { - $this->contentHandler = $contentHandler; - $this->locationHandler = $locationHandler; } public function accept(Content $content): bool diff --git a/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php b/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php index 69d412a9b0..8d04f283fb 100644 --- a/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php +++ b/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php @@ -16,23 +16,14 @@ class RandomBlockListener implements EventSubscriberInterface { - private ContentService $contentService; - - private LocationService $locationService; - - private SearchService $searchService; - public function __construct( - ContentService $contentService, - LocationService $locationService, - SearchService $searchService + private readonly ContentService $contentService, + private readonly LocationService $locationService, + private readonly SearchService $searchService ) { - $this->contentService = $contentService; - $this->locationService = $locationService; - $this->searchService = $searchService; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ BlockRenderEvents::getBlockPreRenderEventName('random') => 'onBlockPreRender', diff --git a/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php b/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php index 33128465fb..cbd1d14a74 100644 --- a/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php +++ b/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php @@ -17,35 +17,17 @@ final class GoogleResourceOwnerMapper extends ResourceOwnerToExistingOrNewUserMapper { - private const PROVIDER_PREFIX = 'google:'; - - private OAuth2UserService $oauthUserService; - - private LanguageResolver $languageResolver; - - private UserService $userService; - - /** @var string|null */ - private ?string $contentTypeIdentifier; - - /** @var string|null */ - private ?string $parentGroupRemoteId; + private const string PROVIDER_PREFIX = 'google:'; public function __construct( Repository $repository, - OAuth2UserService $oauthUserService, - LanguageResolver $languageResolver, - UserService $userService, - ?string $contentTypeIdentifier = null, - ?string $parentGroupRemoteId = null + private readonly OAuth2UserService $oauthUserService, + private readonly LanguageResolver $languageResolver, + private readonly UserService $userService, + private readonly ?string $contentTypeIdentifier = null, + private readonly ?string $parentGroupRemoteId = null ) { parent::__construct($repository); - - $this->oauthUserService = $oauthUserService; - $this->languageResolver = $languageResolver; - $this->userService = $userService; - $this->contentTypeIdentifier = $contentTypeIdentifier; - $this->parentGroupRemoteId = $parentGroupRemoteId; } /** @@ -54,8 +36,8 @@ public function __construct( protected function loadUser( ResourceOwnerInterface $resourceOwner, UserProviderInterface $userProvider - ): ?UserInterface { - return $userProvider->loadUserByUsername($this->getUsername($resourceOwner)); + ): UserInterface { + return $userProvider->loadUserByIdentifier($this->getUsername($resourceOwner)); } /** @@ -64,7 +46,7 @@ protected function loadUser( protected function createUser( ResourceOwnerInterface $resourceOwner, UserProviderInterface $userProvider - ): ?UserInterface { + ): UserInterface { $userCreateStruct = $this->oauthUserService->newOAuth2UserCreateStruct( $this->getUsername($resourceOwner), $resourceOwner->getEmail(), @@ -82,7 +64,7 @@ protected function createUser( $this->userService->createUser($userCreateStruct, $parentGroups); - return $userProvider->loadUserByUsername($this->getUsername($resourceOwner)); + return $userProvider->loadUserByIdentifier($this->getUsername($resourceOwner)); } private function getOAuth2UserContentType(Repository $repository): ?ContentType diff --git a/code_samples/workflow/custom_workflow/src/EventListener/ApprovedTransitionListener.php b/code_samples/workflow/custom_workflow/src/EventListener/ApprovedTransitionListener.php index ed7f5af3e2..1e6d72e701 100644 --- a/code_samples/workflow/custom_workflow/src/EventListener/ApprovedTransitionListener.php +++ b/code_samples/workflow/custom_workflow/src/EventListener/ApprovedTransitionListener.php @@ -10,11 +10,8 @@ class ApprovedTransitionListener extends AbstractTransitionWorkflowActionListener { - private NotificationInterface $notificationHandler; - - public function __construct(NotificationInterface $notificationHandler) + public function __construct(private readonly NotificationInterface $notificationHandler) { - $this->notificationHandler = $notificationHandler; } public function getIdentifier(): string diff --git a/code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php b/code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php index 85f63f55b8..067f46ee14 100644 --- a/code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php +++ b/code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php @@ -10,11 +10,8 @@ class LegalTransitionListener extends AbstractTransitionWorkflowActionListener { - private NotificationInterface $notificationHandler; - - public function __construct(NotificationInterface $notificationHandler) + public function __construct(private readonly NotificationInterface $notificationHandler) { - $this->notificationHandler = $notificationHandler; } public function getIdentifier(): string @@ -25,7 +22,7 @@ public function getIdentifier(): string public function onWorkflowEvent(TransitionEvent $event): void { $metadata = $this->getActionMetadata($event->getWorkflow(), $event->getTransition()); - $message = $metadata['data']['message']; + $message = $metadata['data']['message'] ?? ''; $this->notificationHandler->info( $message, diff --git a/code_samples/workflow/strategy/NewWorkflow.php b/code_samples/workflow/strategy/NewWorkflow.php index ac4a240d25..6d15c010ce 100644 --- a/code_samples/workflow/strategy/NewWorkflow.php +++ b/code_samples/workflow/strategy/NewWorkflow.php @@ -11,7 +11,7 @@ final class NewWorkflow implements WorkflowStrategyInterface { - private const IDENTIFIER = 'new_workflow'; + private const string IDENTIFIER = 'new_workflow'; public function getWorkflow(CartInterface $cart): WorkflowInterface { diff --git a/code_samples/workflow/strategy/NewWorkflowConditionalStep.php b/code_samples/workflow/strategy/NewWorkflowConditionalStep.php index d055c879e0..1fa93235d7 100644 --- a/code_samples/workflow/strategy/NewWorkflowConditionalStep.php +++ b/code_samples/workflow/strategy/NewWorkflowConditionalStep.php @@ -11,7 +11,7 @@ final class NewWorkflowConditionalStep implements WorkflowStrategyInterface { - private const IDENTIFIER = 'new_workflow'; + private const string IDENTIFIER = 'new_workflow'; public function getWorkflow(CartInterface $cart): WorkflowInterface { diff --git a/composer.json b/composer.json index b24e245968..f4f318a534 100644 --- a/composer.json +++ b/composer.json @@ -11,9 +11,12 @@ "url": "https://updates.ibexa.co" } ], + "require": { + "php": "^8.3" + }, "require-dev": { "ibexa/automated-translation": "5.0.x-dev", - "ibexa/code-style": "^1.0", + "ibexa/code-style": "~2.0.0", "friendsofphp/php-cs-fixer": "^3.30", "phpstan/phpstan": "^2.0", "phpstan/phpstan-symfony": "^2.0", diff --git a/docs/ai_actions/extend_ai_actions.md b/docs/ai_actions/extend_ai_actions.md index b07ed511bb..5674155151 100644 --- a/docs/ai_actions/extend_ai_actions.md +++ b/docs/ai_actions/extend_ai_actions.md @@ -14,7 +14,7 @@ For example, you can create a handler that connects to a translation model and u You can execute AI Actions by using the [ActionServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionServiceInterface.html) service, as in the following example: ``` php -[[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php', 105, 124) =]] +[[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php', 86, 105) =]] ``` The `GenerateAltTextAction` is a built-in action that implements the [ActionInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionInterface.html), takes an [Image](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-Action-DataType-Image.html) as an input, and generates the alternative text in the response. @@ -43,7 +43,7 @@ You can influence the execution of an Action with two events: Below you can find the full example of a Symfony Command, together with a matching service definition. The command finds the images modified in the last 24 hours, and adds the alternative text to them if it's missing. -``` php hl_lines="91 104-129" +``` php hl_lines="72 85-110" [[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php') =]] ``` @@ -77,7 +77,7 @@ See [Action Configuration Search Criteria reference](action_configuration_criter The following example creates a new Action Configuration: ``` php hl_lines="3 17" -[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 62, 79) =]] +[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 46, 63) =]] ``` Actions Configurations are tied to a specific Action Type and are translatable. @@ -88,7 +88,7 @@ Reuse existing Action Configurations to simplify the execution of AI Actions. You can pass one directly to the `ActionServiceInterface::execute()` method: ``` php hl_lines="7-8" -[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 80, 88) =]] +[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 64, 72) =]] ``` The passed Action Configuration is only taken into account if the Action Context was not passed to the Action directly using the [ActionInterface::setActionContext()](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionInterface.html#method_hasActionContext) method. @@ -116,7 +116,7 @@ Create a class implementing the [ActionHandlerInterface](/api/php_api/php_api_re See the code sample below, together with a matching service definition: -``` php hl_lines="21 29-32 34-69 71-74" +``` php hl_lines="17 25-28 30-65 67-70" [[= include_file('code_samples/ai_actions/src/AI/Handler/LLaVaTextToTextActionHandler.php') =]] ``` diff --git a/docs/api/php_api/php_api.md b/docs/api/php_api/php_api.md index c194d34865..c4917c04d8 100644 --- a/docs/api/php_api/php_api.md +++ b/docs/api/php_api/php_api.md @@ -126,7 +126,7 @@ While [using `sudo()`](#using-sudo) is the recommended option, you can also set To identify as a different user, you need to use the `UserService` together with `PermissionResolver` (in the example `admin` is the login of the administrator user): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 55, 57) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 40, 41) =]] ``` !!! tip diff --git a/docs/commerce/cart/cart_api.md b/docs/commerce/cart/cart_api.md index 0d6855db34..d8208d737a 100644 --- a/docs/commerce/cart/cart_api.md +++ b/docs/commerce/cart/cart_api.md @@ -23,7 +23,7 @@ From the developer's perspective, carts and entries are referenced with a UUID i To access a single cart, use the `CartServiceInterface::getCart` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 91) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 66) =]] ``` ## Get multiple carts @@ -35,7 +35,7 @@ It follows the same search Query pattern as other APIs: [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 10, 11) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 74, 83) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 49, 57) =]] ``` ## Create cart @@ -46,7 +46,7 @@ To create a cart, use the `CartServiceInterface::createCart` method and provide [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 8, 9) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 95, 104) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 70, 78) =]] ``` ## Update cart metadata @@ -59,7 +59,7 @@ To update cart metadata, use the `CartServiceInterface::updateCartMetadata` meth [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 9, 10) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 107, 114) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 82, 89) =]] ``` You can also use this method to change cart ownership: @@ -80,8 +80,8 @@ $cart = $cartService->updateCartMetadata($cart, $updateMetadataStruct); To delete a cart permanently, use the `CartServiceInterface::deleteCart` method and pass the `CartInterface` object: ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 89) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 149, 150) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 124, 125) =]] ``` ## Empty cart @@ -89,8 +89,8 @@ To delete a cart permanently, use the `CartServiceInterface::deleteCart` method To remove all products from the cart in a single operation, use the `CartServiceInterface::emptyCart` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 89) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 116, 117) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 91, 92) =]] ``` ## Check cart validity @@ -101,8 +101,8 @@ To validate the cart, use the `CartServiceInterface::validateCart` method. Validation is done with help from the `symfony/validator` component, and the method returns a `Symfony\Component\Validator\ConstraintViolationListInterface` object. ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 89) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 119, 120) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 94, 95) =]] ``` ## Add entry to cart @@ -114,8 +114,8 @@ Then pass it to the `CartServiceInterface::addEntry` method: [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 11, 12) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 89) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 124, 131) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 99, 106) =]] ``` ## Remove entry from cart @@ -123,11 +123,8 @@ Then pass it to the `CartServiceInterface::addEntry` method: To remove an entry from the cart, use the `CartServiceInterface::removeEntry` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 11, 12) =]] -// ... - -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 89) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 134, 137) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 109, 112) =]] ``` ## Update entry metadata @@ -139,9 +136,9 @@ To change entry metadata, use the `CartServiceInterface::updateEntry` method and [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 12, 13) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 89) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 129, 130) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 139, 147) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 109, 110) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 114, 122) =]] ``` ## Adding context data @@ -188,5 +185,5 @@ To combine the contents of multiple shopping carts into a target cart, use the ` This operation is helpful when you want to consolidate items from a reorder cart and a current cart into a single order. ```php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 151, 164) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 126, 139) =]] ``` diff --git a/docs/commerce/checkout/checkout_api.md b/docs/commerce/checkout/checkout_api.md index b45f220587..42e79c59a3 100644 --- a/docs/commerce/checkout/checkout_api.md +++ b/docs/commerce/checkout/checkout_api.md @@ -22,7 +22,7 @@ From the developer's perspective, checkouts are referenced with an UUID identifi To access a single checkout, use the `CheckoutServiceInterface::getCheckout` method: ``` php -[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 32, 33) =]] +[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 28, 29) =]] ``` ## Get single checkout for specific cart @@ -31,7 +31,7 @@ To fetch checkout for a cart that already exists, use the `CheckoutServiceInterf You can use it when you want to initiate the checkout process right after products are successfully added to a cart. ``` php -[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 26, 30) =]] +[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 22, 26) =]] ``` ## Create checkout @@ -39,7 +39,7 @@ You can use it when you want to initiate the checkout process right after produc To create a checkout, use the `CheckoutServiceInterface::createCheckout` method and provide it with a `CheckoutCreateStruct` struct that contains a `CartInterface` object. ``` php -[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 35, 41) =]] +[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 31, 37) =]] ``` ## Update checkout @@ -53,7 +53,7 @@ To update the checkout, use the `CheckoutServiceInterface::updateCheckout` metho All data is placed in session storage. ``` php -[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 43, 45) =]] +[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 39, 41) =]] ``` ## Delete checkout @@ -61,5 +61,5 @@ All data is placed in session storage. To delete a checkout from the session, use the `CheckoutServiceInterface::deleteCheckout` method: ``` php -[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 47, 48) =]] +[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 43, 44) =]] ``` diff --git a/docs/commerce/order_management/order_management_api.md b/docs/commerce/order_management/order_management_api.md index 9fc9bd0f4f..640221200f 100644 --- a/docs/commerce/order_management/order_management_api.md +++ b/docs/commerce/order_management/order_management_api.md @@ -19,7 +19,7 @@ To get orders and manage them, use the [`Ibexa\Contracts\OrderManagement\OrderSe To access a single order by using its string identifier, use the [`OrderServiceInterface::getOrderByIdentifier`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_getOrderByIdentifier) method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 61, 65) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 51, 55) =]] ``` ### Get single order by ID @@ -27,7 +27,7 @@ To access a single order by using its string identifier, use the [`OrderServiceI To access a single order by using its numerical ID, use the [`OrderServiceInterface::getOrder`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_getOrder) method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 67, 72) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 57, 61) =]] ``` ## Get multiple orders @@ -39,7 +39,7 @@ It follows the same search query pattern as other APIs: [[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 8, 9) =]][[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 10, 14) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 120, 130) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 110, 119) =]] ``` ## Create order @@ -47,7 +47,7 @@ It follows the same search query pattern as other APIs: To create an order, use the [`OrderServiceInterface::createOrder`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_createOrder) method and provide it with the [`Ibexa\Contracts\OrderManagement\Value\Struct\OrderCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-Value-Struct-OrderCreateStruct.html) object that contains a list of products, purchased quantities, product, total prices, and tax amounts. ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 101, 113) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 91, 102) =]] ``` ## Update order @@ -57,5 +57,5 @@ You could do it to support a scenario when, for example, the order is processed To update order information, use the [`OrderServiceInterface::updateOrder`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_updateOrder) method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 114, 119) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 104, 108) =]] ``` diff --git a/docs/commerce/payment/extend_payment.md b/docs/commerce/payment/extend_payment.md index feb410f7a7..eb76cde4af 100644 --- a/docs/commerce/payment/extend_payment.md +++ b/docs/commerce/payment/extend_payment.md @@ -94,11 +94,11 @@ When you create a payment, you can attach custom data to it, for example, you ca You add custom data by using the `setContext` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 97, 109) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 81, 93) =]] ``` Then, you retrieve it with the `getContext` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 70, 74) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 54, 58) =]] ``` diff --git a/docs/commerce/payment/payment_api.md b/docs/commerce/payment/payment_api.md index 93d416df7f..96a6850814 100644 --- a/docs/commerce/payment/payment_api.md +++ b/docs/commerce/payment/payment_api.md @@ -17,7 +17,7 @@ You can change that by providing a custom payment identifier in `Ibexa\Contracts To access a single payment by using its numerical ID, use the `PaymentServiceInterface::getPayment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 64, 68) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 48, 52) =]] ``` ### Get single payment by identifier @@ -25,7 +25,7 @@ To access a single payment by using its numerical ID, use the `PaymentServiceInt To access a single payment by using its string identifier, use the `PaymentServiceInterface::getPaymentByIdentifier` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 70, 72) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 54, 56) =]] ``` ## Get multiple payments @@ -34,7 +34,7 @@ To fetch multiple payments, use the `PaymentServiceInterface::findPayments` meth It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 79, 95) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 63, 79) =]] ``` ## Create payment @@ -42,8 +42,7 @@ It follows the same search query pattern as other APIs: To create a payment, use the `PaymentServiceInterface::createPayment` method and provide it with the `Ibexa\Contracts\Payment\Payment\PaymentCreateStruct` object that takes the following arguments: `method`, `order` and `amount`. ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 101, 105) =]] -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 108, 112) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 81, 95) =]] ``` ## Update payment @@ -54,7 +53,7 @@ The `Ibexa\Contracts\Payment\Payment\PaymentUpdateStruct` object takes the follo To update payment information, use the `PaymentServiceInterface::updatePayment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 113, 119) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 97, 103) =]] ``` ## Delete payment @@ -62,5 +61,5 @@ To update payment information, use the `PaymentServiceInterface::updatePayment` To delete a payment from the system, use the `PaymentServiceInterface::deletePayment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 121, 122) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 105, 106) =]] ``` diff --git a/docs/commerce/payment/payment_method_api.md b/docs/commerce/payment/payment_method_api.md index 00856a67aa..61ff2ee38f 100644 --- a/docs/commerce/payment/payment_method_api.md +++ b/docs/commerce/payment/payment_method_api.md @@ -26,7 +26,7 @@ From the developer's perspective, payment methods are referenced with identifier To access a single payment method by using its string identifier, use the `PaymentMethodService::getPaymentMethodByIdentifier` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 56, 60) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 46, 50) =]] ``` ### Get single payment method by ID @@ -34,7 +34,7 @@ To access a single payment method by using its string identifier, use the `Payme To access a single payment method by using its numerical ID, use the `PaymentMethodService::getPaymentMethod` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 50, 54) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 40, 44) =]] ``` ## Get multiple payment methods @@ -44,7 +44,7 @@ To fetch multiple payment methods, use the `PaymentMethodService::findPaymentMet It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 62, 79) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 52, 69) =]] ``` ## Create payment method @@ -59,7 +59,7 @@ To create a payment method, use the `PaymentMethodService::createPaymentMethod` - `options` object. ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 62, 63) =]][[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 81, 91) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 52, 53) =]][[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 71, 81) =]] ``` ## Update payment method @@ -70,14 +70,14 @@ An `Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodUpdateStruct` object can To update payment method information, use the `PaymentMethodServiceInterface::updatePaymentMethod` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 93, 103) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 83, 93) =]] ``` ## Delete payment method To delete a payment method from the system, use the `PaymentMethodService::deletePayment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 105, 111) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 95, 101) =]] ``` ## Check whether payment method is used @@ -85,5 +85,5 @@ To delete a payment method from the system, use the `PaymentMethodService::delet To check whether a payment method is used, for example, before you delete it, use the `PaymentMethodService::isPaymentMethodUsed` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 113, 126) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 103, 116) =]] ``` diff --git a/docs/commerce/shipping_management/shipment_api.md b/docs/commerce/shipping_management/shipment_api.md index 3d6140a151..48f605d864 100644 --- a/docs/commerce/shipping_management/shipment_api.md +++ b/docs/commerce/shipping_management/shipment_api.md @@ -16,7 +16,7 @@ From the developer's perspective, shipments are referenced with a UUID identifie To access a single shipment by using its string identifier, use the `ShipmentService::getShipmentByIdentifier` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 73, 82) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 57, 66) =]] ``` ### Get single shipment by id @@ -24,7 +24,7 @@ To access a single shipment by using its string identifier, use the `ShipmentSer To access a single shipment by using its numerical id, use the `ShipmentService::getShipment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 61, 71) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 45, 55) =]] ``` ## Get multiple shipments @@ -33,7 +33,7 @@ To fetch multiple shipments, use the `ShipmentService::findShipments` method. It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 84, 103) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 68, 87) =]] ``` ## Create shipment @@ -41,7 +41,7 @@ It follows the same search query pattern as other APIs: To create a shipment, use the `ShipmentService::createShipment` method and provide it with an `Ibexa\Contracts\Shipping\Value\ShipmentCreateStruct` object that takes two parameters, a `shippingMethod` string and a `Money` object. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 105, 119) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 89, 103) =]] ``` ## Update shipment @@ -51,7 +51,7 @@ You could do it to support a scenario when, for example, the shipment is process To update shipment information, use the `ShipmentService::updateShipment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 121, 132) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 105, 116) =]] ``` ## Delete shipment @@ -59,5 +59,5 @@ To delete a shipment from the system, use the `ShipmentService::deleteShipment` ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 134, 135) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 118, 119) =]] ``` diff --git a/docs/commerce/shipping_management/shipping_method_api.md b/docs/commerce/shipping_management/shipping_method_api.md index a869cd3570..6a47fc1687 100644 --- a/docs/commerce/shipping_management/shipping_method_api.md +++ b/docs/commerce/shipping_management/shipping_method_api.md @@ -17,7 +17,7 @@ To access a shipping method by using its identifier, use the `ShippingMethodServ The method takes a string as `$identifier` parameter and uses a prioritized language from SiteAccess settings unless you pass another language as `forcedLanguage`. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 65, 75) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 52, 62) =]] ``` ### Get shipping method by ID @@ -26,7 +26,7 @@ To access a shipping method by using its ID, use the `ShippingMethodServiceInter The method takes a string as `$id` parameter and uses a prioritized language from SiteAccess settings unless you pass another language as `forcedLanguage`. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 53, 63) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 40, 50) =]] ``` ## Get multiple shipping methods @@ -35,7 +35,7 @@ To fetch multiple shipping methods, use the `ShippingMethodServiceInterface::get It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 77, 95) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 64, 82) =]] ``` ## Create shipping method @@ -43,7 +43,7 @@ It follows the same search query pattern as other APIs: To create a shipping method, use the `ShippingMethodServiceInterface::createShippingMethod` method and provide it with the `Ibexa\Contracts\Shipping\Value\ShippingMethodCreateStruct` object that you created by using the `newShippingMethodCreateStruct` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 97, 120) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 84, 107) =]] ``` ## Update shipping method @@ -51,7 +51,7 @@ To create a shipping method, use the `ShippingMethodServiceInterface::createShip To update a shipping method, use the `ShippingMethodServiceInterface::updateShippingMethod` method and provide it with the `Ibexa\Contracts\Shipping\Value\ShippingMethodUpdateStruct` object that you created by using the `newShippingMethodUpdateStruct` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 122, 137) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 109, 123) =]] ``` ## Delete shipping method @@ -59,7 +59,7 @@ To update a shipping method, use the `ShippingMethodServiceInterface::updateShip To update a shipping method, use the `ShippingMethodServiceInterface::deleteShippingMethod` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 138, 144) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 125, 131) =]] ``` ## Delete shipping method translation @@ -67,5 +67,5 @@ To update a shipping method, use the `ShippingMethodServiceInterface::deleteShip To delete shipping method translation, use the `ShippingMethodServiceInterface::deleteShippingMethodTranslation` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 146, 155) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 133, 142) =]] ``` diff --git a/docs/content_management/content_api/browsing_content.md b/docs/content_management/content_api/browsing_content.md index 03fcbcd953..5636fa90e8 100644 --- a/docs/content_management/content_api/browsing_content.md +++ b/docs/content_management/content_api/browsing_content.md @@ -25,16 +25,16 @@ This value object provides primitive fields, such as `contentTypeId`, `published You can also use it to request other Content-related value objects from various services: -``` php hl_lines="10" +``` php hl_lines="8" // ... [[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 4, 5) =]] -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 20, 22) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 18, 22) =]] // ... -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 55, 57) =]][[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 63, 72) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 44, 46) =]][[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 54, 65) =]] ``` -`ContentInfo` is loaded from the [`ContentService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html) (line 9). +`ContentInfo` is loaded from the [`ContentService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html) (line 8). It provides you with basic content metadata such as modification and publication dates or main language code. !!! note "Retrieving content information in a controller" @@ -46,7 +46,7 @@ It provides you with basic content metadata such as modification and publication To get the locations of a content item you need to make use of the [`LocationService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 73, 77) =]] } +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 55, 61) =]] ``` [`LocationService::loadLocations`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_loadLocations) uses `ContentInfo` to get all the locations of a content item. diff --git a/docs/content_management/content_api/creating_content.md b/docs/content_management/content_api/creating_content.md index 7f8997a167..7cd1df6a04 100644 --- a/docs/content_management/content_api/creating_content.md +++ b/docs/content_management/content_api/creating_content.md @@ -20,18 +20,18 @@ Value objects such as content items are read-only, so to create or modify them y [`ContentService::newContentCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_newContentCreateStruct) returns a new [`ContentCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentCreateStruct.html) object. -``` php hl_lines="2-3 5" -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 62, 71) =]] +``` php hl_lines="1-2 6" +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 47, 53) =]] ``` -This command creates a draft using [`ContentService::createContent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_createContent) (line 7). +This command creates a draft using [`ContentService::createContent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_createContent) (line 6). This method must receive a `ContentCreateStruct` and an array of location structs. -`ContentCreateStruct` (which extends `ContentStruct`) is created through [`ContentService::newContentCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_newContentCreateStruct) (line 2), +`ContentCreateStruct` (which extends `ContentStruct`) is created through [`ContentService::newContentCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_newContentCreateStruct) (line 1), which receives the content type and the primary language for the content item. For information about translating a content item into other languages, see [Translating content](#translating-content). -[`ContentStruct::setField`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentStruct.html#method_setField) (line 3) enables you to define the field values. +[`ContentStruct::setField`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentStruct.html#method_setField) (line 2) enables you to define the field values. When the field accepts a simple value, you can provide it directly, as in the example above. For some field types, for example [images](#creating-an-image), you need to provide an instance of a Value type. @@ -42,7 +42,7 @@ Therefore, when creating a content item of the Image type (or any other content the `ContentCreateStruct` is slightly more complex than in the previous example: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateImageCommand.php', 61, 74) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateImageCommand.php', 47, 62) =]] ``` Value of the Image field type contains the path to the image file and other basic information based on the input file. @@ -66,7 +66,7 @@ To publish it, use [`ContentService::publishVersion`](/api/php_api/php_api_refer This method must get the [`VersionInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-VersionInfo.html) object of a draft version. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 73, 74) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 58, 59) =]] ``` ## Updating content @@ -76,7 +76,7 @@ and pass it to [`ContentService::updateContent`](/api/php_api/php_api_reference/ This method works on a draft, so to publish your changes you need to use [`ContentService::publishVersion`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_publishVersion) as well: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/UpdateContentCommand.php', 52, 60) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/UpdateContentCommand.php', 45, 50) =]] ``` ## Translating content @@ -86,15 +86,15 @@ Content [translations](languages.md#language-versions) are created per version. To translate a content item to a new language, you need to update it and provide a new `initialLanguageCode`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 57, 62) =]] -[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 67, 69) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 50, 52) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 58, 60) =]] ``` You can also update content in multiple languages at once using the `setField` method's third argument. Only one language can still be set as a version's initial language: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 64, 65) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 55, 55) =]] ``` ### Deleting a translation diff --git a/docs/content_management/content_api/managing_content.md b/docs/content_management/content_api/managing_content.md index 858c023f52..827da71f16 100644 --- a/docs/content_management/content_api/managing_content.md +++ b/docs/content_management/content_api/managing_content.md @@ -22,8 +22,8 @@ Creating a new location, like creating content, requires using a struct, because To add a new location to existing content you need to create a [`LocationCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-LocationCreateStruct.html) and pass it to the [`LocationService::createLocation`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_createLocation) method: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 55, 56) =]] -[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 60, 62) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 46, 47) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 51, 53) =]] ``` `LocationCreateStruct` must receive the parent location ID. @@ -32,7 +32,7 @@ It sets the `parentLocationId` property of the new location. You can also provide other properties for the location, otherwise they're set to their defaults: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 57, 59) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 48, 50) =]] ``` ### Changing the main location @@ -41,7 +41,7 @@ When a content item has more that one location, one location is always considere You can change the main location using [`ContentService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html), by updating the `ContentInfo` with a [`ContentUpdateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentUpdateStruct.html) that sets the new main location: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php', 53, 57) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php', 46, 51) =]] ``` ### Hiding and revealing locations @@ -49,7 +49,8 @@ You can change the main location using [`ContentService`](/api/php_api/php_api_r To hide or reveal (unhide) a location you need to make use of [`LocationService::hideLocation`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_hideLocation) or [`LocationService::unhideLocation`:](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_unhideLocation) ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 51, 52) =]][[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 54, 55) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 44, 45) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 47, 48) =]] ``` See [location visibility](locations.md#location-visibility) for detailed information on the behavior of visible and hidden Locations. @@ -66,14 +67,14 @@ Content which has more locations is still available in its other locations. If you delete the [main location](#changing-the-main-location) of a content item that has more locations, another location becomes the main one. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/DeleteContentCommand.php', 49, 50) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/DeleteContentCommand.php', 40, 43) =]] ``` To send the location and its subtree to Trash, use [`TrashService::trash`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-TrashService.html#method_trash). Items in Trash can be later [restored, or deleted permanently](#trash). ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 59, 60) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 50, 51) =]] ``` ### Moving and copying a subtree @@ -81,7 +82,7 @@ Items in Trash can be later [restored, or deleted permanently](#trash). You can move a location with its whole subtree using [`LocationService::moveSubtree`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_moveSubtree): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/MoveContentCommand.php', 51, 54) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/MoveContentCommand.php', 44, 47) =]] ``` [`LocationService::copySubtree`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_copySubtree) is used in the same way, but it copies the location and its subtree instead of moving it. @@ -108,7 +109,7 @@ You must provide the method with the ID of the object in Trash. Trash location is identical to the origin location of the object. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 69, 70) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 60, 61) =]] ``` The content item is restored under its previous location. @@ -138,13 +139,14 @@ In this case you use [`ContentTypeCreateStruct`](/api/php_api/php_api_reference/ A content type must have at least one name, in the main language, and at least one field definition. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 64, 74) =]][[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 81, 90) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 56, 66) =]][[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 73, 82) =]] + ``` You can specify more details of the field definition in the create struct, for example: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 72, 82) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 64, 74) =]] ``` ### Copying content types @@ -152,7 +154,7 @@ You can specify more details of the field definition in the create struct, for e To copy a content type, use [`ContentTypeService::copyContentType`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentTypeService.html#method_copyContentType): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 94, 95) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 85, 88) =]] ``` The copy is automatically getting an identifier based on the original content type identifier and the copy's ID, for example: `copy_of_folder_21`. @@ -160,7 +162,7 @@ The copy is automatically getting an identifier based on the original content ty To change the identifier of the copy, use a [`ContentTypeUpdateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-ContentTypeUpdateStruct.html): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 95, 101) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 87, 93) =]] ``` ## Calendar events @@ -177,19 +179,19 @@ To get a list of events for a specified time period, use the `CalendarServiceInt You need to provide the method with an EventQuery, which takes a date range and a count as the minimum of parameters: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 44, 55) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 37, 48) =]] ``` You can also get the first and last event in the list by using the `first()` and `last()` methods of an `EventCollection` (`Ibexa\Contracts\Calendar\EventCollection`): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 56, 58) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 49, 51) =]] ``` You can process the events in a collection using the `find(Closure $predicate)`, `filter(Closure $predicate)`, `map(Closure $callback)` or `slice(int $offset, ?int $length = null)` methods of `EventCollection`, for example: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 59, 62) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 52, 56) =]] ``` ### Performing calendar actions @@ -199,9 +201,5 @@ You must pass an `Ibexa\Contracts\Calendar\EventAction\EventActionContext` insta `EventActionContext` defines events on which the action is performed, and action-specific parameters, for example, a new date: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 64, 66) =]] -``` - -``` php -$context = new UnscheduleEventActionContext($eventCollection); +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 57, 61) =]] ``` diff --git a/docs/content_management/content_management_api/bookmark_api.md b/docs/content_management/content_management_api/bookmark_api.md index 63f5ba6176..8f57d51d51 100644 --- a/docs/content_management/content_management_api/bookmark_api.md +++ b/docs/content_management/content_management_api/bookmark_api.md @@ -13,17 +13,17 @@ description: You can use the PHP API to view the bookmark list, and add or remov To view a list of all bookmarks, use [`BookmarkService::loadBookmarks`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-BookmarkService.html#method_loadBookmarks): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/BookmarkCommand.php', 48, 55) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/BookmarkCommand.php', 42, 48) =]] ``` You can add a bookmark to a content item by providing its Location object to the [`BookmarkService::createBookmark`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-BookmarkService.html#method_createBookmark) method: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/BookmarkCommand.php', 42, 45) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/BookmarkCommand.php', 38, 40) =]] ``` You can remove a bookmark from a location with [`BookmarkService::deleteBookmark`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-BookmarkService.html#method_deleteBookmark): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/BookmarkCommand.php', 57, 58) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/BookmarkCommand.php', 51, 51) =]] ``` diff --git a/docs/content_management/content_management_api/object_state_api.md b/docs/content_management/content_management_api/object_state_api.md index 8d907897cf..7f65271c04 100644 --- a/docs/content_management/content_management_api/object_state_api.md +++ b/docs/content_management/content_management_api/object_state_api.md @@ -18,7 +18,7 @@ You can manage Object states by using the PHP API by using `ObjectStateService`. You can use the [`ObjectStateService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ObjectStateService.html) to get information about object state groups or object states. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 48, 53) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 41, 46) =]] ``` ## Creating object states @@ -26,7 +26,7 @@ You can use the [`ObjectStateService`](/api/php_api/php_api_reference/classes/Ib To create an object state group and add object states to it, you need to make use of the [`ObjectStateService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ObjectStateService.html): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 57, 61) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 50, 54) =]] ``` [`ObjectStateService::createObjectStateGroup`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ObjectStateService.html#method_createObjectStateGroup) takes as argument an [`ObjectStateGroupCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ObjectState-ObjectStateGroupCreateStruct.html), in which you need to specify the identifier, default language and at least one name for the group. @@ -34,7 +34,7 @@ To create an object state group and add object states to it, you need to make us To create an object state inside a group, use [`ObjectStateService::newObjectStateCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ObjectStateService.html#method_newObjectStateCreateStruct) and provide it with an `ObjectStateCreateStruct`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 63, 67) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 56, 60) =]] ``` ## Assigning object state @@ -43,5 +43,5 @@ To assign an object state to a content item, use [`ObjectStateService::setConten Provide it with a `ContentInfo` object of the content item, the object state group and the object state: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 77, 82) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 71, 75) =]] ``` diff --git a/docs/content_management/content_management_api/section_api.md b/docs/content_management/content_management_api/section_api.md index fff9973e03..f93c0760f2 100644 --- a/docs/content_management/content_management_api/section_api.md +++ b/docs/content_management/content_management_api/section_api.md @@ -17,7 +17,7 @@ You can manage sections by using the PHP API by using `SectionService`. To create a new section, you need to make use of the [`SectionCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-SectionCreateStruct.html) and pass it to the [`SectionService::createSection`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-SectionService.html#method_createSection) method: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 58, 62) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 48, 52) =]] ``` ## Getting section information @@ -25,7 +25,7 @@ To create a new section, you need to make use of the [`SectionCreateStruct`](/ap You can use `SectionService` to retrieve section information such as whether it's in use: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 76, 81) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 66, 71) =]] ``` ## Listing content in a section @@ -34,7 +34,7 @@ To list content items assigned to a section you need to make a [query](search_ap You can also use the query to get the total number of assigned content items: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 69, 75) =]][[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 82, 86) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 59, 65) =]][[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 72, 76) =]] ``` ## Assigning section to content @@ -43,7 +43,7 @@ To assign content to a section, use the [`SectionService::assignSection`](/api/p You need to provide it with the `ContentInfo` object of the content item, and the [`Section`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Section.html) object: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 64, 67) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 54, 57) =]] ``` Assigning a section to content doesn't automatically assign it to the content item's children. diff --git a/docs/content_management/data_migration/data_migration_api.md b/docs/content_management/data_migration/data_migration_api.md index 53a17c8a6b..53c247b17c 100644 --- a/docs/content_management/data_migration/data_migration_api.md +++ b/docs/content_management/data_migration/data_migration_api.md @@ -11,13 +11,13 @@ You can use the PHP API to manage and run [data migrations](data_migration.md). To list all migration files available in the directory defined in configuration (by default, `src/Migrations/Ibexa`), use the `MigrationService:listMigrations()` method: ``` php -[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 35, 38) =]] +[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 31, 34) =]] ``` To get a single migration file by its name, use the `MigrationService:findOneByName()` method: ``` php -[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 40, 41) =]] +[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 36, 37) =]] ``` ## Running migration files @@ -25,7 +25,7 @@ To get a single migration file by its name, use the `MigrationService:findOneByN To run migration file(s), use either `MigrationService:executeOne()` or `MigrationService:executeAll()`: ``` php -[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 42, 44) =]] +[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 38, 40) =]] ``` Both `executeOne()` and `executeAll()` can take an optional parameter: the login of the User that you want to execute the migrations as. @@ -35,5 +35,5 @@ Both `executeOne()` and `executeAll()` can take an optional parameter: the login To add a new migration file, use the `MigrationService:add()` method: ``` php -[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 28, 34) =]] +[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 24, 30) =]] ``` diff --git a/docs/content_management/forms/form_api.md b/docs/content_management/forms/form_api.md index c0c9930445..925f089962 100644 --- a/docs/content_management/forms/form_api.md +++ b/docs/content_management/forms/form_api.md @@ -14,13 +14,13 @@ To manage form submissions created in the [Form Builder](form_builder_guide.md), To get existing form submissions, use `FormSubmissionServiceInterface::loadByContent()` (which takes a `ContentInfo` object as parameter), or `FormSubmissionServiceInterface::loadById()`. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 54, 55) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 46, 46) =]] ``` Through this object, you can get information about submissions, such as their total number, and submission contents. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 55, 66) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 48, 56) =]] ``` ### Creating form submissions @@ -35,7 +35,7 @@ This method takes: - the array of form field values ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 40, 53) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 32, 44) =]] ``` ### Deleting form submissions @@ -43,5 +43,5 @@ This method takes: You can delete a form submission by using the `FormSubmissionServiceInterface::delete()` method. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 66, 68) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 58, 59) =]] ``` diff --git a/docs/content_management/taxonomy/taxonomy_api.md b/docs/content_management/taxonomy/taxonomy_api.md index 3a46b2322f..aa5f85e69c 100644 --- a/docs/content_management/taxonomy/taxonomy_api.md +++ b/docs/content_management/taxonomy/taxonomy_api.md @@ -14,7 +14,7 @@ Or pass entry identifier (with optionally a taxonomy identifier), and use `TaxonomyServiceInterface::loadEntryByIdentifier()`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 43, 46) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 35, 37) =]] ``` !!! note @@ -37,7 +37,7 @@ The default taxonomy identifier is given by `TaxonomyConfiguration::getDefaultTa The default limit is 30. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 41, 42) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 33, 33) =]] ``` To see how many entries is there, use `TaxonomyServiceInterface::countAllEntries()` with optionally a taxonomy identifier. @@ -47,7 +47,7 @@ provide it with the entry object, and optionally specify the limit of results an The default limit is 30: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 48, 53) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 40, 44) =]] ``` ## Managing taxonomy entries @@ -56,7 +56,7 @@ You can move a taxonomy entry to a different parent by using `TaxonomyServiceInt Provide the method with two objects: the entry that you want to move and the new parent entry: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 54, 58) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 46, 49) =]] ``` You can also move a taxonomy entry by passing its target sibling entry to `TaxonomyServiceInterface::moveEntry()`. @@ -64,7 +64,7 @@ The method takes as parameters the entry you want to move, the future sibling, and a `position` parameter, which is either `TaxonomyServiceInterface::MOVE_POSITION_NEXT` or `TaxonomyServiceInterface::MOVE_POSITION_PREV`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 59, 61) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 51, 52) =]] ``` !!! note diff --git a/docs/content_management/url_management/url_api.md b/docs/content_management/url_management/url_api.md index 94d93a1476..cc8188c003 100644 --- a/docs/content_management/url_management/url_api.md +++ b/docs/content_management/url_management/url_api.md @@ -19,9 +19,9 @@ in which you need to specify: ```php // ... -[[= include_file('code_samples/api/public_php_api/src/Command/FindUrlCommand.php', 7, 10) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindUrlCommand.php', 6, 10) =]] // ... -[[= include_file('code_samples/api/public_php_api/src/Command/FindUrlCommand.php', 41, 56) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindUrlCommand.php', 32, 51) =]] ``` ## URL search reference diff --git a/docs/content_management/workflow/workflow_api.md b/docs/content_management/workflow/workflow_api.md index d6c46a6975..157d436373 100644 --- a/docs/content_management/workflow/workflow_api.md +++ b/docs/content_management/workflow/workflow_api.md @@ -25,7 +25,7 @@ but the implementation in workflow service extends them, for example by providin To get information about a specific workflow for a content item, use `WorkflowServiceInterface::loadWorkflowMetadataForContent`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 58, 63) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 49, 53) =]] ``` !!! tip @@ -36,7 +36,7 @@ To get information about a specific workflow for a content item, use `WorkflowSe To get a list of all workflows that can be used for a given content item, use `WorkflowRegistry`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 52, 53) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 43, 46) =]] ``` ## Applying workflow transitions @@ -44,14 +44,14 @@ To get a list of all workflows that can be used for a given content item, use `W To place a content item in a workflow, use `WorkflowService::start`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 57, 58) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 48, 48) =]] ``` To apply a transition to a content item, use `Workflow::apply`. Additionally, you can check if the transition is possible for the given object using `WorkflowService::can`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 64, 69) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 55, 59) =]] ``` !!! tip diff --git a/docs/multisite/languages/language_api.md b/docs/multisite/languages/language_api.md index 7b5f850fcc..5450ea53b4 100644 --- a/docs/multisite/languages/language_api.md +++ b/docs/multisite/languages/language_api.md @@ -11,7 +11,7 @@ You can manage languages configured in the system with PHP API by using [`Langua To get a list of all languages in the system use [`LanguageService::loadLanguages`:](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LanguageService.html#method_loadLanguage) ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 42, 47) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 31, 37) =]] ``` ## Creating a language @@ -20,5 +20,5 @@ To create a new language, you need to create a [`LanguageCreateStruct`](/api/php Then, use [`LanguageService::createLanguage`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LanguageService.html#method_createLanguage) and pass the `LanguageCreateStruct` to it: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 48, 52) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 37, 42) =]] ``` diff --git a/docs/multisite/siteaccess/siteaccess_aware_configuration.md b/docs/multisite/siteaccess/siteaccess_aware_configuration.md index bf77dc3974..33e74240ca 100644 --- a/docs/multisite/siteaccess/siteaccess_aware_configuration.md +++ b/docs/multisite/siteaccess/siteaccess_aware_configuration.md @@ -68,7 +68,7 @@ Semantic configuration must always be mapped to internal key/value settings with You usually do it in the [service container](php_api.md#service-container) extension. ``` php -[[= include_file('code_samples/multisite/siteaccess/AcmeExampleExtension.php', 0, 42) =]][[= include_file('code_samples/multisite/siteaccess/AcmeExampleExtension.php', 53, 61) =]] +[[= include_file('code_samples/multisite/siteaccess/AcmeExampleExtension.php', 0, 42) =]][[= include_file('code_samples/multisite/siteaccess/AcmeExampleExtension.php', 53, 62) =]] ``` You can also map simple settings by calling `$processor->mapSetting()`, without having to call `$processor->mapConfig()` with a callable. diff --git a/docs/pim/catalog_api.md b/docs/pim/catalog_api.md index 2caa8d2ede..c16c54a2c5 100644 --- a/docs/pim/catalog_api.md +++ b/docs/pim/catalog_api.md @@ -11,7 +11,7 @@ To get information about product catalogs and manage them, use `CatalogServiceIn To get a single catalog, use `Ibexa\Contracts\ProductCatalog\CatalogServiceInterface::getCatalog()` and provide it with catalog ID, or `CatalogServiceInterface::getCatalogByIdentifier()` and pass the identifier: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 81, 83) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 68, 70) =]] ``` ## Get products in catalog @@ -20,7 +20,7 @@ To get products from a catalog, request the product query from the catalog objec Then, create a new `ProductQuery` based on it and run a product search with `ProductServiceInterface::findProduct()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 85, 91) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 72, 78) =]] ``` ## Create catalog @@ -29,7 +29,7 @@ To create a catalog, you need to prepare a `CatalogCreateStruct` that contains: Then, pass this struct to `CatalogServiceInterface::createCatalog()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 71, 79) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 51, 66) =]] ``` ## Update catalog @@ -39,5 +39,5 @@ You must pass the catalog object and a `CatalogUpdateStruct` to the method. In the following example, you update the catalog to publish it: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 93, 97) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 80, 84) =]] ``` diff --git a/docs/pim/price_api.md b/docs/pim/price_api.md index 6d26b2cee5..37c991ae0f 100644 --- a/docs/pim/price_api.md +++ b/docs/pim/price_api.md @@ -12,13 +12,13 @@ To access a currency object by its code, use `CurrencyServiceInterface::getCurre To access a whole list of currencies, use `CurrencyServiceInterface::findCurrencies`. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CurrencyCommand.php', 52, 61) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CurrencyCommand.php', 45, 53) =]] ``` To create a new currency, use `CurrencyServiceInterface::createCurrency()` and provide it with a `CurrencyCreateStruct` with code, number of fractional digits and a flag indicating if the currency is enabled: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CurrencyCommand.php', 67, 71) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CurrencyCommand.php', 60, 63) =]] ``` ## Prices @@ -28,19 +28,19 @@ To manage prices, use `ProductPriceService`. To retrieve the price of a product in the currency for the current context, use `Product::getPrice()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 79, 82) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 60, 63) =]] ``` To retrieve the price of a product in a specific currency, use `ProductPriceService::getPriceByProductAndCurrency`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 83, 86) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 64, 67) =]] ``` To get all prices (in different currencies) for a given product, use `ProductPriceService::findPricesByProductCode`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 97, 103) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 78, 84) =]] ``` To load price definitions that match given criteria, use `ProductPriceServiceInterface::findPrices`: @@ -48,14 +48,14 @@ To load price definitions that match given criteria, use `ProductPriceServiceInt ``` php [[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 12, 16) =]] // ... -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 104, 114) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 85, 95) =]] ``` You can also use `ProductPriceService` to create or modify existing prices. For example, to create a new price for a given currency, use `ProductPriceService::createProductPrice` and provide it with a `ProductPriceCreateStruct` object: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 79, 85) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 69, 75) =]] ``` !!! note @@ -80,7 +80,7 @@ To resolve a price of a product in the currency for the current context, use eit ``` php [[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 7, 8) =]][[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 11, 12) =]] // ... -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 115, 119) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 96, 100) =]] ``` ## VAT @@ -89,17 +89,17 @@ To get information about the VAT categories and rates configured in the system, VAT is configured per region, so you also need to use `RegionServiceInterface` to get the relevant region object. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 54, 55) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 41, 42) =]] ``` To get information about all VAT categories configured for the selected region, use `VatServiceInterface::getVatCategories()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 56, 61) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 43, 48) =]] ``` To get a single VAT category, use `VatServiceInterface::getVatCategoryByIdentifier()` and provide it with the region object and the identifier of the VAT category: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 62, 64) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 49, 50) =]] ``` diff --git a/docs/pim/product_api.md b/docs/pim/product_api.md index e2cb59219c..b12ec44821 100644 --- a/docs/pim/product_api.md +++ b/docs/pim/product_api.md @@ -21,7 +21,7 @@ month_change: false Get an individual product by using the `ProductServiceInterface::getProduct()` method: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 73, 76) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 54, 57) =]] ``` Find multiple products with `ProductServiceInterface::findProducts()`. @@ -29,7 +29,7 @@ Find multiple products with `ProductServiceInterface::findProducts()`. Provide the method with optional filter, query or Sort Clauses. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 77, 87) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 58, 68) =]] ``` See [Product Search Criteria](product_search_criteria.md) and [Product Sort Clauses](product_sort_clauses.md) references for more information about how to use the [`ProductQuery`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-Product-ProductQuery.html) class. @@ -39,7 +39,7 @@ See [Product Search Criteria](product_search_criteria.md) and [Product Sort Clau To create, update and delete products, use the `LocalProductServiceInterface`. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 98, 102) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 79, 83) =]] ``` To create a product, use `LocalProductServiceInterface::newProductCreateStruct()` to get a [`ProductCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-Values-Product-ProductCreateStruct.html). @@ -47,13 +47,13 @@ Provide the method with the product type object and the main language code. You also need to set (at least) the code for the product and the required Field of the underlying content type, `name`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 88, 95) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 69, 76) =]] ``` To delete a product, use `LocalProductServiceInterface::deleteProduct()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 125, 126) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 106, 107) =]] ``` ### Product variants @@ -65,13 +65,13 @@ A `ProductVariantQuery` lets you define the offset and limit of the variant quer The default offset is 0, and limit is 25. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 62, 65) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 49, 52) =]] ``` From a variant ([`ProductVariantInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-ProductVariantInterface.html)), you can access the attributes that are used to generate the variant by using `ProductVariantInterface::getDiscriminatorAttributes()`. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 66, 73) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 53, 60) =]] ``` #### Creating variants @@ -81,7 +81,7 @@ This method takes the product and an array of [`ProductVariantCreateStruct`](/ap `ProductVariantCreateStruct` specifies the attribute values and the code for the new variant. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 75, 81) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 62, 68) =]] ``` ### Product assets @@ -91,14 +91,14 @@ You can get assets assigned to a product by using [`AssetServiceInterface`](/api Use `AssetServiceInterface` to get a single asset by providing the product object and the assets's ID as parameters: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductAssetCommand.php', 59, 61) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductAssetCommand.php', 46, 48) =]] ``` To get all assets assigned to a product, use `AssetServiceInterface::findAssets()`. You can retrieve the tags (corresponding to attribute values) of assets with the `AssetInterface::getTags()` method: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductAssetCommand.php', 62, 71) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductAssetCommand.php', 49, 58) =]] ``` ## Product types @@ -108,13 +108,13 @@ To work with product types, use [`ProductTypeServiceInterface`](/api/php_api/php Get a product type object by using `ProductTypeServiceInterface::getProductType()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 48, 49) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 41, 42) =]] ``` You can also get a list of product types with `ProductTypeServiceInterface::findProductTypes()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 52, 57) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 45, 50) =]] ``` ## Product availability @@ -128,14 +128,14 @@ Get the availability object with `ProductAvailabilityServiceInterface::getAvaila You can then use `ProductAvailabilityServiceInterface::getStock()` to get the stock number for the product: ```php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 109, 114) =]] } +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 90, 95) =]] } ``` To change availability for a product, use `ProductAvailabilityServiceInterface::updateProductAvailability()` with a [`ProductAvailabilityUpdateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-Availability-ProductAvailabilityUpdateStruct.html) and provide it with the product object. The second parameter defines whether product is available, and the third whether its stock is infinite. The fourth parameter is the stock number: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 117, 120) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 98, 101) =]] ``` ## Attributes @@ -146,24 +146,24 @@ To get information about product attribute groups, use the [`AttributeGroupServi `AttributeGroupServiceInterface::findAttributeGroups()` gets attribute groups, all of them or filtered with an optional [`AttributeGroupQuery`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-AttributeGroup-AttributeGroupQuery.html) object: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 75, 76) =]] -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 96, 102) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 53, 54) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 74, 79) =]] ``` To create an attribute group, use `LocalAttributeGroupServiceinterface::createAttributeGroup()` and provide it with an [`AttributeGroupCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-Values-AttributeGroup-AttributeGroupCreateStruct.html): ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 69, 75) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 48, 52) =]] ``` To get information about product attributes, use the [`AttributeDefinitionServiceInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-AttributeDefinitionServiceInterface.html), or [`LocalAttributeDefinitionServiceInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-LocalAttributeDefinitionServiceInterface.html) to modify attributes. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 81, 85) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 60, 62) =]] ``` To create an attribute, use `LocalAttributeGroupServiceinterface::createAttributeDefinition()` and provide it with an [`AttributeDefinitionCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-Values-AttributeDefinition-AttributeDefinitionCreateStruct.html): ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 86, 94) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 65, 71) =]] ``` diff --git a/docs/search/search_api.md b/docs/search/search_api.md index 47238e952d..de1c1bca69 100644 --- a/docs/search/search_api.md +++ b/docs/search/search_api.md @@ -22,18 +22,18 @@ The service should be [injected into the constructor of your command or controll To search through content you need to create a [`LocationQuery`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-LocationQuery.html) and provide your Search Criteria as a series of Criterion objects. -For example, to search for all content of a selected content type, use one Criterion, [`Criterion\ContentTypeIdentifier`](contenttypeidentifier_criterion.md) (line 14). +For example, to search for all content of a selected content type, use one Criterion, [`Criterion\ContentTypeIdentifier`](contenttypeidentifier_criterion.md) (line 12). The following command takes the content type identifier as an argument and lists all results: -``` php hl_lines="14 16" +``` php hl_lines="12 14" // ... [[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 4, 7) =]]// ... -[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 16, 18) =]] // ... -[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 36, 52) =]]} +[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 14, 18) =]] // ... +[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 37, 45) =]]} ``` -[`SearchService::findContentInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-SearchService.html#method_findContentInfo) (line 16) +[`SearchService::findContentInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-SearchService.html#method_findContentInfo) (line 14) retrieves [`ContentInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Persistence-Content-ContentInfo.html) objects of the found content items. You can also use [`SearchService::findContent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-SearchService.html#method_findContent) to get full Content objects, together with their field information. @@ -116,19 +116,19 @@ It doesn't use the `SearchService` and isn't based on indexed data. For example, the following command lists all content items under the specified parent location and sorts them by name in descending order: -``` php hl_lines="13-16" +``` php hl_lines="11-14" // ... [[= include_file('code_samples/api/public_php_api/src/Command/FilterCommand.php', 4, 9) =]] // ... -[[= include_file('code_samples/api/public_php_api/src/Command/FilterCommand.php', 37, 57) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FilterCommand.php', 38, 49) =]] ``` The same Filter can be applied to find locations instead of content items, for example: -``` php hl_lines="17" +``` php hl_lines="15" // ... [[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 4, 9) =]]// ... -[[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 37, 57) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 38, 49) =]] ``` !!! caution @@ -238,8 +238,8 @@ For more complex searches, you need to combine multiple Criteria. You can do it using logical operators: `LogicalAnd`, `LogicalOr`, and `LogicalNot`. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 48, 54) =]][[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 58, 59) =]] -[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 65, 70) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 45, 48) =]][[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 59, 60) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 60, 63) =]] ``` This example takes three parameters from a command — `$text`, `$contentTypeId`, and `$locationId`. @@ -253,7 +253,7 @@ The example below uses the `LogicalNot` operator to search for all content conta that doesn't belong to the provided Section: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 50, 51) =]][[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 53, 58) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 47, 47) =]][[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 49, 52) =]] ``` ### Combining independent Criteria @@ -286,7 +286,7 @@ To sort the results of a query, use one of more [Sort Clauses](sort_clause_refer For example, to order search results by their publicationg date, from oldest to newest, and then alphabetically by content name, add the following Sort Clauses to the query: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 60, 64) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 54, 57) =]] ``` !!! tip @@ -305,7 +305,7 @@ For a list of supported Criteria and Sort Clauses, see [Search in trash referenc Searching through the trashed content items operates directly on the database, therefore you cannot use external search engines, such as Solr or Elasticsearch, and it's impossible to reindex the data. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindInTrashCommand.php', 39, 46) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindInTrashCommand.php', 38, 42) =]] ``` !!! caution @@ -324,7 +324,7 @@ With aggregations you can find the count of search results or other result infor To do this, you use of the query's `$aggregations` property: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 39, 44) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 31, 35) =]] ``` The name of the aggregation must be unique in the given query. @@ -332,13 +332,13 @@ The name of the aggregation must be unique in the given query. Access the results by using the `get()` method of the aggregation: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 48, 49) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 40, 41) =]] ``` Aggregation results contain the name of the result and the count of found items: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 51, 54) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 43, 45) =]] ``` With field aggregations you can group search results according to the value of a specific field. @@ -347,14 +347,14 @@ In this case the aggregation takes the content type identifier and the field ide The following example creates an aggregation named `selection` that groups results according to the value of the `topic` field in the `article` content type: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 44, 45) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 36, 36) =]] ``` With term aggregation you can define additional limits to the results. The following example limits the number of terms returned to 5 and only considers terms that have 10 or more results: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 39, 42) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 31, 33) =]] ``` To use a range aggregation, you must provide a `ranges` array containing a set of `Range` objects that define the borders of the specific range sets. diff --git a/docs/users/oauth_client.md b/docs/users/oauth_client.md index 47e741d2e5..393f0f0039 100644 --- a/docs/users/oauth_client.md +++ b/docs/users/oauth_client.md @@ -84,11 +84,11 @@ The following example shows how to create a Resource Owner mapper for the `googl Create a resource owner mapper for Google login in `src/OAuth/GoogleResourceOwnerMapper.php`. The mapper extends `ResourceOwnerToExistingOrNewUserMapper`, which enables it to create a new user in the repository if the user doesn't exist yet. -The mapper loads a user (line 51) or creates a new one (line 61), based on the information from `resourceOwner`, that's the OAuth2 authorization server. +The mapper loads a user (line 40) or creates a new one (line 49), based on the information from `resourceOwner`, that's the OAuth2 authorization server. -The new username is set with a `google:` prefix (lines 19, 109), to avoid conflicts with users registered in a regular way. +The new username is set with a `google:` prefix (lines 20, 91), to avoid conflicts with users registered in a regular way. -``` php hl_lines="20 54 64 109" +``` php hl_lines="20 40 67 91" [[= include_file('code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php') =]] ``` diff --git a/docs/users/segment_api.md b/docs/users/segment_api.md index a025b2ebe7..749aecd82f 100644 --- a/docs/users/segment_api.md +++ b/docs/users/segment_api.md @@ -15,13 +15,13 @@ To load a segment group, use `SegmentationService::loadSegmentGroupByIdentifier( Get all segments assigned to the group with `SegmentationService::loadSegmentsAssignedToGroup()`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 54, 62) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 46, 52) =]] ``` Similarly, you can load a segment by using `SegmentationService::loadSegmentByIdentifier()`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 62, 63) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 54, 54) =]] ``` ## Checking assignment @@ -29,7 +29,7 @@ Similarly, you can load a segment by using `SegmentationService::loadSegmentById You can check whether a user is assigned to a segment with `SegmentationService::isUserAssignedToSegment()`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 66, 71) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 58, 62) =]] ``` ## Assigning users @@ -37,7 +37,7 @@ You can check whether a user is assigned to a segment with `SegmentationService: To assign a user to a segment, use `SegmentationService::assignUserToSegment()`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 64, 65) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 56, 56) =]] ``` ## Creating segments @@ -47,13 +47,13 @@ Each segment must be assigned to a segment group. To create a segment group, use `SegmentationService::createSegmentGroup()` and provide it with a `SegmentGroupCreateStruct`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 38, 45) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 30, 36) =]] ``` To add a segment, use `SegmentationService::createSegment()` and provide it with a `SegmentCreateStruct`, which takes an existing group as one of the parameters: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 46, 53) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 38, 44) =]] ``` ## Updating segments diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c19c052141..0cac07b456 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -60,12 +60,6 @@ parameters: count: 3 path: code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php - - - message: '#^Parameter \#1 \$messages of method Symfony\\Component\\Console\\Output\\OutputInterface\:\:writeln\(\) expects iterable\\|string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: code_samples/api/public_php_api/src/Command/FilterLocationCommand.php - - message: '#^Access to protected property Ibexa\\Contracts\\Core\\Repository\\Values\\URL\\URL\:\:\$url\.$#' identifier: property.protected @@ -288,18 +282,6 @@ parameters: count: 1 path: code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php - - - message: '#^Parameter \#2 \$string of function explode expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php - - - - message: '#^Method App\\Setting\\Group\\MyGroup\:\:__construct\(\) has parameter \$values with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: code_samples/back_office/settings/src/Setting/Group/MyGroup.php - - message: '#^Method App\\Setting\\Unit\:\:mapFieldForm\(\) has parameter \$formBuilder with generic interface Symfony\\Component\\Form\\FormBuilderInterface but does not specify its types\: TData$#' identifier: missingType.generics @@ -456,12 +438,6 @@ parameters: count: 1 path: code_samples/field_types/generic_ft/src/Form/Type/HelloWorldType.php - - - message: '#^Method App\\FormBuilder\\FieldType\\Field\\Mapper\\CheckboxWithRichtextDescriptionFieldMapper\:\:mapFormOptions\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: code_samples/forms/custom_form_attribute/src/FormBuilder/FieldType/Field/Mapper/CheckboxWithRichtextDescriptionFieldMapper.php - - message: '#^Class App\\FormBuilder\\Form\\Type\\CheckboxWithRichtextDescriptionType extends generic class Symfony\\Component\\Form\\AbstractType but does not specify its types\: TData$#' identifier: missingType.generics @@ -474,12 +450,6 @@ parameters: count: 1 path: code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php - - - message: '#^Method App\\FormBuilder\\Field\\Mapper\\CountryFieldMapper\:\:mapFormOptions\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: code_samples/forms/custom_form_field/src/FormBuilder/Field/Mapper/CountryFieldMapper.php - - message: '#^Method App\\QueryType\\LatestContentQueryType\:\:getQuery\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -642,30 +612,12 @@ parameters: count: 1 path: code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php - - - message: '#^Method App\\Query\\Aggregation\\Solr\\PriorityRangeAggregationResultExtractor\:\:canVisit\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php - - - - message: '#^Method App\\Query\\Aggregation\\Solr\\PriorityRangeAggregationResultExtractor\:\:extract\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php - - message: '#^Method App\\Query\\Aggregation\\Solr\\PriorityRangeAggregationVisitor\:\:formatRangeValue\(\) has parameter \$value with no type specified\.$#' identifier: missingType.parameter count: 1 path: code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php - - - message: '#^Method App\\Query\\Aggregation\\Solr\\PriorityRangeAggregationVisitor\:\:visit\(\) should return array\ but returns array\\>\|string\>\.$#' - identifier: return.type - count: 1 - path: code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php - - message: '#^Method App\\Query\\Criterion\\Elasticsearch\\CameraManufacturerVisitor\:\:visit\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -738,24 +690,12 @@ parameters: count: 1 path: code_samples/tutorials/page_tutorial_starting_point/src/QueryType/MenuQueryType.php - - - message: '#^Call to an undefined method Symfony\\Component\\Security\\Core\\User\\UserProviderInterface\\:\:loadUserByUsername\(\)\.$#' - identifier: method.notFound - count: 2 - path: code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php - - message: '#^Parameter \#2 \$email of method Ibexa\\Contracts\\OAuth2Client\\Repository\\OAuth2UserService\:\:newOAuth2UserCreateStruct\(\) expects string, string\|null given\.$#' identifier: argument.type count: 1 path: code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php - - - message: '#^Offset ''data'' might not exist on array\|null\.$#' - identifier: offsetAccess.notFound - count: 1 - path: code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php - - message: '#^Parameter \#2 \$transition of method Ibexa\\Contracts\\Workflow\\Event\\Action\\AbstractTransitionWorkflowActionListener\:\:getActionMetadata\(\) expects Symfony\\Component\\Workflow\\Transition, Symfony\\Component\\Workflow\\Transition\|null given\.$#' identifier: argument.type diff --git a/rector.php b/rector.php new file mode 100644 index 0000000000..091043e174 --- /dev/null +++ b/rector.php @@ -0,0 +1,28 @@ +withPaths([ + __DIR__ . '/code_samples', + ]) + ->withPhpSets() + ->withSets([ + IbexaSetList::IBEXA_50->value, + SymfonySetList::SYMFONY_60, + SymfonySetList::SYMFONY_61, + SymfonySetList::SYMFONY_62, + SymfonySetList::SYMFONY_63, + SymfonySetList::SYMFONY_64, + SymfonySetList::SYMFONY_70, + SymfonySetList::SYMFONY_71, + SymfonySetList::SYMFONY_72, + ]);