diff --git a/.github/workflows/code_samples.yaml b/.github/workflows/code_samples.yaml index 9764f2ab1a..962c8fddec 100644 --- a/.github/workflows/code_samples.yaml +++ b/.github/workflows/code_samples.yaml @@ -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 diff --git a/code_samples/api/graphql/src/GraphQL/Schema/MyFieldDefinitionMapper.php b/code_samples/api/graphql/src/GraphQL/Schema/MyFieldDefinitionMapper.php index e450986329..b2a4432f86 100644 --- a/code_samples/api/graphql/src/GraphQL/Schema/MyFieldDefinitionMapper.php +++ b/code_samples/api/graphql/src/GraphQL/Schema/MyFieldDefinitionMapper.php @@ -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)) { diff --git a/code_samples/catalog/custom_catalog_filter/src/CatalogFilter/DataTransformer/ProductNameCriterionTransformer.php b/code_samples/catalog/custom_catalog_filter/src/CatalogFilter/DataTransformer/ProductNameCriterionTransformer.php index fe1cad48ae..8a7837a023 100644 --- a/code_samples/catalog/custom_catalog_filter/src/CatalogFilter/DataTransformer/ProductNameCriterionTransformer.php +++ b/code_samples/catalog/custom_catalog_filter/src/CatalogFilter/DataTransformer/ProductNameCriterionTransformer.php @@ -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 diff --git a/deptrac.baseline.yaml b/deptrac.baseline.yaml index 735af566a5..c45d47606a 100644 --- a/deptrac.baseline.yaml +++ b/deptrac.baseline.yaml @@ -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 diff --git a/docs/api/graphql/graphql_custom_ft.md b/docs/api/graphql/graphql_custom_ft.md index 9010719f4c..1a4f416d5c 100644 --- a/docs/api/graphql/graphql_custom_ft.md +++ b/docs/api/graphql/graphql_custom_ft.md @@ -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') =]] ``` @@ -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: @@ -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. diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index fb9caacfb0..0dad648276 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -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 @@ -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 @@ -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