diff --git a/phpcs.xml b/phpcs.xml index afba95a481cda27a0d63bbea6a13ca15a6b70886..86e43243b7a2ff3ca36877dccf798118e11d2e10 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -8,9 +8,9 @@ core.phpcs.xml.dist -> /PATH/TO/DRUPAL/ROOT/core/phpcs.xml.dist <exclude-pattern>*/modules/same_page_preview/*</exclude-pattern> <exclude-pattern>*/modules/xb_vite/*</exclude-pattern> <!-- Drupal (core) uses stylelint: https://www.drupal.org/list-changes/drupal/published?keywords_description=stylelint--> - <exclude-pattern>*.css</exclude-pattern> + <exclude-pattern>*.css$</exclude-pattern> <!-- Drupal (core) uses eslint: https://www.drupal.org/list-changes/drupal/published?keywords_description=eslint--> - <exclude-pattern>*.js</exclude-pattern> + <exclude-pattern>*.js$</exclude-pattern> <!-- Use the Drupal coding standard, but … --> <rule ref="./core.phpcs.xml.dist"> @@ -28,5 +28,8 @@ core.phpcs.xml.dist -> /PATH/TO/DRUPAL/ROOT/core/phpcs.xml.dist <include-pattern>*/Functional/*</include-pattern> <include-pattern>*/tests/modules/*</include-pattern> </exclude> + <exclude name="Drupal.Files.EndFileNewline"> + <exclude-pattern>*/config/install/*.yml$</exclude-pattern> + </exclude> </rule> </ruleset> diff --git a/src/Config/Schema/JsonSchemaObject.php b/src/Config/Schema/JsonSchemaObject.php index 6a806242d425025438a6542c876ca4150b0f5e2a..80cd377aa5cb9b9055f1d0265c4476f9f3731cbb 100644 --- a/src/Config/Schema/JsonSchemaObject.php +++ b/src/Config/Schema/JsonSchemaObject.php @@ -57,7 +57,7 @@ final class JsonSchemaObject extends Mapping { if (\array_key_exists('pattern', $detail)) { $definition['mapping'][$property_name]['constraints']['Regex'] = [ 'pattern' => \sprintf('@%s@', $detail['pattern']), - 'message' => '%value does not match the pattern %pattern.' + 'message' => '%value does not match the pattern %pattern.', ]; } if (\array_key_exists('enum', $detail)) { diff --git a/src/JsonSchemaDefinitionsStreamwrapper.php b/src/JsonSchemaDefinitionsStreamwrapper.php index 09bc60279536e9e6acc79b549cdcabdc3bee37fe..59ea00c25de44815ab87fb9bee1ac67f8f293891 100644 --- a/src/JsonSchemaDefinitionsStreamwrapper.php +++ b/src/JsonSchemaDefinitionsStreamwrapper.php @@ -38,7 +38,7 @@ class JsonSchemaDefinitionsStreamwrapper extends LocalReadOnlyStream { try { [$extension_path, $definition_name] = self::parseUri($uri); } - catch (UnknownExtensionException | UnknownExtensionTypeException $e) { + catch (UnknownExtensionException | UnknownExtensionTypeException) { // @todo Re-throw with more precise exception message for better DX. return FALSE; } diff --git a/src/JsonSchemaInterpreter/JsonSchemaStringFormat.php b/src/JsonSchemaInterpreter/JsonSchemaStringFormat.php index 58d4195791a19bb40e738e41b939e0d26386237a..88909e6f7c54a2f795e625a00da50ebaff61d0dd 100644 --- a/src/JsonSchemaInterpreter/JsonSchemaStringFormat.php +++ b/src/JsonSchemaInterpreter/JsonSchemaStringFormat.php @@ -11,7 +11,6 @@ use Drupal\experience_builder\PropExpressions\StructuredData\FieldTypePropExpres use Drupal\experience_builder\PropShape\PropShape; use Drupal\experience_builder\PropShape\StorablePropShape; use Drupal\experience_builder\ShapeMatcher\DataTypeShapeRequirement; -use Drupal\link\LinkItemInterface; use Symfony\Component\Validator\Constraints\Ip; // phpcs:disable Drupal.Files.LineLength.TooLong @@ -157,8 +156,8 @@ enum JsonSchemaStringFormat: string { // Built-in formats: resource identifiers. // @see https://json-schema.org/understanding-json-schema/reference/string#resource-identifiers // ⚠️ This field type has no widget in Drupal core, otherwise it'd be - // possible to support! But … would allowing the Content Creator to - // enter a UUID really make sense? + // possible to support! But … would allowing the Content Creator to + // enter a UUID really make sense? // @see \Drupal\Core\Field\Plugin\Field\FieldType\UuidItem static::UUID => NULL, // TRICKY: Drupal core does not support RFC3987 aka IRIs, but it's a superset of RFC3986. diff --git a/src/JsonSchemaInterpreter/SdcPropJsonSchemaType.php b/src/JsonSchemaInterpreter/SdcPropJsonSchemaType.php index 1bd367f6a5e0fa9ca0fe3a3fe61e48b3023d2c74..f85d4970af99601e35ec767d3adb5ce45ba4ab1f 100644 --- a/src/JsonSchemaInterpreter/SdcPropJsonSchemaType.php +++ b/src/JsonSchemaInterpreter/SdcPropJsonSchemaType.php @@ -5,13 +5,11 @@ declare(strict_types=1); namespace Drupal\experience_builder\JsonSchemaInterpreter; use Drupal\Core\Entity\TypedData\EntityDataDefinition; -use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem; use Drupal\experience_builder\Plugin\Validation\Constraint\StringSemanticsConstraint; use Drupal\experience_builder\PropExpressions\StructuredData\FieldPropExpression; use Drupal\experience_builder\PropExpressions\StructuredData\FieldTypeObjectPropsExpression; use Drupal\experience_builder\PropExpressions\StructuredData\FieldTypePropExpression; use Drupal\experience_builder\PropExpressions\StructuredData\ReferenceFieldTypePropExpression; -use Drupal\experience_builder\PropExpressions\StructuredData\StructuredDataPropExpression; use Drupal\experience_builder\PropShape\PropShape; use Drupal\experience_builder\PropShape\StorablePropShape; use Drupal\experience_builder\ShapeMatcher\DataTypeShapeRequirement; @@ -47,7 +45,7 @@ use Drupal\experience_builder\ShapeMatcher\DataTypeShapeRequirements; * * @phpstan-type JsonSchema array<string, mixed> */ -enum SdcPropJsonSchemaType : string { +enum SdcPropJsonSchemaType: string { case STRING = 'string'; case NUMBER = 'number'; case INTEGER = 'integer'; @@ -91,10 +89,10 @@ enum SdcPropJsonSchemaType : string { * dynamic prop source expressions that return a value that fits in this prop * shape. * + * @param JsonSchema $schema + * * @see \Drupal\experience_builder\PropSource\DynamicPropSource * @see \Drupal\experience_builder\SdcPropToFieldTypePropMatcher - * - * @param JsonSchema $schema */ public function toDataTypeShapeRequirements(array $schema): DataTypeShapeRequirement|DataTypeShapeRequirements|false { return match ($this) { @@ -132,7 +130,7 @@ enum SdcPropJsonSchemaType : string { // but `preg_match()` in PHP does. // @see https://json-schema.org/understanding-json-schema/reference/regular_expressions // @see \Symfony\Component\Validator\Constraints\Regex - array_key_exists('pattern', $schema) => new DataTypeShapeRequirement('Regex', ['pattern' => '/' . str_replace('/', '\/',$schema['pattern']) . '/']), + array_key_exists('pattern', $schema) => new DataTypeShapeRequirement('Regex', ['pattern' => '/' . str_replace('/', '\/', $schema['pattern']) . '/']), array_key_exists('format', $schema) => JsonSchemaStringFormat::from($schema['format'])->toDataTypeShapeRequirements(), // Otherwise, it's an unrestricted string. Simply surfacing all // structured data containing strings would be meaningless though. To diff --git a/src/Plugin/ExperienceBuilder/ComponentSource/JsComponent.php b/src/Plugin/ExperienceBuilder/ComponentSource/JsComponent.php index 5eab0f11987e40582d5973ba8a4d8759cbf44405..30a9f2e8b5814fd51f3edc42a59f395a67b7d558 100644 --- a/src/Plugin/ExperienceBuilder/ComponentSource/JsComponent.php +++ b/src/Plugin/ExperienceBuilder/ComponentSource/JsComponent.php @@ -4,8 +4,6 @@ declare(strict_types=1); namespace Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource; -use Drupal\Core\Access\AccessResult; -use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\Entity\ConfigEntityStorageInterface; use Drupal\Core\Extension\ExtensionPathResolver; use Drupal\Core\File\FileUrlGeneratorInterface; diff --git a/tests/src/Kernel/Config/Schema/JsonSchemaObjectTest.php b/tests/src/Kernel/Config/Schema/JsonSchemaObjectTest.php index 66d5e36d63e84a39bafdb0f4ea04d75a827c264b..d09416a3f99b23928798821238ead5ff8fd30b8a 100644 --- a/tests/src/Kernel/Config/Schema/JsonSchemaObjectTest.php +++ b/tests/src/Kernel/Config/Schema/JsonSchemaObjectTest.php @@ -32,6 +32,7 @@ final class JsonSchemaObjectTest extends KernelTestBase { } /** + * @phpcs:ignore Drupal.Commenting.FunctionComment.SeeAdditionalText * @see `type: experience_builder.json_schema.prop.object` */ public function testSchemaDerivation(): void { @@ -50,7 +51,7 @@ final class JsonSchemaObjectTest extends KernelTestBase { self::assertViolations([ // We only allow image at this point, but we can still derive schema. '$ref' => 'The value you selected is not a valid choice.', - 'examples.0.element' => 'The value you selected is not a valid choice.' + 'examples.0.element' => 'The value you selected is not a valid choice.', ], $config->validate()); } diff --git a/tests/src/Kernel/Plugin/ExperienceBuilder/ComponentSource/JsComponentTest.php b/tests/src/Kernel/Plugin/ExperienceBuilder/ComponentSource/JsComponentTest.php index c33aba164544e2c85dc1e803effcd7552b1c6b8f..b38ff85a44b4dc295c6377a31138e7bb7da38533 100644 --- a/tests/src/Kernel/Plugin/ExperienceBuilder/ComponentSource/JsComponentTest.php +++ b/tests/src/Kernel/Plugin/ExperienceBuilder/ComponentSource/JsComponentTest.php @@ -8,13 +8,10 @@ use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\Crypt; use Drupal\Core\Asset\AssetResolverInterface; use Drupal\Core\Asset\AttachedAssets; -use Drupal\Core\Render\BubbleableMetadata; use Drupal\Core\Site\Settings; use Drupal\Core\StreamWrapper\StreamWrapperInterface; use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface; -use Drupal\Core\Url; use Drupal\experience_builder\AutoSave\AutoSaveManager; -use Drupal\experience_builder\Element\AstroIsland; use Drupal\experience_builder\Entity\Component; use Drupal\experience_builder\Entity\ComponentInterface; use Drupal\experience_builder\Entity\JavaScriptComponent; @@ -24,7 +21,7 @@ use Drupal\Tests\experience_builder\Traits\CrawlerTrait; use Drupal\Tests\user\Traits\UserCreationTrait; /** - * Tests JsComponent + * Tests JsComponent. * * @covers \Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource\JsComponent * @group experience_builder @@ -36,7 +33,7 @@ final class JsComponentTest extends KernelTestBase { use CrawlerTrait; /** - * Test component + * Test component. */ protected ComponentInterface $component; diff --git a/tests/src/Traits/CreateTestJsComponentTrait.php b/tests/src/Traits/CreateTestJsComponentTrait.php index 157dd41b23b6aca97ffd82e974912308a16fd1aa..a96cf33aa0c8d33c2b192f854b92c8d07b31fde4 100644 --- a/tests/src/Traits/CreateTestJsComponentTrait.php +++ b/tests/src/Traits/CreateTestJsComponentTrait.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace Drupal\Tests\experience_builder\Traits; use Drupal\experience_builder\Entity\JavaScriptComponent; -use Drupal\Tests\migrate_drupal\Traits\CreateTestContentEntitiesTrait; use Symfony\Component\Yaml\Yaml; trait CreateTestJsComponentTrait { @@ -36,4 +35,5 @@ trait CreateTestJsComponentTrait { 'css' => ['original' => '', 'compiled' => ''], ])->save(); } + }