Skip to content
Open
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
11 changes: 11 additions & 0 deletions .github/workflows/code_samples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,28 @@ jobs:
dependency-versions: highest

- name: Run PHPStan analysis
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: Fail job if any check failed
if: always()
run: |
if [[ "${{ steps.phpstan.outcome }}" == "failure" || "${{ steps.deptrac.outcome }}" == "failure" || "${{ steps.rector.outcome }}" == "failure" ]]; then
echo "One or more checks failed: PHPStan=${{ steps.phpstan.outcome }}, Deptrac=${{ steps.deptrac.outcome }}, Rector=${{ steps.rector.outcome }}"
exit 1
fi

code-samples-inclusion-check:
name: Check code samples inclusion
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ protected function getFieldTypeIdentifier(): string
return 'my_field_type';
}

#[\Override]
public function mapToFieldValueInputType(ContentType $contentType, FieldDefinition $fieldDefinition): ?string
{
if (!$this->canMap($fieldDefinition)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;

/**
* @implements \Symfony\Component\Form\DataTransformerInterface<
* \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\ProductName,
* \Ibexa\Bundle\ProductCatalog\Form\Data\Catalog\CatalogFilterPriceData
* >
*/
final class ProductNameCriterionTransformer implements DataTransformerInterface
{
public function transform($value): ?string
Expand Down
2 changes: 1 addition & 1 deletion deptrac.baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ deptrac:
- Ibexa\Bundle\Checkout\Form\Type\AddressType
- Ibexa\Bundle\Payment\Form\Type\PaymentMethodChoiceType
- Ibexa\Bundle\Shipping\Form\Type\ShippingMethodChoiceType
App\GraphQL\Schema\MyCustomFieldDefinitionMapper:
App\GraphQL\Schema\MyFieldDefinitionMapper:
- Ibexa\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition\DecoratingFieldDefinitionMapper
App\Migrations\Action\AssignSection:
- Ibexa\Migration\ValueObject\Step\Action
Expand Down
7 changes: 4 additions & 3 deletions docs/api/graphql/graphql_custom_ft.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ If not specified, it uses `FieldDefinition`.

Compiler pass example that should be placed in `src/DependencyInjection/Compiler`:

``` php
``` php skip-validation
[[= include_file('code_samples/api/graphql/src/DependencyInjection/Compiler/MyCustomTypeGraphQLCompilerPass.php') =]]
```

Expand All @@ -60,7 +60,8 @@ It requires that you implement the `getFieldTypeIdentifier` method to tell which
Add `MyFieldDefinitionMapper.php` mapper to `src/GraphQL/Schema`:

``` php
[[= include_file('code_samples/api/graphql/src/GraphQL/Schema/MyFieldDefinitionMapper.php', 0, 16) =]][[= include_file('code_samples/api/graphql/src/GraphQL/Schema/MyFieldDefinitionMapper.php', 36, 37) =]]
[[= include_code('code_samples/api/graphql/src/GraphQL/Schema/MyFieldDefinitionMapper.php', 1, 17) =]]
[[= include_code('code_samples/api/graphql/src/GraphQL/Schema/MyFieldDefinitionMapper.php', 38, 39) =]]
```

The `FieldDefinitionMapper` interface defines following methods:
Expand All @@ -75,7 +76,7 @@ When a mapper method is decorated, you need to call the decorated service method
To do that, you need to replace `mapXXX` by the method it's in:

```php
[[= include_file('code_samples/api/graphql/src/GraphQL/Schema/MyFieldDefinitionMapper.php', 19, 22, remove_indent=True) =]]
[[= include_code('code_samples/api/graphql/src/GraphQL/Schema/MyFieldDefinitionMapper.php', 21, 24, remove_indent=True) =]]
```

It's required for every implemented method, so that other mappers are called for the other field types.
Expand Down
30 changes: 12 additions & 18 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ parameters:
count: 1
path: code_samples/api/migration/src/Command/MigrationCommand.php

-
message: '#^Instantiated class App\\Notifications\\MyNotification not found\.$#'
identifier: class.notFound
count: 1
path: code_samples/api/notifications/notification_send.php

-
message: '#^Parameter \#1 \$notification of class Ibexa\\Contracts\\Notifications\\Value\\Notification\\SymfonyNotificationAdapter constructor expects Symfony\\Component\\Notifier\\Notification\\Notification, App\\Notifications\\MyNotification given\.$#'
identifier: argument.type
count: 1
path: code_samples/api/notifications/notification_send.php

-
message: '#^Call to an undefined method Ibexa\\Contracts\\ProductCatalog\\Values\\ProductInterface\:\:getPrice\(\)\.$#'
identifier: method.notFound
Expand Down Expand Up @@ -312,12 +324,6 @@ parameters:
count: 1
path: code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageConverter.php

-
message: '#^Class App\\CatalogFilter\\DataTransformer\\ProductNameCriterionTransformer implements generic interface Symfony\\Component\\Form\\DataTransformerInterface but does not specify its types\: T, R$#'
identifier: missingType.generics
count: 1
path: code_samples/catalog/custom_catalog_filter/src/CatalogFilter/DataTransformer/ProductNameCriterionTransformer.php

-
message: '#^Method App\\CatalogFilter\\ProductNameFilter\:\:getTranslationMessages\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand Down Expand Up @@ -678,18 +684,6 @@ parameters:
count: 1
path: code_samples/tutorials/page_tutorial_starting_point/src/QueryType/MenuQueryType.php

-
message: '#^Instantiated class App\\Notifications\\MyNotification not found\.$#'
identifier: class.notFound
count: 1
path: code_samples/user_management/notifications/notification_send.php

-
message: '#^Parameter \#1 \$notification of class Ibexa\\Contracts\\Notifications\\Value\\Notification\\SymfonyNotificationAdapter constructor expects Symfony\\Component\\Notifier\\Notification\\Notification, App\\Notifications\\MyNotification given\.$#'
identifier: argument.type
count: 1
path: code_samples/user_management/notifications/notification_send.php

-
message: '#^Parameter \#2 \$email of method Ibexa\\Contracts\\OAuth2Client\\Repository\\OAuth2UserService\:\:newOAuth2UserCreateStruct\(\) expects string, string\|null given\.$#'
identifier: argument.type
Expand Down
Loading