Skip to content

Fix existing inline PHP snippets#3206

Open
mnocon wants to merge 9 commits into
5.0from
fix-php-snippets
Open

Fix existing inline PHP snippets#3206
mnocon wants to merge 9 commits into
5.0from
fix-php-snippets

Conversation

@mnocon

@mnocon mnocon commented May 17, 2026

Copy link
Copy Markdown
Contributor

This PR fixes the existing inlined PHP code samples, using the following tools:

  • PHPStan
  • Rector
  • CS-Fixer
  • Deptrac

@github-actions

github-actions Bot commented May 17, 2026

Copy link
Copy Markdown

Preview of modified files: Too many files modified in a single PR, preview link list is skipped. (298 files > 150)

@sonarqubecloud

Copy link
Copy Markdown

```php
use Symfony\Component\HttpFoundation\Request;

/** @var \Symfony\Component\HttpFoundation\Request $request */

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ibexa/php-dev @vidarl @reithor could you please help me and confirm that this change is ok?

Request::HEADER_X_FORWARDED_ALL is removed in Symfony 6/7, I found this:

https://github.com/symfony/symfony/blame/b01d14a27dcd5ca91c5af11ca3cb41ffbe639de7/src/Symfony/Component/HttpFoundation/CHANGELOG.md#L128

I'm sure about other changes in this PR, but for this one would like a confirmation

@reithor reithor Jul 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnocon sorry, but i totally missed that you pinged me here a while ago.
Change looks good to me but I am not 100% sure - so would prefer getting approval from @ibexa/php-dev .

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked that and can confirm it is a secure 1:1 replacement 👍

@mnocon mnocon marked this pull request as ready for review June 23, 2026 07:55
@mnocon mnocon force-pushed the test-php-snippets branch 3 times, most recently from 1bff95b to 5150030 Compare June 23, 2026 11:44
@mnocon mnocon force-pushed the test-php-snippets branch 2 times, most recently from 4e0bcb5 to 02b34ef Compare June 23, 2026 13:17
@mnocon mnocon force-pushed the test-php-snippets branch from 02b34ef to c72a5c4 Compare June 23, 2026 14:05
@mnocon mnocon force-pushed the fix-php-snippets branch from 24aad10 to db52c22 Compare June 23, 2026 14:18
@mnocon mnocon force-pushed the fix-php-snippets branch from db52c22 to 182451d Compare June 23, 2026 14:32
@mnocon mnocon force-pushed the test-php-snippets branch 3 times, most recently from 4806847 to 6fcae4d Compare July 3, 2026 12:51
Base automatically changed from test-php-snippets to 5.0 July 6, 2026 11:07
@mnocon mnocon force-pushed the fix-php-snippets branch from 4b75bc7 to 88a888b Compare July 7, 2026 10:03
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Summary

Status Count
🔍 Total 758313
🔗 Unique 15003
✅ Successful 7263
⏳ Timeouts 0
🔀 Redirected 0
👻 Excluded 751050
❓ Unknown 0
🚫 Errors 0
⛔ Unsupported 0

Full Github Actions output

@mnocon mnocon force-pushed the fix-php-snippets branch from 3693f88 to 687ef0b Compare July 7, 2026 10:23
@mnocon mnocon requested a review from a team July 7, 2026 10:30
@ibexa-workflow-automation-1 ibexa-workflow-automation-1 Bot requested review from adriendupuis, dabrt and julitafalcondusza and removed request for a team July 7, 2026 10:30
Comment on lines +238 to +242
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo */
/** @var int $versionFromId */
/** @var int $versionToId */
/** @var \Ibexa\Contracts\Core\Repository\ContentService $contentService */
/** @var \Ibexa\Contracts\VersionComparison\Service\VersionComparisonServiceInterface $comparisonService */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK for two lines but here…

Suggested change
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo */
/** @var int $versionFromId */
/** @var int $versionToId */
/** @var \Ibexa\Contracts\Core\Repository\ContentService $contentService */
/** @var \Ibexa\Contracts\VersionComparison\Service\VersionComparisonServiceInterface $comparisonService */
/**
* @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
* @var int $versionFromId
* @var int $versionToId
* @var \Ibexa\Contracts\Core\Repository\ContentService $contentService
* @var \Ibexa\Contracts\VersionComparison\Service\VersionComparisonServiceInterface
*/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified for all entries where there is more than a single line, to make it unified:
0c7bbb0

I've checked and there's no hl_lines usage, no need to adjust that

@mnocon mnocon requested a review from adriendupuis July 7, 2026 15:09
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/api/public_php_api/src/Command/SegmentCommand.php

docs/users/segment_api.md@17:``` php
docs/users/segment_api.md@18:[[= include_code('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 49, 55, remove_indent=True) =]]
docs/users/segment_api.md@19:```

001⫶$segmentGroup = $this->segmentationService->loadSegmentGroupByIdentifier('custom_group');
002⫶
003⫶$segments = $this->segmentationService->loadSegmentsAssignedToGroup($segmentGroup);
004⫶
005⫶foreach ($segments as $segment) {
006⫶ $output->writeln('Segment identifier: ' . $segment->getIdentifier() . ', name: ' . $segment->getName());
007⫶}

docs/users/segment_api.md@23:``` php
docs/users/segment_api.md@24:[[= include_code('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 57, 57, remove_indent=True) =]]
docs/users/segment_api.md@25:```

001⫶$segment = $this->segmentationService->loadSegmentByIdentifier('segment_1');

docs/users/segment_api.md@31:``` php
docs/users/segment_api.md@32:[[= include_code('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 61, 65, remove_indent=True) =]]
docs/users/segment_api.md@33:```

001⫶$output->writeln((
002⫶ $this->segmentationService->isUserAssignedToSegment($user, $segment)
003⫶ ? 'The user is assigned to the segment.'
004⫶ : 'The user is not assigned to the segment.'
005⫶));

docs/users/segment_api.md@39:``` php
docs/users/segment_api.md@40:[[= include_code('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 59, 59, remove_indent=True) =]]
docs/users/segment_api.md@41:```

001⫶$this->segmentationService->assignUserToSegment($user, $segment);

docs/users/segment_api.md@49:``` php
docs/users/segment_api.md@50:[[= include_code('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 33, 39, remove_indent=True) =]]
docs/users/segment_api.md@51:```

001⫶$segmentGroupCreateStruct = new SegmentGroupCreateStruct([
002⫶ 'name' => 'Custom Group',
003⫶ 'identifier' => 'custom_group',
004⫶ 'createSegments' => [],
005⫶]);
006⫶
007⫶$newSegmentGroup = $this->segmentationService->createSegmentGroup($segmentGroupCreateStruct);

docs/users/segment_api.md@55:``` php
docs/users/segment_api.md@56:[[= include_code('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 41, 47, remove_indent=True) =]]
docs/users/segment_api.md@57:```

001⫶$segmentCreateStruct = new SegmentCreateStruct([
002⫶ 'name' => 'Segment 1',
003⫶ 'identifier' => 'segment_1',
004⫶ 'group' => $newSegmentGroup,
005⫶]);
006⫶
007⫶$newSegment = $this->segmentationService->createSegment($segmentCreateStruct);


code_samples/api/public_php_api/src/Command/SegmentCommand.php

docs/users/segment_api.md@17:``` php
docs/users/segment_api.md@18:[[= include_code('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 49, 55, remove_indent=True) =]]
docs/users/segment_api.md@19:```

001⫶$segmentGroup = $this->segmentationService->loadSegmentGroupByIdentifier('custom_group');
002⫶
003⫶$segments = $this->segmentationService->loadSegmentsAssignedToGroup($segmentGroup);
004⫶
005⫶foreach ($segments as $segment) {
006⫶ $output->writeln('Segment identifier: ' . $segment->getIdentifier() . ', name: ' . $segment->getName());
007⫶}

docs/users/segment_api.md@23:``` php
docs/users/segment_api.md@24:[[= include_code('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 57, 57, remove_indent=True) =]]
docs/users/segment_api.md@25:```

001⫶$segment = $this->segmentationService->loadSegmentByIdentifier('segment_1');

docs/users/segment_api.md@31:``` php
docs/users/segment_api.md@32:[[= include_code('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 61, 65, remove_indent=True) =]]
docs/users/segment_api.md@33:```

001⫶$output->writeln((
002⫶ $this->segmentationService->isUserAssignedToSegment($user, $segment)
003⫶ ? 'The user is assigned to the segment.'
004⫶ : 'The user is not assigned to the segment.'
005⫶));

docs/users/segment_api.md@39:``` php
docs/users/segment_api.md@40:[[= include_code('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 59, 59, remove_indent=True) =]]
docs/users/segment_api.md@41:```

001⫶$this->segmentationService->assignUserToSegment($user, $segment);

docs/users/segment_api.md@49:``` php
docs/users/segment_api.md@50:[[= include_code('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 33, 39, remove_indent=True) =]]
docs/users/segment_api.md@51:```

001⫶$segmentGroupCreateStruct = new SegmentGroupCreateStruct([
002⫶ 'name' => 'Custom Group',
003⫶ 'identifier' => 'custom_group',
004⫶ 'createSegments' => [],
005⫶]);
006⫶
007⫶$newSegmentGroup = $this->segmentationService->createSegmentGroup($segmentGroupCreateStruct);

docs/users/segment_api.md@55:``` php
docs/users/segment_api.md@56:[[= include_code('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 41, 47, remove_indent=True) =]]
docs/users/segment_api.md@57:```

001⫶$segmentCreateStruct = new SegmentCreateStruct([
002⫶ 'name' => 'Segment 1',
003⫶ 'identifier' => 'segment_1',
004⫶ 'group' => $newSegmentGroup,
005⫶]);
006⫶
007⫶$newSegment = $this->segmentationService->createSegment($segmentCreateStruct);

docs/users/segment_api.md@67:``` php
docs/users/segment_api.md@68:[[= include_code('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 67, 67, remove_indent=True) =]]
docs/users/segment_api.md@69:```

001⫶$this->segmentationService->removeSegmentGroup($segmentGroup);

Download colorized diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants