Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/code_samples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ jobs:
strategy:
matrix:
php:
- "8.3"
- "8.4" # Upper supported version
- "8.2" # Lower supported that haven't reached end of live
- "7.4" # Lower supported version but reached end of life, 8.2 is recommended instead
steps:
- uses: actions/checkout@v4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function handle(ActionInterface $action, array $context = []): ActionResp

$arguments = ['whisper'];

$language = $action->getRuntimeContext()?->get('languageCode');
$language = $action->hasRuntimeContext() ? $action->getRuntimeContext()->get('languageCode') : null;
if ($language !== null) {
$arguments[] = sprintf('--language=%s', substr($language, 0, 2));
}
Expand All @@ -49,10 +49,10 @@ public function handle(ActionInterface $action, array $context = []): ActionResp

$output = $process->getOutput();

$includeTimestamps = $action->getActionContext()
?->getActionTypeOptions()
$includeTimestamps = $action->hasActionContext() ? $action->getActionContext()
->getActionTypeOptions()
->get('include_timestamps', false)
?? false;
: false;

if (!$includeTimestamps) {
$output = $this->removeTimestamps($output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln(' in ' . $versionInfo->getInitialLanguage()->name);
}

$versionInfoArray = iterator_to_array($this->contentService->loadVersions($contentInfo, VersionInfo::STATUS_ARCHIVED));
$versionInfoArray = $this->contentService->loadVersions($contentInfo, VersionInfo::STATUS_ARCHIVED);
if ($versionInfoArray instanceof \Traversable) {
$versionInfoArray = iterator_to_array($versionInfoArray);
}
if (count($versionInfoArray)) {
$output->writeln('Archived versions:');
foreach ($versionInfoArray as $versionInfo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,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, ValueObject $object, ?array $targets = null): ?bool
{
if (!$value instanceof CustomLimitationValue) {
throw new InvalidArgumentException('$value', 'Must be of type: CustomLimitationValue');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@

final class HelpMenuSubscriber implements EventSubscriberInterface
{
private bool $kernelDebug;

public function __construct(
private readonly bool $kernelDebug
bool $kernelDebug
) {
$this->kernelDebug = $kernelDebug;
}

public static function getSubscribedEvents(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ProductSuggestionNormalizer implements
{
use NormalizerAwareTrait;

public function normalize($object, string $format = null, array $context = [])
public function normalize($object, ?string $format = null, array $context = [])
{
/** @var \App\Search\Model\Suggestion\ProductSuggestion $object */
return [
Expand All @@ -27,7 +27,7 @@ public function normalize($object, string $format = null, array $context = [])
];
}

public function supportsNormalization($data, string $format = null)
public function supportsNormalization($data, ?string $format = null)
{
return $data instanceof ProductSuggestion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class AssignSectionDenormalizer extends AbstractActionDenormalizer
{
protected function supportsActionName(string $actionName, string $format = null): bool
protected function supportsActionName(string $actionName, ?string $format = null): bool
{
return $actionName === AssignSection::TYPE;
}
Expand All @@ -22,7 +22,7 @@ protected function supportsActionName(string $actionName, string $format = null)
*
* @return \App\Migrations\Action\AssignSection
*/
public function denormalize($data, string $type, string $format = null, array $context = []): AssignSection
public function denormalize($data, string $type, ?string $format = null, array $context = []): AssignSection
{
Assert::keyExists($data, 'value');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function createCriterion(array $data, string $type, ?string $format, a
return new Criterion\SectionIdentifier($data['value']);
}

public function supportsNormalization($data, string $format = null): bool
public function supportsNormalization($data, ?string $format = null): bool
{
return $data instanceof Criterion\SectionIdentifier;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class ReplaceNameStepNormalizer extends AbstractStepNormalizer
{
protected function normalizeStep(
StepInterface $object,
string $format = null,
?string $format = null,
array $context = []
): array {
assert($object instanceof ReplaceNameStep);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,17 @@ public function addAnniversaryConditionStep(Event $event): void

public function addStepDataToStruct(DiscountStructEventInterface $event): void
{
$step = $event->getData()
->getStepByIdentifier(AnniversaryConditionStep::IDENTIFIER);

if ($step === null) {
return;
}

/** @var AnniversaryConditionStep $stepData */
$stepData = $event
->getData()
->getStepByIdentifier(AnniversaryConditionStep::IDENTIFIER)?->getStepData();
$stepData = $step->getStepData();

if ($stepData === null || !$stepData->enabled) {
if (!$stepData->enabled) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

final class ValueDenormalizer implements DenormalizerInterface
{
public function denormalize($data, string $class, string $format = null, array $context = [])
public function denormalize($data, string $class, ?string $format = null, array $context = [])
{
if (isset($data['x']) && isset($data['y'])) {
// Support for old format
Expand All @@ -18,7 +18,7 @@ public function denormalize($data, string $class, string $format = null, array $
return new $class($data);
}

public function supportsDenormalization($data, string $type, string $format = null)
public function supportsDenormalization($data, string $type, ?string $format = null)
{
return $type === Value::class;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

final class ValueNormalizer implements NormalizerInterface
{
public function normalize($object, string $format = null, array $context = [])
public function normalize($object, ?string $format = null, array $context = [])
{
return [
$object->getX(),
$object->getY(),
];
}

public function supportsNormalization($data, string $format = null)
public function supportsNormalization($data, ?string $format = null)
{
return $data instanceof Value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function canVisit(Criterion $criterion)
/**
* @param \App\Query\Criterion\CameraManufacturerCriterion $criterion
*/
public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null)
public function visit(Criterion $criterion, ?CriterionVisitor $subVisitor = null)
{
$expressions = array_map(
function ($value): string {
Expand Down
8 changes: 4 additions & 4 deletions docs/content_management/content_api/browsing_content.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ This method loads only the specified subset of relations to improve performance
You can get the current version's `VersionInfo` using [`ContentService::loadVersionInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_loadVersionInfo).

``` php
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 100, 107) =]]
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 103, 110) =]]
```

You can also specify the version number as the second argument to get Relations for a specific version:
Expand All @@ -117,7 +117,7 @@ It also holds the [relation type](content_relations.md), and the optional field
You can use the `getOwner` method of the `ContentInfo` object to load the content item's owner as a `User` value object.

``` php
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 109, 110) =]]
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 112, 113) =]]
```

To get the creator of the current version and not the content item's owner, you need to use the `creatorId` property from the current version's `VersionInfo` object.
Expand All @@ -127,7 +127,7 @@ To get the creator of the current version and not the content item's owner, you
You can find the section to which a content item belongs through the [`getSection`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentInfo.html#method_getSection) method of the ContentInfo object:

``` php
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 112, 113) =]]
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 115, 116) =]]
```

!!! note
Expand All @@ -142,7 +142,7 @@ You need to provide it with the object state group.
All object state groups can be retrieved through [`loadObjectStateGroups`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ObjectStateService.html#method_loadObjectStateGroups).

``` php
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 115, 120) =]]
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 118, 123) =]]
```

## Viewing content with fields
Expand Down
2 changes: 1 addition & 1 deletion docs/discounts/extend_discounts_wizard.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Expand the previously created `AnniversaryConditionStepEventSubscriber` to liste

and add the `addStepDataToStruct()` method:

``` php hl_lines="23-24 57-70"
``` php hl_lines="23-24 57-75"
[[= include_file('code_samples/discounts/src/Discounts/Step/Step2/AnniversaryConditionStepEventSubscriber.php') =]]
```

Expand Down
10 changes: 5 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ parameters:
path: code_samples/api/public_php_api/src/Controller/CustomFilterController.php

-
message: '#^Parameter \#1 \$string of function base64_encode expects string, string\|false given\.$#'
message: '#^Parameter \#1 \$str(ing)? of function base64_encode expects string, string\|false given\.$#'
identifier: argument.type
count: 1
path: code_samples/api/rest_api/create_image.json.php
Expand Down Expand Up @@ -151,7 +151,7 @@ parameters:
path: code_samples/api/rest_api/create_image.xml.php

-
message: '#^Parameter \#1 \$string of function base64_encode expects string, string\|false given\.$#'
message: '#^Parameter \#1 \$str(ing)? of function base64_encode expects string, string\|false given\.$#'
identifier: argument.type
count: 1
path: code_samples/api/rest_api/create_image.xml.php
Expand Down Expand Up @@ -193,13 +193,13 @@ parameters:
path: code_samples/api/rest_api/src/Rest/ValueObjectVisitor/RestLocation.php

-
message: '#^Parameter \#1 \.\.\.\$arrays of function array_merge expects array, iterable\<Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\URLAlias\> given\.$#'
message: '#^Parameter \#1 (\.\.\.\$arrays|\$arr1) of function array_merge expects array, iterable\<Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\URLAlias\> given\.$#'
identifier: argument.type
count: 1
path: code_samples/api/rest_api/src/Rest/ValueObjectVisitor/RestLocation.php

-
message: '#^Parameter \#2 \.\.\.\$arrays of function array_merge expects array, iterable\<Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\URLAlias\> given\.$#'
message: '#^Parameter \#2 \.\.\.(\$arrays|\$args) of function array_merge expects array, iterable\<Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\URLAlias\> given\.$#'
identifier: argument.type
count: 1
path: code_samples/api/rest_api/src/Rest/ValueObjectVisitor/RestLocation.php
Expand Down Expand Up @@ -283,7 +283,7 @@ parameters:
path: code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php

-
message: '#^Parameter \#2 \$string of function explode expects string, string\|null given\.$#'
message: '#^Parameter \#2 \$str(ing)? of function explode expects string, string\|null given\.$#'
identifier: argument.type
count: 1
path: code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php
Expand Down
Loading