-
Notifications
You must be signed in to change notification settings - Fork 2
Generate Access Interceptor Proxy #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kletord
wants to merge
15
commits into
master
Choose a base branch
from
warmp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
49555ef
Generate Access Interceptor Proxy
kletord c81fca0
Fix typing and code style
kletord b496611
Clarrify error message
kletord e1f392d
Small fixes from review
kletord 150fc8b
Fix deprectaed and tests
kletord effa0c9
Add helper method ofr instance type checking
kletord 1a3aa95
Update CI
kletord d265dc3
Update CI
kletord 826b94a
Update CI
kletord 206cd88
Remove symfony internal class usage
kletord c74b425
Upgrade phpstan
kletord 1541d65
Fix cs
kletord ac05b58
Fix symfony 6.4 typing
kletord 9ea524c
Fix php 8.5 typing
kletord 6afd6eb
Fix php 8.5 typing
kletord File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,58 +1,70 @@ | ||
| name: Code Analysis | ||
|
|
||
| on: | ||
| pull_request: ~ | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: ~ | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| code-validation: | ||
| name: ${{ matrix.actions.name }} | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| actions: | ||
| - name: Composer validate | ||
| run: composer validate --ansi --strict | ||
|
|
||
| - name: Static analysis | ||
| run: composer phpstan | ||
|
|
||
| - name: Style check | ||
| run: composer check-cs | ||
|
|
||
| - name: Unit tests | ||
| run: composer coverage | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
|
|
||
| - uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: 8.2 | ||
| coverage: pcov | ||
| tools: composer:v2 | ||
| env: | ||
| COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Install dependencies | ||
| uses: "ramsey/composer-install@v2" | ||
|
|
||
| - run: ${{ matrix.actions.run }} | ||
|
|
||
| - name: Coverage diff | ||
| uses: OpenClassrooms/[email protected] | ||
| if: ${{ hashFiles('build/coverage/coverage.xml') != '' && github.event_name == 'pull_request' }} | ||
| with: | ||
| action: check | ||
| files: '[{"coverage": "build/coverage/coverage.xml", "summary": "coverage-summary.json", "label": "Coverage", "badge": "coverage.svg"}]' | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Coverage update | ||
| uses: OpenClassrooms/[email protected] | ||
| if: ${{ hashFiles('build/coverage/coverage.xml') != '' && github.event_name == 'push' && github.ref_name == 'main' }} | ||
| with: | ||
| action: update | ||
| files: '[{"coverage": "build/coverage/coverage.xml", "summary": "coverage-summary.json", "label": "Coverage", "badge": "coverage.svg"}]' | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| code-validation: | ||
| name: ${{ matrix.actions.name }} - PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }} | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| php: [8.3, 8.4, 8.5] | ||
| symfony: [6.4, 7.4] | ||
| actions: | ||
| - name: Composer validate | ||
| run: composer validate --ansi --strict | ||
|
|
||
| - name: Static analysis | ||
| run: composer phpstan | ||
|
|
||
| - name: Style check | ||
| run: composer check-cs | ||
|
|
||
| - name: Unit tests | ||
| run: composer coverage | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ matrix.php }} | ||
| coverage: pcov | ||
| tools: composer:v2 | ||
| env: | ||
| COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: symfony/flex is required to install the correct symfony version | ||
| if: ${{ matrix.symfony }} | ||
| run: | | ||
| composer global config --no-plugins allow-plugins.symfony/flex true | ||
| composer global require symfony/flex | ||
|
|
||
| - name: Configure Symfony version for symfony/flex | ||
| if: ${{ matrix.symfony }} | ||
| run: composer config extra.symfony.require "${{ matrix.symfony }}.*" | ||
|
|
||
| - name: Install dependencies | ||
| run: composer install --no-interaction --prefer-dist --optimize-autoloader | ||
|
|
||
| - run: ${{ matrix.actions.run }} | ||
|
|
||
| - name: Coverage diff | ||
| uses: OpenClassrooms/[email protected] | ||
| if: ${{ hashFiles('build/coverage/coverage.xml') != '' && github.event_name == 'pull_request' }} | ||
| with: | ||
| action: check | ||
| files: '[{"coverage": "build/coverage/coverage.xml", "summary": "coverage-summary.json", "label": "Coverage", "badge": "coverage.svg"}]' | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Coverage update | ||
| uses: OpenClassrooms/[email protected] | ||
| if: ${{ hashFiles('build/coverage/coverage.xml') != '' && github.event_name == 'push' && github.ref_name == 'main' }} | ||
| with: | ||
| action: update | ||
| files: '[{"coverage": "build/coverage/coverage.xml", "summary": "coverage-summary.json", "label": "Coverage", "badge": "coverage.svg"}]' | ||
| token: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/FrameworkBridge/Symfony/CacheWarmer/ProxyCacheWarmer.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace OpenClassrooms\ServiceProxy\FrameworkBridge\Symfony\CacheWarmer; | ||
|
|
||
| use ProxyManager\Proxy\LazyLoadingInterface; | ||
| use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; | ||
| use Symfony\Component\VarExporter\LazyObjectInterface; | ||
|
|
||
| final class ProxyCacheWarmer implements CacheWarmerInterface | ||
| { | ||
| /** | ||
| * @var iterable<object> | ||
| */ | ||
| private iterable $proxies; | ||
|
|
||
| /** | ||
| * @param iterable<object> $proxies | ||
| */ | ||
| public function __construct(iterable $proxies) | ||
| { | ||
| $this->proxies = $proxies; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function warmUp(string $cacheDir, ?string $buildDir = null): array | ||
| { | ||
| foreach ($this->proxies as $proxy) { | ||
| if ($proxy instanceof LazyLoadingInterface && !$proxy->isProxyInitialized()) { | ||
| $proxy->initializeProxy(); | ||
| } | ||
|
|
||
| if (class_exists(LazyObjectInterface::class) | ||
| && $proxy instanceof LazyObjectInterface | ||
| && !$proxy->isLazyObjectInitialized()) { | ||
| $proxy->initializeLazyObject(); | ||
| } | ||
| } | ||
|
|
||
| return []; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function isOptional(): bool | ||
| { | ||
| return true; | ||
kletord marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add continue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is LazyLoadingInterface doesn't exist