From 9eb564d57f1df4a98e93eabb48cda703d6317e85 Mon Sep 17 00:00:00 2001
From: Lee Rowlands <23667-larowlan@users.noreply.drupalcode.org>
Date: Fri, 19 Jul 2024 05:02:08 +0000
Subject: [PATCH] Issue #3462525 by larowlan: Add gitlabci

---
 .gitlab-ci.yml                                | 108 ++++++++++++++++++
 phpcs.xml.dist                                |  14 +++
 src/ClassyLayout.php                          |   5 +-
 ...ayoutClassesPluginDefinitionFormatTest.php |   4 +-
 4 files changed, 127 insertions(+), 4 deletions(-)
 create mode 100644 .gitlab-ci.yml
 create mode 100644 phpcs.xml.dist

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..6d623f9
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,108 @@
+################
+# DrupalCI GitLabCI template
+#
+# Gitlab-ci.yml to replicate DrupalCI testing for Contrib
+#
+# With thanks to:
+#   * The GitLab Acceleration Initiative participants
+#   * DrupalSpoons
+################
+
+################
+# Guidelines
+#
+# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification. It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained.
+#
+# However, you can modify this template if you have additional needs for your project.
+################
+
+################
+# Includes
+#
+# Additional configuration can be provided through includes.
+# One advantage of include files is that if they are updated upstream, the changes affect all pipelines using that include.
+#
+# Includes can be overridden by re-declaring anything provided in an include, here in gitlab-ci.yml
+# https://docs.gitlab.com/ee/ci/yaml/includes.html#override-included-configuration-values
+################
+
+include:
+  ################
+  # DrupalCI includes:
+  # As long as you include this, any future includes added by the Drupal Association will be accessible to your pipelines automatically.
+  # View these include files at https://git.drupalcode.org/project/gitlab_templates/
+  ################
+  - project: $_GITLAB_TEMPLATES_REPO
+    # "ref" value can be:
+    # - Recommended (default) - `ref: $_GITLAB_TEMPLATES_REF` - The Drupal Association will update this value to the recommended tag for contrib.
+    # - Latest - `ref: main` - Get the latest additions and bug fixes as they are merged into the templates.
+    # - Minor or Major latests - `ref: 1.x-latest` or `ref: 1.0.x-latest` - Get the latest additions within a minor (mostly bugfixes) or major (bugs and new features).
+    # - Fixed tag - `ref: 1.0.1` - Set the value to a known tag. This will not get any updates.
+    # If you change the default value of ref, you should set the _CURL_TEMPLATES_REF variable in the variables section to be the same as set here.
+    ref: $_GITLAB_TEMPLATES_REF
+    file:
+      - '/includes/include.drupalci.main.yml'
+      # EXPERIMENTAL: For Drupal 7, remove the above line and uncomment the below.
+      # - '/includes/include.drupalci.main-d7.yml'
+      - '/includes/include.drupalci.variables.yml'
+      - '/includes/include.drupalci.workflows.yml'
+
+################
+# Pipeline configuration variables
+#
+# These are the variables provided to the Run Pipeline form that a user may want to override.
+#
+# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml
+################
+variables:
+#   SKIP_ESLINT: '1'
+  OPT_IN_TEST_NEXT_MINOR: 1
+  OPT_IN_TEST_NEXT_MAJOR: 1
+  _CSPELL_IGNORE_PATHS: 'tests/fixtures'
+
+
+###################################################################################
+#
+#                                        *
+#                                       /(
+#                                      ((((,
+#                                    /(((((((
+#                                   ((((((((((*
+#                                ,(((((((((((((((
+#                              ,(((((((((((((((((((
+#                            ((((((((((((((((((((((((*
+#                         *(((((((((((((((((((((((((((((
+#                       ((((((((((((((((((((((((((((((((((*
+#                    *((((((((((((((((((  .((((((((((((((((((
+#                  ((((((((((((((((((.       /(((((((((((((((((*
+#                /(((((((((((((((((            .(((((((((((((((((,
+#             ,((((((((((((((((((                 ((((((((((((((((((
+#           .((((((((((((((((((((                   .(((((((((((((((((
+#          (((((((((((((((((((((((                     ((((((((((((((((/
+#        (((((((((((((((((((((((((((/                    ,(((((((((((((((*
+#      .((((((((((((((/  /(((((((((((((.                   ,(((((((((((((((
+#     *((((((((((((((      ,(((((((((((((/                   *((((((((((((((.
+#    ((((((((((((((,          /(((((((((((((.                  ((((((((((((((,
+#   (((((((((((((/              ,(((((((((((((*                 ,(((((((((((((,
+#  *(((((((((((((                .(((((((((((((((                ,(((((((((((((
+#  ((((((((((((/                /((((((((((((((((((.              ,((((((((((((/
+# (((((((((((((              *(((((((((((((((((((((((*             *((((((((((((
+# (((((((((((((            ,(((((((((((((..(((((((((((((           *((((((((((((
+# ((((((((((((,          /((((((((((((*      /((((((((((((/         ((((((((((((
+# (((((((((((((        /((((((((((((/          (((((((((((((*       ((((((((((((
+# (((((((((((((/     /((((((((((((               ,((((((((((((,    *((((((((((((
+#  ((((((((((((((  *(((((((((((/                   *((((((((((((.  ((((((((((((/
+#  *((((((((((((((((((((((((((,                      /(((((((((((((((((((((((((
+#   (((((((((((((((((((((((((                         ((((((((((((((((((((((((,
+#   .(((((((((((((((((((((((/                         ,(((((((((((((((((((((((
+#     ((((((((((((((((((((((/                         ,(((((((((((((((((((((/
+#      *(((((((((((((((((((((                         (((((((((((((((((((((,
+#       ,(((((((((((((((((((((,                      ((((((((((((((((((((/
+#         ,(((((((((((((((((((((*                  /((((((((((((((((((((
+#            ((((((((((((((((((((((,           ,/((((((((((((((((((((,
+#              ,(((((((((((((((((((((((((((((((((((((((((((((((((((
+#                 .(((((((((((((((((((((((((((((((((((((((((((((
+#                     .((((((((((((((((((((((((((((((((((((,.
+#                          .,(((((((((((((((((((((((((.
+#
+###################################################################################
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
new file mode 100644
index 0000000..d05c436
--- /dev/null
+++ b/phpcs.xml.dist
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset name="drupal-project">
+  <description>PHP CodeSniffer configuration for forum project.</description>
+  <rule ref="vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml"/>
+  <arg name="extensions" value="php,inc,module,install,info,test,profile,theme"/>
+  <rule ref="Drupal.Commenting.DocComment.MissingShort">
+    <severity>0</severity>
+  </rule>
+
+  <!-- We can leave the following to PHPstan. -->
+  <rule ref="Drupal.Commenting.VariableComment.MissingVar">
+    <severity>0</severity>
+  </rule>
+</ruleset>
diff --git a/src/ClassyLayout.php b/src/ClassyLayout.php
index 45fba01..8688a0c 100644
--- a/src/ClassyLayout.php
+++ b/src/ClassyLayout.php
@@ -66,9 +66,10 @@ class ClassyLayout extends LayoutDefault implements PluginFormInterface {
       if (empty($class_definition['options']) || !is_array($class_definition['options'])) {
         throw new \Exception('The "options" key is required for layout class definitions.');
       }
-      if ($class_definition['multiple'])  {
+      if ($class_definition['multiple'] ?? FALSE) {
         $definition_default = $class_definition['default'] ?? [];
-      } else {
+      }
+      else {
         $definition_default = $class_definition['default'] ?? NULL;
       }
       $form['classes'][$key] = [
diff --git a/tests/src/Unit/LayoutClassesPluginDefinitionFormatTest.php b/tests/src/Unit/LayoutClassesPluginDefinitionFormatTest.php
index 713f6cd..9c7d577 100644
--- a/tests/src/Unit/LayoutClassesPluginDefinitionFormatTest.php
+++ b/tests/src/Unit/LayoutClassesPluginDefinitionFormatTest.php
@@ -68,7 +68,7 @@ class LayoutClassesPluginDefinitionFormatTest extends UnitTestCase {
   /**
    * Test cases for ::testDefinitionParsing.
    */
-  public function definitionFormGenerationTestCases() {
+  public static function definitionFormGenerationTestCases(): array {
     return [
       'Standard plugin' => [
         new LayoutDefinition([
@@ -118,7 +118,7 @@ class LayoutClassesPluginDefinitionFormatTest extends UnitTestCase {
               ],
               '#required' => FALSE,
               '#default_value' => [],
-              '#description' => 'Select the style that will be applied to this region.',
+              '#description' => 'Select the style that will be applied to this region.', // phpcs:ignore
               '#empty_option' => '- Select -',
             ],
             'spacing' => [
-- 
GitLab