-
Notifications
You must be signed in to change notification settings - Fork 3
Prepared configuration for Ibexa Annotation to Attribute Constraints #45
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
alongosz
wants to merge
5
commits into
5.0
Choose a base branch
from
configure-ibexa-constraints-for-annotation-to-attribute
base: 5.0
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
5 commits
Select commit
Hold shift + click to select a range
9701bd6
Prepared configuration for Ibexa Annotation to Attribute Constraints
alongosz a2f35bb
[Tests] Added coverage for Ibexa annotation to attribute rector config
alongosz 6ec8516
Made AnnotationToAttributeConfigurationBuilder readonly
alongosz b786001
Added strict types to stubs
alongosz f3df31a
Enabled Symfony & Doctrine annotation to attribute rectors in the con…
alongosz 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
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
24 changes: 24 additions & 0 deletions
24
src/lib/Configuration/AnnotationToAttributeConfigurationBuilder.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,24 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
| * @license For full copyright and license information view LICENSE file distributed with this source code. | ||
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Ibexa\Rector\Configuration; | ||
|
|
||
| use Rector\Php80\ValueObject\AnnotationToAttribute; | ||
|
|
||
| final readonly class AnnotationToAttributeConfigurationBuilder | ||
| { | ||
| /** | ||
| * @return iterable<\Rector\Php80\ValueObject\AnnotationToAttribute> | ||
| */ | ||
| public function build(): iterable | ||
| { | ||
| foreach (IbexaSymfonyConstraintList::cases() as $constraintFQCN) { | ||
| yield new AnnotationToAttribute($constraintFQCN->value); | ||
| } | ||
| } | ||
| } |
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,52 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
| * @license For full copyright and license information view LICENSE file distributed with this source code. | ||
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Ibexa\Rector\Configuration; | ||
|
|
||
| enum IbexaSymfonyConstraintList: string | ||
| { | ||
| // Segmentation | ||
| case SegmentationUserToSegmentAssignment = 'Ibexa\Segmentation\Validation\Constraint\UserToSegmentAssignment'; | ||
| case SegmentationUniqueSegmentGroupStructIdentifier = 'Ibexa\Segmentation\Validation\Constraint\UniqueSegmentGroupStructIdentifier'; | ||
| case SegmentationUniqueSegmentStructIdentifier = 'Ibexa\Segmentation\Validation\Constraint\UniqueSegmentStructIdentifier'; | ||
|
|
||
| // Connector AI | ||
| case ConnectorAiActionConfigurationHandlerOptions = 'Ibexa\ConnectorAi\Validation\Constraints\ActionConfigurationHandlerOptions'; | ||
| case ConnectorAiActionConfigurationTypeOptions = 'Ibexa\ConnectorAi\Validation\Constraints\ActionConfigurationTypeOptions'; | ||
| case ConnectorAiUniqueActionConfigurationIdentifier = 'Ibexa\ConnectorAi\Validation\Constraints\UniqueActionConfigurationIdentifier'; | ||
| case ConnectorAiIdentifier = 'Ibexa\ConnectorAi\Validation\Constraints\Identifier'; | ||
|
|
||
| // Discounts | ||
| case DiscountsAtLeastOneDiscountTranslationWillRemain = 'Ibexa\Discounts\Validation\Constraint\AtLeastOneDiscountTranslationWillRemain'; | ||
| case DiscountsCountCategories = 'Ibexa\Discounts\Validation\Constraint\CountCategories'; | ||
| case DiscountsCountCustomerGroup = 'Ibexa\Discounts\Validation\Constraint\CountCustomerGroup'; | ||
| case DiscountsCountProducts = 'Ibexa\Discounts\Validation\Constraint\CountProducts'; | ||
| case DiscountsCurrencyRequired = 'Ibexa\Discounts\Validation\Constraint\CurrencyRequired'; | ||
| case DiscountsUniqueIdentifier = 'Ibexa\Discounts\Validation\Constraint\UniqueIdentifier'; | ||
| case DiscountsIdentifier = 'Ibexa\Discounts\Validation\Constraint\Identifier'; | ||
| case DiscountsValidDiscountRuleType = 'Ibexa\Discounts\Validation\Constraint\ValidDiscountRuleType'; | ||
|
|
||
| // Collaboration | ||
| case CollaborationParticipantType = 'Ibexa\Collaboration\Validation\Constraint\ParticipantType'; | ||
| case CollaborationUniqueToken = 'Ibexa\Collaboration\Validation\Constraint\UniqueToken'; | ||
|
|
||
| // Payment | ||
| case PaymentAllowedPaymentStatusTransition = 'Ibexa\Payment\Validation\Constraints\AllowedPaymentStatusTransition'; | ||
| case PaymentAtLeastOneTranslation = 'Ibexa\Payment\Validation\Constraints\AtLeastOneTranslation'; | ||
| case PaymentEnabledPaymentMethod = 'Ibexa\Payment\Validation\Constraints\EnabledPaymentMethod'; | ||
| case PaymentIdentifier = 'Ibexa\Payment\Validation\Constraints\Identifier'; | ||
| case PaymentMoneyAmountEqualToOrGreaterThanZero = 'Ibexa\Payment\Validation\Constraints\MoneyAmountEqualToOrGreaterThanZero'; | ||
| case PaymentPaymentMethodEnabled = 'Ibexa\Payment\Validation\Constraints\PaymentMethodEnabled'; | ||
| case PaymentPaymentMethodOptions = 'Ibexa\Payment\Validation\Constraints\PaymentMethodOptions'; | ||
| case PaymentUniquePaymentIdentifier = 'Ibexa\Payment\Validation\Constraints\UniquePaymentIdentifier'; | ||
| case PaymentUniquePaymentMethodIdentifier = 'Ibexa\Payment\Validation\Constraints\UniquePaymentMethodIdentifier'; | ||
|
|
||
| // SiteFactory | ||
| case SiteFactoryHostnameWithOptionalPort = 'Ibexa\Bundle\SiteFactory\Validator\Constraints\HostnameWithOptionalPort'; | ||
| case SiteFactoryPort = 'Ibexa\Bundle\SiteFactory\Validator\Constraints\Port'; | ||
| } |
11 changes: 11 additions & 0 deletions
11
stubs/Ibexa/Payment/Validation/Constraints/UniquePaymentMethodIdentifier.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,11 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Ibexa\Payment\Validation\Constraints; | ||
|
|
||
| use Symfony\Component\Validator\Constraint; | ||
|
|
||
| #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD)] | ||
| final class UniquePaymentMethodIdentifier extends Constraint | ||
| { | ||
| } |
11 changes: 11 additions & 0 deletions
11
stubs/Ibexa/Segmentation/Validation/Constraint/UserToSegmentAssignment.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,11 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
| namespace Ibexa\Segmentation\Validation\Constraint; | ||
|
|
||
| use Symfony\Component\Validator\Constraint; | ||
|
|
||
| #[\Attribute(\Attribute::TARGET_CLASS)] | ||
| final class UserToSegmentAssignment extends Constraint | ||
| { | ||
|
|
||
| } |
49 changes: 49 additions & 0 deletions
49
tests/lib/Sets/Ibexa50/Fixture/annotation_to_attribute.php.inc
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,49 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
|
|
||
|
alongosz marked this conversation as resolved.
|
||
| namespace Ibexa\Rector\Tests\Sets\Ibexa50\Fixture; | ||
|
|
||
| use Ibexa\Payment\Validation\Constraints\UniquePaymentMethodIdentifier; | ||
| use Ibexa\Segmentation\Validation\Constraint\UserToSegmentAssignment; | ||
|
|
||
| /** | ||
| * @UserToSegmentAssignment() | ||
| */ | ||
| class Foo | ||
| { | ||
| /** @UniquePaymentMethodIdentifier */ | ||
| public string $uniquePaymentIdentifier; | ||
|
|
||
| /** | ||
| * @UniquePaymentMethodIdentifier | ||
| */ | ||
| public function getUniquePaymentIdentifier(): string | ||
| { | ||
| return $this->uniquePaymentIdentifier; | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
| declare(strict_types=1); | ||
|
|
||
|
alongosz marked this conversation as resolved.
|
||
| namespace Ibexa\Rector\Tests\Sets\Ibexa50\Fixture; | ||
|
|
||
| use Ibexa\Payment\Validation\Constraints\UniquePaymentMethodIdentifier; | ||
| use Ibexa\Segmentation\Validation\Constraint\UserToSegmentAssignment; | ||
|
|
||
| #[UserToSegmentAssignment] | ||
| class Foo | ||
| { | ||
| #[UniquePaymentMethodIdentifier] | ||
| public string $uniquePaymentIdentifier; | ||
|
|
||
| #[UniquePaymentMethodIdentifier] | ||
| public function getUniquePaymentIdentifier(): string | ||
| { | ||
| return $this->uniquePaymentIdentifier; | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
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.
Well, that kinda sucks.
How about we enable other attributes though? From Symfony Validator, routing, etc.?