Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 4 additions & 26 deletions .github/workflows/code_samples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,11 @@ jobs:
with:
dependency-versions: highest

- name: Run PHPStan analysis
- name: Run code sample quality tests
id: phpstan
continue-on-error: true
run: composer phpstan

- name: Run Deptrac analysis
id: deptrac
continue-on-error: true
run: composer deptrac

- name: Run Rector check
id: rector
continue-on-error: true
run: composer check-rector

- name: Run YAML snippet tests
id: check-yaml
continue-on-error: true
run: composer check-yaml

- name: Fail job if any check failed
if: always()
run: |
if [[ "${{ steps.phpstan.outcome }}" == "failure" || "${{ steps.deptrac.outcome }}" == "failure" || "${{ steps.rector.outcome }}" == "failure" || "${{ steps.check-yaml.outcome }}" == "failure" ]]; then
echo "One or more checks failed: PHPStan=${{ steps.phpstan.outcome }}, Deptrac=${{ steps.deptrac.outcome }}, Rector=${{ steps.rector.outcome }}, YAML=${{ steps.check-yaml.outcome }}"
exit 1
fi
run: composer test --ansi
env:
PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.php == '8.4' && '1' || '' }}


code-samples-inclusion-check:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@
```

Regenerate the baseline by running:

```bash
composer phpstan -- --generate-baseline
composer phpstan-update-baseline

Check notice on line 92 in README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] README.md#L92

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "README.md", "range": {"start": {"line": 92, "column": 12}}}, "severity": "INFO"}
```

#### Skipping validation of inline PHP snippets
Expand Down Expand Up @@ -120,8 +121,9 @@
```

Regenerate the baseline by running:

Check notice on line 124 in README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] README.md#L124

[Ibexa.Lists] Verify list formatting: Full sentences should start with uppercase and end with a period. Sentence fragments should start with lowercase and have no period.
Raw output
{"message": "[Ibexa.Lists] Verify list formatting: Full sentences should start with uppercase and end with a period. Sentence fragments should start with lowercase and have no period.", "location": {"path": "README.md", "range": {"start": {"line": 124, "column": 1}}}, "severity": "INFO"}
```bash
vendor/bin/deptrac --formatter=baseline
composer deptrac-update-baseline
```

## Checking links
Expand Down
41 changes: 39 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,35 @@
"check-rector": "php tools/extract-inline-php.php && rector process --dry-run --ansi",
"check-yaml": "phpunit --group yaml",
"phpunit": "phpunit --exclude-group=yaml",
"yaml-update-baseline": "php tests/generate-yaml-baseline.php"
"yaml-update-baseline": "php tests/generate-yaml-baseline.php",
"phpstan-update-baseline": "@phpstan --generate-baseline",
"deptrac-update-baseline": "@deptrac --formatter=baseline",
"composer-update": "[ -d vendor ] || composer update",
"yarn-install": "[ -d node_modules ] || yarn install",
"markdownlint": [
"@yarn-install",
"yarn markdownlint"
],
"fix-markdownlint": [
"@yarn-install",
"yarn markdownlint --fix"
],
"test": [
"@composer-update",
"EXIT=0; FAILED=''; { composer check-cs; } || { EXIT=1; FAILED=\"$FAILED check-cs\"; }; { composer phpstan; } || { EXIT=1; FAILED=\"$FAILED phpstan\"; }; { composer deptrac; } || { EXIT=1; FAILED=\"$FAILED deptrac\"; }; { composer check-rector; } || { EXIT=1; FAILED=\"$FAILED check-rector\"; }; { composer markdownlint; } || { EXIT=1; FAILED=\"$FAILED markdownlint\"; }; { composer check-yaml; } || { EXIT=1; FAILED=\"$FAILED check-yaml\"; }; if [ 1 -eq $EXIT ]; then echo \"Failed:$FAILED\"; fi; exit $EXIT;"
],
"fix": [
"@composer-update",
"@composer fix-rector",
"@composer fix-cs",
"@composer fix-markdownlint"
],
"baseline": [
"@composer-update",
"@composer phpstan-update-baseline",
"@composer deptrac-update-baseline",
"@composer yaml-update-baseline"
]
},
"scripts-descriptions": {
"fix-cs": "Automatically fixes code style in all files",
Expand All @@ -133,7 +161,16 @@
"fix-rector": "Automatically applies Rector refactoring to code samples and syncs back to Markdown",
"check-rector": "Check for code refactoring opportunities",
"check-yaml": "Run PHPUnit tests (YAML validation)",
"yaml-update-baseline": "Regenerate tests/yaml-validation-baseline.yaml from current failures"
"yaml-update-baseline": "Regenerate tests/yaml-validation-baseline.yaml from current failures",
"phpstan-update-baseline": "Regenerate PHPStan baseline from current failures",
"deptrac-update-baseline": "Regenerate Deptrac baseline from current failures",
"composer-update": "Install composer dependencies if not already installed",
"yarn-install": "Install yarn dependencies if not already installed",
"markdownlint": "Run Markdownlint on all documentation files",
"fix-markdownlint": "Automatically fixes Markdownlint issues in all documentation files",
"test": "Run all checks (CS-Fixer, PHPStan, Deptrac, Rector, Markdownlint, YAML checks), continuing past failures and reporting failure overall if any check failed",
"fix": "Run all automatic fixes (Rector, CS-Fixer, Markdownlint)",
"baseline": "Regenerate all baselines (PHPStan, Deptrac, YAML) from current failures"
},
"config": {
"allow-plugins": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,26 +108,30 @@ To resolve `websiteId` on the project level, implement the interface as follows:

``` php
namespace App\Tracking;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Ibexa\Contracts\Core\Repository\PermissionResolver;

use Ibexa\Contracts\ConnectorRaptor\Tracking\ContextProvider\WebsiteIdContextProviderInterface;
use Ibexa\Contracts\Core\Repository\PermissionResolver;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;

final readonly class MyCrmWebsiteUserIdProvider implements WebsiteIdContextProviderInterface
{
public function __construct(
private ConfigResolverInterface $configResolver,
private ConfigResolverInterface $configResolver,
private PermissionResolver $permissionResolver,
)
{
) {
}

public function getWebsiteId(): ?string
{
$currentUserId = $this->permissionResolver->getCurrentUserReference()->getUserId();
// Don't resolve for anynomous user
if ($this->isAnonymousUser($currentUserId)) {
return null;
}

return $this->getWebsiteUserIdForCurrentUser($currentUserId);
}

/**
* @phpstan-return non-empty-string
*/
Expand All @@ -136,6 +140,7 @@ final readonly class MyCrmWebsiteUserIdProvider implements WebsiteIdContextProvi
// Implement custom logic resolving user identifier from the CRM
return 'custom-identifier-for-the-user-retrieved-from-the-CRM';
}

private function isAnonymousUser(int $userId): bool
{
return (int) $this->configResolver->getParameter('anonymous_user_id') === $userId;
Expand Down
Loading