diff --git a/.gitattributes b/.gitattributes index e7b792f8407c7c95dd9a5f34646643adb4fa7a37..f9e806c9a10dd7e41ce31de1b49271c1d155d180 100644 --- a/.gitattributes +++ b/.gitattributes @@ -48,6 +48,7 @@ core/.phpstan-baseline.php text eol=lf whitespace=blank-at-eol,-blank-at-eof,-sp # Define binary file attributes. # - Do not treat them as text. # - Include binary diff in patches instead of "binary files differ." +*.avif -text diff *.eot -text diff *.exe -text diff *.gif -text diff diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b4b2ee57154a7ba0343f3c16ac6f201c382ea07c..cb1d112b2f000b2b509995b686dd569520c20fc6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -347,6 +347,31 @@ default: - core/.eslintcache - core/.stylelintcache +'📔 Spell-checking': + <<: [ *default-job-settings-lint ] + stage: 🪄 Lint + variables: + KUBERNETES_CPU_REQUEST: "2" + script: + - *prepare-lint-directory + - *cspell-cache + - *core-spellcheck + - mv -f /build/core/package.json $CI_PROJECT_DIR/core/package.json + - mv -f /build/core/yarn.lock $CI_PROJECT_DIR/core/yarn.lock + - mv /build/core/node_modules $CI_PROJECT_DIR/core + cache: + key: + files: + - ./core/package.json + - ./core/yarn.lock + paths: + - ./core/node_modules + artifacts: + expire_in: 1 week + expose_as: 'yarn-vendor' + paths: + - core/node_modules/ + '🧹 PHP Static Analysis (phpstan)': <<: [ *default-job-settings-lint ] stage: 🪄 Lint @@ -464,31 +489,6 @@ default: reports: codequality: gl-codequality.json -'📔 Spell-checking': - <<: [ *default-job-settings-lint ] - stage: 🪄 Lint - variables: - KUBERNETES_CPU_REQUEST: "2" - script: - - *prepare-lint-directory - - *cspell-cache - - *core-spellcheck - - mv -f /build/core/package.json $CI_PROJECT_DIR/core/package.json - - mv -f /build/core/yarn.lock $CI_PROJECT_DIR/core/yarn.lock - - mv /build/core/node_modules $CI_PROJECT_DIR/core - cache: - key: - files: - - ./core/package.json - - ./core/yarn.lock - paths: - - ./core/node_modules - artifacts: - expire_in: 1 week - expose_as: 'yarn-vendor' - paths: - - core/node_modules/ - '📔 Validatable config': <<: [ *default-job-settings-lint ] stage: 🪄 Lint diff --git a/.gitlab-ci/pipeline.yml b/.gitlab-ci/pipeline.yml index 7da0bc09298255bda7926f20d8bdcc4955bf4d91..3ed4a14a65c7b474757e45bbc26693fdae5b41ba 100644 --- a/.gitlab-ci/pipeline.yml +++ b/.gitlab-ci/pipeline.yml @@ -151,24 +151,14 @@ variables: - sed -i "s#$CI_PROJECT_DIR/##" ./sites/default/files/simpletest/phpunit-*.xml || true - cp /builds/chromedriver.log ./ -'🖱️️️ PHPUnit Functional Javascript (non W3C legacy)': - <<: [ *with-composer, *default-job-settings ] - parallel: 1 +'👷️️️ PHPUnit Build': + <<: [ *with-composer, *run-tests, *default-job-settings ] variables: - TESTSUITE: PHPUnit-FunctionalJavascript - CONCURRENCY: 6 - KUBERNETES_CPU_REQUEST: "16" - MINK_DRIVER_ARGS_WEBDRIVER: $MINK_DRIVER_ARGS_WEBDRIVER_CHROMEDRIVER_NON_W3C + TESTSUITE: PHPUnit-Build + KUBERNETES_CPU_REQUEST: "8" + CONCURRENCY: "5" services: - <<: *with-database - - <<: *with-chrome - script: - # Run a small subset of tests to prove non W3C testing still works. - - sudo -u www-data -E -H php ./core/scripts/run-tests.sh --color --keep-results --types "$TESTSUITE" --concurrency "$CONCURRENCY" --repeat "1" --sqlite "./sites/default/files/tests.sqlite" --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --verbose --non-html javascript - - after_script: - - sed -i "s#$CI_PROJECT_DIR/##" ./sites/default/files/simpletest/phpunit-*.xml || true - - cp /builds/chromedriver.log ./ '🌐️️ PHPUnit Functional': <<: [ *with-composer, *run-tests, *default-job-settings ] @@ -190,15 +180,6 @@ variables: services: - <<: *with-database -'👷️️️ PHPUnit Build': - <<: [ *with-composer, *run-tests, *default-job-settings ] - variables: - TESTSUITE: PHPUnit-Build - KUBERNETES_CPU_REQUEST: "8" - CONCURRENCY: "5" - services: - - <<: *with-database - '⚡️ PHPUnit Unit': <<: [ *with-composer, *run-tests, *default-job-settings ] variables: @@ -272,6 +253,25 @@ variables: - ./nightwatch_output - '*.log' +'🖱️️️ PHPUnit Functional Javascript (non W3C legacy)': + <<: [ *with-composer, *default-job-settings ] + parallel: 1 + variables: + TESTSUITE: PHPUnit-FunctionalJavascript + CONCURRENCY: 6 + KUBERNETES_CPU_REQUEST: "16" + MINK_DRIVER_ARGS_WEBDRIVER: $MINK_DRIVER_ARGS_WEBDRIVER_CHROMEDRIVER_NON_W3C + services: + - <<: *with-database + - <<: *with-chrome + script: + # Run a small subset of tests to prove non W3C testing still works. + - sudo -u www-data -E -H php ./core/scripts/run-tests.sh --color --keep-results --types "$TESTSUITE" --concurrency "$CONCURRENCY" --repeat "1" --sqlite "./sites/default/files/tests.sqlite" --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --verbose --non-html javascript + + after_script: + - sed -i "s#$CI_PROJECT_DIR/##" ./sites/default/files/simpletest/phpunit-*.xml || true + - cp /builds/chromedriver.log ./ + '🔁 Repeat Class Test': <<: [ *with-composer, *run-repeat-class-test, *default-job-settings ] when: manual diff --git a/composer.lock b/composer.lock index ffb28c03aee1e4a3d4c0f80736e5a100ab681ca0..88795c2dcfe0a9d9bd0eb03b703ca35f8865de84 100644 --- a/composer.lock +++ b/composer.lock @@ -496,7 +496,7 @@ "dist": { "type": "path", "url": "core", - "reference": "71e78e0d59139e8223b07ae3ee950771150a3e8f" + "reference": "bba96164d4ad20ffabd88fff8b13ddfe8089c3c2" }, "require": { "asm89/stack-cors": "^2.1", @@ -525,7 +525,7 @@ "mck89/peast": "^1.14", "pear/archive_tar": "^1.4.14", "php": ">=8.3.0", - "php-tuf/composer-stager": "^2-rc5", + "php-tuf/composer-stager": "^2.0", "psr/log": "^3.0", "revolt/event-loop": "^1.0", "sebastian/diff": "^4|^5", diff --git a/composer/Composer.php b/composer/Composer.php index 606c697ca090d4e7ab7e36960587069578bd6701..6b2a13ccee1b0d5235146ba8df160ee308c8a912 100644 --- a/composer/Composer.php +++ b/composer/Composer.php @@ -119,7 +119,7 @@ public static function drupalVersionBranch(): string { * @param string $root * Path to root of drupal/drupal repository. * @param string $subprojectType - * Type of subproject - one of Metapackage, Plugin, or Template + * Type of subproject - one of Metapackage, Plugin, or Template. * * @return \Symfony\Component\Finder\Finder * A Finder object. diff --git a/composer/Generator/Util/DrupalCoreComposer.php b/composer/Generator/Util/DrupalCoreComposer.php index cf4aea0ce8dfa577566f4411051a87e453d1ee99..414fd3ae7bfb49fc18053dadcb53596d7a2bbd4b 100644 --- a/composer/Generator/Util/DrupalCoreComposer.php +++ b/composer/Generator/Util/DrupalCoreComposer.php @@ -92,7 +92,7 @@ public function getRequireDev() { * @param string $packageName * Name of package to find, e.g. 'behat/mink-selenium2-driver'. * @param bool $dev - * TRUE: consider only 'packages-dev'. Default: consider only 'packages' + * TRUE: consider only 'packages-dev'. Default: consider only 'packages'. * * @return array * Package info from composer.lock. diff --git a/composer/Plugin/Scaffold/Operations/AppendOp.php b/composer/Plugin/Scaffold/Operations/AppendOp.php index f24257e000d677d2b6473fc82860ca1abbb00c5c..4ed8b62d2018a85269a52273c1f903b7b092780b 100644 --- a/composer/Plugin/Scaffold/Operations/AppendOp.php +++ b/composer/Plugin/Scaffold/Operations/AppendOp.php @@ -199,7 +199,7 @@ public function scaffoldAtNewLocation(ScaffoldFilePath $destination) { * @param string $contents * The contents of the target file. * @param \Drupal\Composer\Plugin\Scaffold\ScaffoldFilePath $data_path - * The path to the data to append or prepend + * The path to the data to append or prepend. * * @return bool * 'TRUE' if the append/prepend data already exists in contents. diff --git a/composer/Plugin/Scaffold/Operations/ScaffoldFileCollection.php b/composer/Plugin/Scaffold/Operations/ScaffoldFileCollection.php index c6e89ef4c79190d12f8d15f713c67de3315b5b3f..688bcfdc2ef4577728ec0025de0928442325fb11 100644 --- a/composer/Plugin/Scaffold/Operations/ScaffoldFileCollection.php +++ b/composer/Plugin/Scaffold/Operations/ScaffoldFileCollection.php @@ -77,7 +77,7 @@ public function __construct(array $file_mappings, Interpolator $location_replace * Matching is done via destination path. * * @param string[] $files_to_filter - * List of destination paths + * List of destination paths. */ public function filterFiles(array $files_to_filter) { foreach ($this->scaffoldFilesByProject as $project_name => $scaffold_files) { @@ -97,7 +97,7 @@ public function filterFiles(array $files_to_filter) { * Scans through a list of scaffold files and determines if any has contents. * * @param \Drupal\Composer\Plugin\Scaffold\ScaffoldFileInfo[] $scaffold_files - * List of scaffold files, path: ScaffoldFileInfo + * List of scaffold files, path: ScaffoldFileInfo. * * @return bool * TRUE if at least one item in the list has content diff --git a/composer/Plugin/VendorHardening/VendorHardeningPlugin.php b/composer/Plugin/VendorHardening/VendorHardeningPlugin.php index c4eb88b939a2ef18b1d3eb3221dca2d7bc1853c4..50195be657d2ab9619e51571f9406f7742124fe2 100644 --- a/composer/Plugin/VendorHardening/VendorHardeningPlugin.php +++ b/composer/Plugin/VendorHardening/VendorHardeningPlugin.php @@ -332,7 +332,7 @@ public function cleanPackage(PackageInterface $package): void { * @param \Composer\Package\PackageInterface $package * The package to clean. * @param string[] $paths_for_package - * List of directories in $package_name to remove + * List of directories in $package_name to remove. */ protected function cleanPathsForPackage(PackageInterface $package, $paths_for_package): void { // Whatever happens here, this package counts as cleaned so that we don't diff --git a/core/.phpstan-baseline.php b/core/.phpstan-baseline.php index 33d0f6ad86e5cd91af0faaaf6d7c9fd0dcae31f7..6bfcd63daeb051786ecd2d8a74486703b73b2e83 100644 --- a/core/.phpstan-baseline.php +++ b/core/.phpstan-baseline.php @@ -319,12 +319,6 @@ 'count' => 1, 'path' => __DIR__ . '/includes/install.core.inc', ]; -$ignoreErrors[] = [ - 'message' => '#^Function install_config_download_translations\\(\\) should return string but return statement is missing\\.$#', - 'identifier' => 'return.missing', - 'count' => 1, - 'path' => __DIR__ . '/includes/install.core.inc', -]; $ignoreErrors[] = [ 'message' => '#^Function install_config_import_batch\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -355,12 +349,6 @@ 'count' => 1, 'path' => __DIR__ . '/includes/install.core.inc', ]; -$ignoreErrors[] = [ - 'message' => '#^Function install_download_translation\\(\\) should return string but return statement is missing\\.$#', - 'identifier' => 'return.missing', - 'count' => 2, - 'path' => __DIR__ . '/includes/install.core.inc', -]; $ignoreErrors[] = [ 'message' => '#^Function install_drupal\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -973,12 +961,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Component/Gettext/PoMemoryWriter.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Component\\\\Gettext\\\\PoMemoryWriter\\:\\:getLangcode\\(\\) should return string but return statement is missing\\.$#', - 'identifier' => 'return.missing', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Component/Gettext/PoMemoryWriter.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Component\\\\Gettext\\\\PoMemoryWriter\\:\\:setHeader\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -4933,12 +4915,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/Entity/Controller/EntityController.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\Controller\\\\EntityController\\:\\:deleteTitle\\(\\) should return string but return statement is missing\\.$#', - 'identifier' => 'return.missing', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Core/Entity/Controller/EntityController.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\Controller\\\\EntityRevisionViewController\\:\\:create\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -5989,12 +5965,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/Entity/Query/QueryBase.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\Query\\\\QueryBase\\:\\:getClass\\(\\) should return string but return statement is missing\\.$#', - 'identifier' => 'return.missing', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Core/Entity/Query/QueryBase.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\Query\\\\QueryBase\\:\\:groupBy\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -10801,12 +10771,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/Template/AttributeArray.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Core\\\\Template\\\\AttributeValueBase\\:\\:render\\(\\) should return string but return statement is missing\\.$#', - 'identifier' => 'return.missing', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Core/Template/AttributeValueBase.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Core\\\\Template\\\\AttributeValueBase\\:\\:value\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -20785,12 +20749,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/jsonapi/src/JsonApiResource/LinkCollection.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\jsonapi\\\\JsonApiResource\\\\ResourceIdentifier\\:\\:getDataReferencePropertyName\\(\\) should return string but return statement is missing\\.$#', - 'identifier' => 'return.missing', - 'count' => 1, - 'path' => __DIR__ . '/modules/jsonapi/src/JsonApiResource/ResourceIdentifier.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\jsonapi\\\\JsonApiResource\\\\ResourceObject\\:\\:extractContentEntityFields\\(\\) return type with generic interface Drupal\\\\Core\\\\Field\\\\FieldItemListInterface does not specify its types\\: T$#', 'identifier' => 'missingType.generics', @@ -24235,12 +24193,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/locale/src/StringDatabaseStorage.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\locale\\\\StringDatabaseStorage\\:\\:dbStringTable\\(\\) should return string but return statement is missing\\.$#', - 'identifier' => 'return.missing', - 'count' => 1, - 'path' => __DIR__ . '/modules/locale/src/StringDatabaseStorage.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\locale\\\\StringDatabaseStorage\\:\\:deleteStrings\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -26413,12 +26365,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/migrate/src/Plugin/migrate/destination/Entity.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\migrate\\\\Plugin\\\\migrate\\\\destination\\\\Entity\\:\\:fields\\(\\) should return array but return statement is missing\\.$#', - 'identifier' => 'return.missing', - 'count' => 1, - 'path' => __DIR__ . '/modules/migrate/src/Plugin/migrate/destination/Entity.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\migrate\\\\Plugin\\\\migrate\\\\destination\\\\Entity\\:\\:processStubRow\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -41049,12 +40995,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/views/src/Form/ViewsForm.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\views\\\\Form\\\\ViewsFormMainForm\\:\\:getFormId\\(\\) should return string but return statement is missing\\.$#', - 'identifier' => 'return.missing', - 'count' => 1, - 'path' => __DIR__ . '/modules/views/src/Form/ViewsFormMainForm.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\views\\\\Form\\\\ViewsFormMainForm\\:\\:submitForm\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -43929,12 +43869,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/views/src/Plugin/views/field/EntityField.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\views\\\\Plugin\\\\views\\\\field\\\\EntityField\\:\\:renderItems\\(\\) should return string but return statement is missing\\.$#', - 'identifier' => 'return.missing', - 'count' => 1, - 'path' => __DIR__ . '/modules/views/src/Plugin/views/field/EntityField.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\views\\\\Plugin\\\\views\\\\field\\\\EntityField\\:\\:submitGroupByForm\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -44385,12 +44319,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/views/src/Plugin/views/field/PrerenderList.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\views\\\\Plugin\\\\views\\\\field\\\\PrerenderList\\:\\:renderItems\\(\\) should return string but return statement is missing\\.$#', - 'identifier' => 'return.missing', - 'count' => 1, - 'path' => __DIR__ . '/modules/views/src/Plugin/views/field/PrerenderList.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\views\\\\Plugin\\\\views\\\\field\\\\RenderedEntity\\:\\:buildOptionsForm\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -56200,6 +56128,12 @@ 'count' => 1, 'path' => __DIR__ . '/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php', ]; +$ignoreErrors[] = [ + 'message' => '#^@covers value \\\\Drupal\\\\Core\\\\Entity\\\\Sql\\\\SqlContentEntityStorageSchema\\:\\:onEntityTypeUpdate\\(\\) references an invalid method\\.$#', + 'identifier' => 'phpunit.coversMethod', + 'count' => 1, + 'path' => __DIR__ . '/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php', +]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Tests\\\\Core\\\\Entity\\\\Sql\\\\SqlContentEntityStorageSchemaTest\\:\\:providerSchemaCastValue\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', diff --git a/core/assets/scaffold/files/gitattributes b/core/assets/scaffold/files/gitattributes index e7b792f8407c7c95dd9a5f34646643adb4fa7a37..f9e806c9a10dd7e41ce31de1b49271c1d155d180 100644 --- a/core/assets/scaffold/files/gitattributes +++ b/core/assets/scaffold/files/gitattributes @@ -48,6 +48,7 @@ core/.phpstan-baseline.php text eol=lf whitespace=blank-at-eol,-blank-at-eof,-sp # Define binary file attributes. # - Do not treat them as text. # - Include binary diff in patches instead of "binary files differ." +*.avif -text diff *.eot -text diff *.exe -text diff *.gif -text diff diff --git a/core/composer.json b/core/composer.json index db0174ec59d0675568bcf8c115bf702bc49f2f93..83ededbbfd71ec448985ee4379ab1a50defef783 100644 --- a/core/composer.json +++ b/core/composer.json @@ -50,7 +50,7 @@ "psr/log": "^3.0", "mck89/peast": "^1.14", "sebastian/diff": "^4|^5", - "php-tuf/composer-stager": "^2-rc5" + "php-tuf/composer-stager": "^2.0" }, "conflict": { "drush/drush": "<12.4.3" diff --git a/core/core.services.yml b/core/core.services.yml index 54fbf157977747e091122796d92f1e651b037ab5..bb73e29d505bc93dec5e23853174d9127cdd04e0 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -9,6 +9,9 @@ parameters: cache_default_bin_backends: [] memory_cache_default_bin_backends: [] security.enable_super_user: true + core.moved_classes: + 'Drupal\Core\StringTranslation\TranslationWrapper': + class: 'Drupal\Core\StringTranslation\TranslatableMarkup' session.storage.options: gc_probability: 1 gc_divisor: 100 diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 4cffe40471ee73d80b4bf810e3b2268580efac63..0a90a7472e12901851035751ac7aa138d0a1f286 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -44,11 +44,6 @@ */ define('DRUPAL_ROOT', dirname(__DIR__, 2)); -/** - * Keep backward compatibility for sites with references to TranslationWrapper. - */ -class_alias(TranslatableMarkup::class, '\Drupal\Core\StringTranslation\TranslationWrapper', TRUE); - /** * Translates a string to the current language or to a given language. * diff --git a/core/includes/form.inc b/core/includes/form.inc index 945c625dcb65a2308e9b4ab22eb024f3fa43a115..d04c3b3c6bc7938df00d8aa4233fc260df6211eb 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -357,7 +357,7 @@ function template_preprocess_input(&$variables): void { * @param array $variables * An associative array containing: * - element: An associative array containing the properties of the element. - * Properties used: #action, #method, #attributes, #children + * Properties used: #action, #method, #attributes, #children. */ function template_preprocess_form(&$variables): void { $element = $variables['element']; @@ -670,7 +670,7 @@ function template_preprocess_form_element_label(&$variables): void { * \Drupal::messenger()->addMessage($message); * // Providing data for the redirected page is done through the session. * foreach ($results as $result) { - * $items[] = t('Loaded node %title.', ['%title' => $result)]; + * $items[] = t('Loaded node %title.', ['%title' => $result]); * } * $session = \Drupal::getRequest()->getSession(); * $session->set('my_batch_results', $items); @@ -702,7 +702,7 @@ function template_preprocess_form_element_label(&$variables): void { * Example: * @code * [ - * ['callback_batch_operation_1', [$arg1)], + * ['callback_batch_operation_1', [$arg1]], * ['callback_batch_operation_2', [$arg2_1, $arg2_2]], * ] * @endcode @@ -711,8 +711,10 @@ function template_preprocess_form_element_label(&$variables): void { * - init_message: Message displayed while the processing is initialized. * Defaults to t('Initializing.'). * - progress_message: Message displayed while processing the batch. Available - * placeholders are @current, @remaining, @total, @percentage, @estimate and - * @elapsed. Defaults to t('Completed @current of @total.'). + * placeholders are "@current", "@remaining", "@total", "@percentage", + * phpcs:ignore Drupal.Commenting.FunctionComment.ParamCommentFullStop + * "@estimate" and "@elapsed". Defaults to "t('Completed @current of + * @total.')". * - error_message: Message displayed if an error occurred while processing * the batch. Defaults to t('An error has occurred.'). * - finished: Name of an implementation of callback_batch_finished(). This is diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index b1c6683eec80ceccce95fb1adf5ab6d0812d1d3d..e125d06a035f13dfc1c200e5d573e07d1dc8f964 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1405,7 +1405,7 @@ function install_select_language(&$install_state) { * @param array $install_state * An array of information about the current installation state. * - * @return string + * @return array * A themed status report, or an exception if there are requirement errors. * Upon successful download the page is reloaded and no output is returned. */ @@ -1423,6 +1423,7 @@ function install_download_translation(&$install_state) { if ($install_state['interactive']) { install_goto(install_redirect_url($install_state)); } + return []; } /** @@ -2444,7 +2445,7 @@ function install_config_import_batch() { * @param array $install_state * An array of information about the current installation state. * - * @return string + * @return string|null * A themed status report, or an exception if there are requirement errors. * Upon successful download the page is reloaded and no output is returned. * @@ -2455,6 +2456,7 @@ function install_config_download_translations(&$install_state) { if ($needs_download) { return install_download_translation($install_state); } + return NULL; } /** diff --git a/core/includes/install.inc b/core/includes/install.inc index 368c8c694901e1ce1bd296a30b56ea8953779912..2d246b5c84269eb7c0cbbc3fc7e8b48644c1bdcf 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -373,7 +373,7 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file', $auto_f * Creates a directory with the specified permissions. * * @param string $file - * The name of the directory to create; + * The name of the directory to create. * @param int $mask * The permissions of the directory to create. * @param bool $message diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 21a6f7a87f5978bbef211c22fd1db5a8bfd52564..7d72c4e8e8dc5eb1e28b7b365eac98802b67e466 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -330,9 +330,9 @@ function theme_settings_convert_to_config(array $theme_settings, Config $config) * * @param array $variables * An associative array possibly containing: - * - attributes['timestamp']: - * - timestamp: - * - text: + * - "attributes['timestamp']:". + * - "timestamp:". + * - "text:". */ function template_preprocess_time(&$variables): void { /** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */ @@ -620,6 +620,7 @@ function template_preprocess_links(&$variables): void { * - attributes: Associative array of attributes to be placed in the img tag. * - srcset: Array of multiple URIs and sizes/multipliers. * - sizes: The sizes attribute for viewport-based selection of images. + * phpcs:ignore * - http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content.html#introduction-3:viewport-based-selection-2 */ function template_preprocess_image(&$variables): void { diff --git a/core/lib/Drupal/Component/Assertion/Inspector.php b/core/lib/Drupal/Component/Assertion/Inspector.php index d7bc6f994389a58bd5cd0feaaa77661285991702..a59787e7bd8e0481325663142dec55d3f7a2fea2 100644 --- a/core/lib/Drupal/Component/Assertion/Inspector.php +++ b/core/lib/Drupal/Component/Assertion/Inspector.php @@ -94,7 +94,7 @@ public static function assertAllStringable($traversable) { * in any way will cause a problem. * * @param mixed $string - * Variable to be examined + * Variable to be examined. * * @return bool * TRUE if $string is a string or an object castable to a string. diff --git a/core/lib/Drupal/Component/Datetime/DateTimePlus.php b/core/lib/Drupal/Component/Datetime/DateTimePlus.php index d37dc44e96a691889b51ec316479b0cd54b1b13a..4f95d6d8b662edb3359f52004d191ad4e8f4ddac 100644 --- a/core/lib/Drupal/Component/Datetime/DateTimePlus.php +++ b/core/lib/Drupal/Component/Datetime/DateTimePlus.php @@ -219,6 +219,7 @@ public static function createFromTimestamp($timestamp, $timezone = NULL, $settin * to use things like negative years, which php's parser fails on, or * any other specialized input with a known format. If provided the * date will be created using the createFromFormat() method. + * phpcs:ignore Drupal.Commenting.FunctionComment.ParamCommentFullStop * @see http://php.net/manual/datetime.createfromformat.php * @param string $time * String representing the time. @@ -285,6 +286,7 @@ public static function createFromFormat($format, $time, $timezone = NULL, $setti * parameter and the current timezone are ignored when the $time parameter * either is a UNIX timestamp (e.g. @946684800) or specifies a timezone * (e.g. 2010-01-28T15:00:00+02:00). + * phpcs:ignore Drupal.Commenting.FunctionComment.ParamCommentFullStop * @see http://php.net/manual/datetime.construct.php * @param array $settings * (optional) Keyed array of settings. Defaults to empty array. diff --git a/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php b/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php index b4d28b5d7697c3101a578799b211895036c07c39..b85ac6a2771e090c02de00afe0d26060e7f39283 100644 --- a/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php +++ b/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php @@ -67,6 +67,7 @@ public function setLangcode($langcode) { * Not implemented. Not relevant for the MemoryWriter. */ public function getLangcode() { + throw new \LogicException(__METHOD__ . '() not implemented. Not relevant for the MemoryWriter'); } /** diff --git a/core/lib/Drupal/Component/Utility/Number.php b/core/lib/Drupal/Component/Utility/Number.php index 6c7c0ab6bbd645f7672500b56d4d3fe05c3604ac..0845d14d66ab0b345eaa09076a4eabd32f816e04 100644 --- a/core/lib/Drupal/Component/Utility/Number.php +++ b/core/lib/Drupal/Component/Utility/Number.php @@ -87,7 +87,7 @@ public static function intToAlphadecimal($i = 0) { * Decodes a sorting code back to an integer. * * @param string $string - * The alpha decimal value to convert + * The alpha decimal value to convert. * * @return int * The integer value. diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php index 9ad996c239806e24d816ff10be846c7db6827359..3b32dc9625e69330049cd9bf79b0ef74d8622cf6 100644 --- a/core/lib/Drupal/Component/Utility/UrlHelper.php +++ b/core/lib/Drupal/Component/Utility/UrlHelper.php @@ -285,7 +285,7 @@ public static function isExternal($path) { * @param string $url * A string containing an external URL, such as "http://example.com/foo". * @param string $base_url - * The base URL string to check against, such as "http://example.com/" + * The base URL string to check against, such as "http://example.com/". * * @return bool * TRUE if the URL has the same domain and base path. diff --git a/core/lib/Drupal/Core/Access/AccessResult.php b/core/lib/Drupal/Core/Access/AccessResult.php index 4b4be161c7cfe6c8730f216cb74a5f5eb888d7b7..479867c083f35e000f4aa207b8ae71d3782d6a28 100644 --- a/core/lib/Drupal/Core/Access/AccessResult.php +++ b/core/lib/Drupal/Core/Access/AccessResult.php @@ -87,7 +87,7 @@ public static function allowedIf($condition) { * The condition to evaluate. * @param string|null $reason * (optional) The reason why access is forbidden. Intended for developers, - * hence not translatable + * hence not translatable. * * @return \Drupal\Core\Access\AccessResult * If $condition is TRUE, isForbidden() will be TRUE, otherwise isNeutral() @@ -131,7 +131,7 @@ public static function allowedIfHasPermission(AccountInterface $account, $permis * The permissions to check. * @param string $conjunction * (optional) 'AND' if all permissions are required, 'OR' in case just one. - * Defaults to 'AND' + * Defaults to 'AND'. * * @return \Drupal\Core\Access\AccessResult * If the account has the permissions, isAllowed() will be TRUE, otherwise diff --git a/core/lib/Drupal/Core/Access/AccessResultNeutral.php b/core/lib/Drupal/Core/Access/AccessResultNeutral.php index 5cc38dbdcd1fe5cb4198ba02499039607c449e88..22add897b1cb5a88e2d2a13da66d315f899fb0a7 100644 --- a/core/lib/Drupal/Core/Access/AccessResultNeutral.php +++ b/core/lib/Drupal/Core/Access/AccessResultNeutral.php @@ -18,7 +18,7 @@ class AccessResultNeutral extends AccessResult implements AccessResultReasonInte * Constructs a new AccessResultNeutral instance. * * @param null|string $reason - * (optional) A message to provide details about this access result + * (optional) A message to provide details about this access result. */ public function __construct($reason = NULL) { $this->reason = $reason; diff --git a/core/lib/Drupal/Core/Annotation/Translation.php b/core/lib/Drupal/Core/Annotation/Translation.php index 401a186fd15b7695fe7f0ae731986ce56444ecc2..6e5fca83e80accf0903ba00d94187e39747e9327 100644 --- a/core/lib/Drupal/Core/Annotation/Translation.php +++ b/core/lib/Drupal/Core/Annotation/Translation.php @@ -70,7 +70,7 @@ class Translation extends AnnotationBase { * - value (required): the string that is to be translated. * - arguments (optional): an array with placeholder replacements, keyed by * placeholder. - * - context (optional): a string that describes the context of "value"; + * - context (optional): a string that describes the context of "value". */ public function __construct(array $values) { $string = $values['value']; diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index aef7e5d9d5ef1be9a235d16ce13e98d706ff9fdc..efae811b7679a66c32a046fcd63058ce13913c7c 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -30,7 +30,7 @@ class DatabaseBackend implements CacheBackendInterface { const DEFAULT_MAX_ROWS = 5000; /** - * -1 means infinite allows numbers of rows for the cache backend. + * Indicates that an infinite number of rows is allowed for the cache backend. */ const MAXIMUM_NONE = -1; diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackendFactory.php b/core/lib/Drupal/Core/Cache/DatabaseBackendFactory.php index b931ee11ec902783e15e204535c87231b49e91da..3a0a560967f36ea44cb66981ae5e6ab3d47ea3d4 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackendFactory.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackendFactory.php @@ -27,7 +27,7 @@ class DatabaseBackendFactory implements CacheFactoryInterface { * Constructs the DatabaseBackendFactory object. * * @param \Drupal\Core\Database\Connection $connection - * Database connection + * Database connection. * @param \Drupal\Core\Cache\CacheTagsChecksumInterface $checksum_provider * The cache tags checksum provider. * @param \Drupal\Core\Site\Settings $settings diff --git a/core/lib/Drupal/Core/Cache/VariationCache.php b/core/lib/Drupal/Core/Cache/VariationCache.php index 4454911b9dd999366cbb4ca761cd64929c642ac2..3e3080b3230123ddcdb8007b227bfcdff7237615 100644 --- a/core/lib/Drupal/Core/Cache/VariationCache.php +++ b/core/lib/Drupal/Core/Cache/VariationCache.php @@ -220,7 +220,7 @@ public function set(array $keys, $data, CacheableDependencyInterface $cacheabili // need to be cleared. If they ever end up leading to a stale cache item // that now uses different contexts then said item will either follow an // existing path of redirects or carve its own over the old one. - /** @phpstan-ignore variable.undefined */ + // @phpstan-ignore variable.undefined $this->cacheBackend->set($chain_cid, new CacheRedirect($cacheability)); } diff --git a/core/lib/Drupal/Core/ClassLoader/BackwardsCompatibilityClassLoader.php b/core/lib/Drupal/Core/ClassLoader/BackwardsCompatibilityClassLoader.php new file mode 100644 index 0000000000000000000000000000000000000000..078579ce4cc709dda8dcc6fa7ed2e1c288b8380a --- /dev/null +++ b/core/lib/Drupal/Core/ClassLoader/BackwardsCompatibilityClassLoader.php @@ -0,0 +1,28 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Core\ClassLoader; + +final class BackwardsCompatibilityClassLoader { + + public function __construct(protected array $movedClasses) {} + + /** + * Aliases a moved class to another class, instead of actually autoloading it. + * + * @param string $class + * The classname to load. + */ + public function loadClass(string $class): void { + if (isset($this->movedClasses[$class])) { + $moved = $this->movedClasses[$class]; + if (isset($moved['deprecation_version']) && isset($moved['removed_version']) && isset($moved['change_record'])) { + // @phpcs:ignore + @trigger_error(sprintf('Class %s is deprecated in %s and is removed from %s, use %s instead. See %s', $class, $moved['deprecation_version'], $moved['removed_version'], $moved['class'], $moved['change_record']), E_USER_DEPRECATED); + } + class_alias($moved['class'], $class, TRUE); + } + } + +} diff --git a/core/lib/Drupal/Core/Config/CachedStorage.php b/core/lib/Drupal/Core/Config/CachedStorage.php index c1633dbcb538c63414c4cef49e9fd0c4638fb325..a1085d84f9822e6d70c2c6c7f90fc2d21ca05193 100644 --- a/core/lib/Drupal/Core/Config/CachedStorage.php +++ b/core/lib/Drupal/Core/Config/CachedStorage.php @@ -196,7 +196,7 @@ public function listAll($prefix = '') { * names. * * @param string $prefix - * The prefix to search for + * The prefix to search for. * * @return array * An array containing matching configuration object names. diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index 411ffad30fd686eee7befb0de18b530190c0d7a2..86359e6e8fe300498877d4523ef260c3370ae182 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -191,11 +191,11 @@ class ConfigImporter { * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config * The typed configuration manager. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler + * The module handler. * @param \Drupal\Core\Extension\ModuleInstallerInterface $module_installer * The module installer. * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler - * The theme handler + * The theme handler. * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * The string translation service. * @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module diff --git a/core/lib/Drupal/Core/Config/Entity/ThirdPartySettingsInterface.php b/core/lib/Drupal/Core/Config/Entity/ThirdPartySettingsInterface.php index 3223a41badda353829cd603b1415979c9b01da73..8d8a254a7df495f4a4c1c36af967711360d36bbc 100644 --- a/core/lib/Drupal/Core/Config/Entity/ThirdPartySettingsInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ThirdPartySettingsInterface.php @@ -34,7 +34,7 @@ public function setThirdPartySetting($module, $key, $value); * @param string $key * The setting name. * @param mixed $default - * The default value + * The default value. * * @return mixed * The value. diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php index 17346fedf0714f9714abdd04a73879c73f3d775f..99fdb0d5978cbdc1ccc1098f0d24bae8020a16b4 100644 --- a/core/lib/Drupal/Core/Config/TypedConfigManager.php +++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php @@ -46,9 +46,9 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI * Creates a new typed configuration manager. * * @param \Drupal\Core\Config\StorageInterface $configStorage - * The storage object to use for reading schema data + * The storage object to use for reading schema data. * @param \Drupal\Core\Config\StorageInterface $schemaStorage - * The storage object to use for reading schema data + * The storage object to use for reading schema data. * @param \Drupal\Core\Cache\CacheBackendInterface $cache * The cache backend to use for caching the definitions. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler diff --git a/core/lib/Drupal/Core/CoreServiceProvider.php b/core/lib/Drupal/Core/CoreServiceProvider.php index 7f0c897b6547e3fdca5acdcb6ef09e7bf47fea92..106df846dbd7480570a4c7932c5445efd846232e 100644 --- a/core/lib/Drupal/Core/CoreServiceProvider.php +++ b/core/lib/Drupal/Core/CoreServiceProvider.php @@ -6,6 +6,7 @@ use Drupal\Core\Cache\ListCacheBinsPass; use Drupal\Core\DependencyInjection\Compiler\AuthenticationProviderPass; use Drupal\Core\DependencyInjection\Compiler\BackendCompilerPass; +use Drupal\Core\DependencyInjection\Compiler\BackwardsCompatibilityClassLoaderPass; use Drupal\Core\DependencyInjection\Compiler\CorsCompilerPass; use Drupal\Core\DependencyInjection\Compiler\DeprecatedServicePass; use Drupal\Core\DependencyInjection\Compiler\DevelopmentSettingsPass; @@ -110,6 +111,9 @@ public function register(ContainerBuilder $container) { $container->addCompilerPass(new DeprecatedServicePass()); + // Collect moved classes for the backwards compatibility class loader. + $container->addCompilerPass(new BackwardsCompatibilityClassLoaderPass()); + $container->registerForAutoconfiguration(EventSubscriberInterface::class) ->addTag('event_subscriber'); diff --git a/core/lib/Drupal/Core/Cron.php b/core/lib/Drupal/Core/Cron.php index 222638c24ec9166a52c281e6cd96726277a84990..1773d810a25b9999137ef9f95e203f5ac9f183d1 100644 --- a/core/lib/Drupal/Core/Cron.php +++ b/core/lib/Drupal/Core/Cron.php @@ -38,7 +38,7 @@ class Cron implements CronInterface { * Constructs a cron object. * * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler - * The module handler + * The module handler. * @param \Drupal\Core\Lock\LockBackendInterface $lock * The lock service. * @param \Drupal\Core\Queue\QueueFactory $queueFactory diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index f28f60a521026bce85946f3d866c7de6fb1861d7..41bd043c5c8f45846e4e5ac8fc78c89621b6b60f 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -12,6 +12,7 @@ use Drupal\Core\Database\Query\Select; use Drupal\Core\Database\Query\Truncate; use Drupal\Core\Database\Query\Update; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Database\Transaction\TransactionManagerInterface; use Drupal\Core\Pager\PagerManagerInterface; @@ -250,11 +251,10 @@ public function getClientConnection(): object { * A given query can be customized with a number of option flags in an * associative array: * - fetch: This element controls how rows from a result set will be - * returned. Legal values include \PDO::FETCH_ASSOC, \PDO::FETCH_BOTH, - * \PDO::FETCH_OBJ, \PDO::FETCH_NUM, or a string representing the name of a - * class. If a string is specified, each record will be fetched into a new - * object of that class. The behavior of all other values is defined by PDO. - * See http://php.net/manual/pdostatement.fetch.php + * returned. Legal values include one of the enumeration cases of FetchAs or + * a string representing the name of a class. If a string is specified, each + * record will be fetched into a new object of that class. The behavior of + * all other values is described in the FetchAs enum. * - allow_delimiter_in_query: By default, queries which have the ; delimiter * any place in them will cause an exception. This reduces the chance of SQL * injection attacks that terminate the original query and add one or more @@ -277,7 +277,7 @@ public function getClientConnection(): object { */ protected function defaultOptions() { return [ - 'fetch' => \PDO::FETCH_OBJ, + 'fetch' => FetchAs::Object, 'allow_delimiter_in_query' => FALSE, 'allow_square_brackets' => FALSE, 'pdo' => [], @@ -432,6 +432,9 @@ public function getFullQualifiedTableName($table) { */ public function prepareStatement(string $query, array $options, bool $allow_row_count = FALSE): StatementInterface { assert(!isset($options['return']), 'Passing "return" option to prepareStatement() has no effect. See https://www.drupal.org/node/3185520'); + if (isset($options['fetch']) && is_int($options['fetch'])) { + @trigger_error("Passing the 'fetch' key as an integer to \$options in prepareStatement() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + } try { $query = $this->preprocessStatement($query, $options); @@ -650,6 +653,9 @@ public function query($query, array $args = [], $options = []) { assert(is_string($query), 'The \'$query\' argument to ' . __METHOD__ . '() must be a string'); assert(!isset($options['return']), 'Passing "return" option to query() has no effect. See https://www.drupal.org/node/3185520'); assert(!isset($options['target']), 'Passing "target" option to query() has no effect. See https://www.drupal.org/node/2993033'); + if (isset($options['fetch']) && is_int($options['fetch'])) { + @trigger_error("Passing the 'fetch' key as an integer to \$options in query() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + } // Use default values if not already set. $options += $this->defaultOptions(); @@ -1280,7 +1286,7 @@ public function quote($string, $parameter_type = \PDO::PARAM_STR) { * Extracts the SQLSTATE error from a PDOException. * * @param \Exception $e - * The exception + * The exception. * * @return string * The five character error code. diff --git a/core/lib/Drupal/Core/Database/Statement/FetchAs.php b/core/lib/Drupal/Core/Database/Statement/FetchAs.php new file mode 100644 index 0000000000000000000000000000000000000000..051ed412a2b1c1bae4382c7a75ef3d6d018b6235 --- /dev/null +++ b/core/lib/Drupal/Core/Database/Statement/FetchAs.php @@ -0,0 +1,31 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Core\Database\Statement; + +/** + * Enumeration of the fetch modes for result sets. + */ +enum FetchAs { + + // Returns an anonymous object with property names that correspond to the + // column names returned in the result set. This is the default fetch mode + // for Drupal. + case Object; + + // Returns a new instance of a requested class, mapping the columns of the + // result set to named properties in the class. + case ClassObject; + + // Returns an array indexed by column name as returned in the result set. + case Associative; + + // Returns an array indexed by column number as returned in the result set, + // starting at column 0. + case List; + + // Returns a single column from the next row of a result set. + case Column; + +} diff --git a/core/lib/Drupal/Core/Database/Statement/PdoTrait.php b/core/lib/Drupal/Core/Database/Statement/PdoTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..064c882b7f11c7f665148874f4c0fe46358d9369 --- /dev/null +++ b/core/lib/Drupal/Core/Database/Statement/PdoTrait.php @@ -0,0 +1,229 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Core\Database\Statement; + +/** + * A trait for calling \PDOStatement methods. + */ +trait PdoTrait { + + /** + * Converts a FetchAs mode to a \PDO::FETCH_* constant value. + * + * @param \Drupal\Core\Database\FetchAs $mode + * The FetchAs mode. + * + * @return int + * A \PDO::FETCH_* constant value. + */ + protected function fetchAsToPdo(FetchAs $mode): int { + return match ($mode) { + FetchAs::Associative => \PDO::FETCH_ASSOC, + FetchAs::ClassObject => \PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, + FetchAs::Column => \PDO::FETCH_COLUMN, + FetchAs::List => \PDO::FETCH_NUM, + FetchAs::Object => \PDO::FETCH_OBJ, + }; + } + + /** + * Converts a \PDO::FETCH_* constant value to a FetchAs mode. + * + * @param int $mode + * The \PDO::FETCH_* constant value. + * + * @return \Drupal\Core\Database\FetchAs + * A FetchAs mode. + */ + protected function pdoToFetchAs(int $mode): FetchAs { + return match ($mode) { + \PDO::FETCH_ASSOC => FetchAs::Associative, + \PDO::FETCH_CLASS, \PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE => FetchAs::ClassObject, + \PDO::FETCH_COLUMN => FetchAs::Column, + \PDO::FETCH_NUM => FetchAs::List, + \PDO::FETCH_OBJ => FetchAs::Object, + default => throw new \RuntimeException('Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.'), + }; + } + + /** + * Returns the client-level database PDO statement object. + * + * This method should normally be used only within database driver code. + * + * @return \PDOStatement + * The client-level database PDO statement. + * + * @throws \RuntimeException + * If the client-level statement is not set. + */ + public function getClientStatement(): \PDOStatement { + if (isset($this->clientStatement)) { + assert($this->clientStatement instanceof \PDOStatement); + return $this->clientStatement; + } + throw new \LogicException('\\PDOStatement not initialized'); + } + + /** + * Sets the default fetch mode for the PDO statement. + * + * @param \Drupal\Core\Database\FetchAs $mode + * One of the cases of the FetchAs enum. + * @param int|class-string|null $columnOrClass + * If $mode is FetchAs::Column, the index of the column to fetch. + * If $mode is FetchAs::ClassObject, the FQCN of the object. + * @param list<mixed>|null $constructorArguments + * If $mode is FetchAs::ClassObject, the arguments to pass to the + * constructor. + * + * @return bool + * Returns true on success or false on failure. + */ + protected function clientSetFetchMode(FetchAs $mode, int|string|null $columnOrClass = NULL, array|null $constructorArguments = NULL): bool { + return match ($mode) { + FetchAs::Column => $this->getClientStatement()->setFetchMode( + \PDO::FETCH_COLUMN, + $columnOrClass ?? $this->fetchOptions['column'], + ), + FetchAs::ClassObject => $this->getClientStatement()->setFetchMode( + \PDO::FETCH_CLASS, + $columnOrClass ?? $this->fetchOptions['class'], + $constructorArguments ?? $this->fetchOptions['constructor_args'], + ), + default => $this->getClientStatement()->setFetchMode( + $this->fetchAsToPdo($mode), + ), + }; + } + + /** + * Executes the prepared PDO statement. + * + * @param array|null $arguments + * An array of values with as many elements as there are bound parameters in + * the SQL statement being executed. This can be NULL. + * @param array $options + * An array of options for this query. + * + * @return bool + * TRUE on success, or FALSE on failure. + */ + protected function clientExecute(?array $arguments = [], array $options = []): bool { + return $this->getClientStatement()->execute($arguments); + } + + /** + * Fetches the next row from the PDO statement. + * + * @param \Drupal\Core\Database\FetchAs|null $mode + * (Optional) one of the cases of the FetchAs enum. If not specified, + * defaults to what is specified by setFetchMode(). + * @param int|null $cursorOrientation + * Not implemented in all database drivers, don't use. + * @param int|null $cursorOffset + * Not implemented in all database drivers, don't use. + * + * @return array<scalar|null>|object|scalar|null|false + * A result, formatted according to $mode, or FALSE on failure. + */ + protected function clientFetch(?FetchAs $mode = NULL, ?int $cursorOrientation = NULL, ?int $cursorOffset = NULL): array|object|int|float|string|bool|NULL { + return match(func_num_args()) { + 0 => $this->getClientStatement()->fetch(), + 1 => $this->getClientStatement()->fetch($this->fetchAsToPdo($mode)), + 2 => $this->getClientStatement()->fetch($this->fetchAsToPdo($mode), $cursorOrientation), + default => $this->getClientStatement()->fetch($this->fetchAsToPdo($mode), $cursorOrientation, $cursorOffset), + }; + } + + /** + * Returns a single column from the next row of a result set. + * + * @param int $column + * 0-indexed number of the column to retrieve from the row. If no value is + * supplied, the first column is fetched. + * + * @return scalar|null|false + * A single column from the next row of a result set or false if there are + * no more rows. + */ + protected function clientFetchColumn(int $column = 0): int|float|string|bool|NULL { + return $this->getClientStatement()->fetchColumn($column); + } + + /** + * Fetches the next row and returns it as an object. + * + * @param class-string|null $class + * FQCN of the class to be instantiated. + * @param list<mixed>|null $constructorArguments + * The arguments to be passed to the constructor. + * + * @return object|false + * An instance of the required class with property names that correspond + * to the column names, or FALSE on failure. + */ + protected function clientFetchObject(?string $class = NULL, array $constructorArguments = []): object|FALSE { + if ($class) { + return $this->getClientStatement()->fetchObject($class, $constructorArguments); + } + return $this->getClientStatement()->fetchObject(); + } + + /** + * Returns an array containing all of the result set rows. + * + * @param \Drupal\Core\Database\FetchAs|null $mode + * (Optional) one of the cases of the FetchAs enum. If not specified, + * defaults to what is specified by setFetchMode(). + * @param int|class-string|null $columnOrClass + * If $mode is FetchAs::Column, the index of the column to fetch. + * If $mode is FetchAs::ClassObject, the FQCN of the object. + * @param list<mixed>|null $constructorArguments + * If $mode is FetchAs::ClassObject, the arguments to pass to the + * constructor. + * + * @return array<array<scalar|null>|object|scalar|null> + * An array of results. + */ + // phpcs:ignore Drupal.Commenting.FunctionComment.InvalidReturn, Drupal.Commenting.FunctionComment.Missing + protected function clientFetchAll(?FetchAs $mode = NULL, int|string|null $columnOrClass = NULL, array|null $constructorArguments = NULL): array { + return match ($mode) { + FetchAs::Column => $this->getClientStatement()->fetchAll( + \PDO::FETCH_COLUMN, + $columnOrClass ?? $this->fetchOptions['column'], + ), + FetchAs::ClassObject => $this->getClientStatement()->fetchAll( + \PDO::FETCH_CLASS, + $columnOrClass ?? $this->fetchOptions['class'], + $constructorArguments ?? $this->fetchOptions['constructor_args'], + ), + default => $this->getClientStatement()->fetchAll( + $this->fetchAsToPdo($mode ?? $this->defaultFetchMode), + ), + }; + } + + /** + * Returns the number of rows affected by the last SQL statement. + * + * @return int + * The number of rows. + */ + protected function clientRowCount(): int { + return $this->getClientStatement()->rowCount(); + } + + /** + * Returns the query string used to prepare the statement. + * + * @return string + * The query string. + */ + protected function clientQueryString(): string { + return $this->getClientStatement()->queryString; + } + +} diff --git a/core/lib/Drupal/Core/Database/StatementInterface.php b/core/lib/Drupal/Core/Database/StatementInterface.php index c7d19201ffa685de4abe3ce511b210645a6abe0f..1f229373c4e4e37f6981b654b2faadbc23db8177 100644 --- a/core/lib/Drupal/Core/Database/StatementInterface.php +++ b/core/lib/Drupal/Core/Database/StatementInterface.php @@ -65,18 +65,18 @@ public function rowCount(); /** * Sets the default fetch mode for this statement. * - * See http://php.net/manual/pdo.constants.php for the definition of the - * constants used. - * - * @param int $mode - * One of the \PDO::FETCH_* constants. - * @param int|null $a1 + * @param \Drupal\Core\Database\FetchAs|int $mode + * One of the cases of the FetchAs enum, or (deprecated) a \PDO::FETCH_* + * constant. + * @param string|int|null $a1 * An option depending of the fetch mode specified by $mode: - * - for \PDO::FETCH_COLUMN, the index of the column to fetch - * - for \PDO::FETCH_CLASS, the name of the class to create - * - for \PDO::FETCH_INTO, the object to add the data to - * @param array $a2 - * If $mode is \PDO::FETCH_CLASS, the optional arguments to pass to the + * - for FetchAs::Column, the index of the column to fetch; + * - for FetchAs::ClassObject, the name of the class to create. + * @param list<mixed> $a2 + * If $mode is FetchAs::ClassObject, the optional arguments to pass to the + * - for \PDO::FETCH_COLUMN, the index of the column to fetch. + * - for \PDO::FETCH_CLASS, the name of the class to create. + * - for \PDO::FETCH_INTO, the object to add the data to. * constructor. */ public function setFetchMode($mode, $a1 = NULL, $a2 = []); @@ -84,12 +84,10 @@ public function setFetchMode($mode, $a1 = NULL, $a2 = []); /** * Fetches the next row from a result set. * - * See http://php.net/manual/pdo.constants.php for the definition of the - * constants used. - * - * @param int $mode - * One of the \PDO::FETCH_* constants. - * Default to what was specified by setFetchMode(). + * @param \Drupal\Core\Database\FetchAs|int|null $mode + * (Optional) one of the cases of the FetchAs enum, or (deprecated) a + * \PDO::FETCH_* constant. If not specified, defaults to what is specified + * by setFetchMode(). * @param int|null $cursor_orientation * Not implemented in all database drivers, don't use. * @param int|null $cursor_offset @@ -146,12 +144,14 @@ public function fetchAssoc(); /** * Returns an array containing all of the result set rows. * - * @param int|null $mode - * One of the \PDO::FETCH_* constants. + * @param \Drupal\Core\Database\FetchAs|int|null $mode + * (Optional) one of the cases of the FetchAs enum, or (deprecated) a + * \PDO::FETCH_* constant. If not specified, defaults to what is specified + * by setFetchMode(). * @param int|null $column_index - * If $mode is \PDO::FETCH_COLUMN, the index of the column to fetch. + * If $mode is FetchAs::Column, the index of the column to fetch. * @param array $constructor_arguments - * If $mode is \PDO::FETCH_CLASS, the arguments to pass to the constructor. + * If $mode is FetchAs::ClassObject, the arguments to pass to the constructor. * * @return array * An array of results. @@ -202,11 +202,12 @@ public function fetchAllKeyed($key_index = 0, $value_index = 1); * * @param string $key * The name of the field on which to index the array. - * @param int|null $fetch - * The fetch mode to use. If set to \PDO::FETCH_ASSOC, \PDO::FETCH_NUM, or - * \PDO::FETCH_BOTH the returned value with be an array of arrays. For any - * other value it will be an array of objects. By default, the fetch mode - * set for the query will be used. + * @param \Drupal\Core\Database\FetchAs|int|string|null $fetch + * (Optional) the fetch mode to use. One of the cases of the FetchAs enum, + * or (deprecated) a \PDO::FETCH_* constant. If set to FetchAs::Associative + * or FetchAs::List the returned value with be an array of arrays. For any + * other value it will be an array of objects. If not specified, defaults to + * what is specified by setFetchMode(). * * @return array * An associative array, or an empty array if there is no result set. diff --git a/core/lib/Drupal/Core/Database/StatementPrefetchIterator.php b/core/lib/Drupal/Core/Database/StatementPrefetchIterator.php index 8d6a1b3906dc8ddd89914bba35a58f9274df3b5f..70209b2d12e06a48db2db1361d0060a10add065e 100644 --- a/core/lib/Drupal/Core/Database/StatementPrefetchIterator.php +++ b/core/lib/Drupal/Core/Database/StatementPrefetchIterator.php @@ -5,6 +5,8 @@ use Drupal\Core\Database\Event\StatementExecutionEndEvent; use Drupal\Core\Database\Event\StatementExecutionFailureEvent; use Drupal\Core\Database\Event\StatementExecutionStartEvent; +use Drupal\Core\Database\Statement\FetchAs; +use Drupal\Core\Database\Statement\PdoTrait; /** * An implementation of StatementInterface that prefetches all data. @@ -15,13 +17,21 @@ */ class StatementPrefetchIterator implements \Iterator, StatementInterface { - use StatementIteratorTrait; use FetchModeTrait; + use PdoTrait; + use StatementIteratorTrait; + + /** + * The client database Statement object. + * + * For a \PDO client connection, this will be a \PDOStatement object. + */ + protected ?object $clientStatement; /** * Main data store. * - * The resultset is stored as a \PDO::FETCH_ASSOC array. + * The resultset is stored as a FetchAs::Associative array. */ protected array $data = []; @@ -39,18 +49,27 @@ class StatementPrefetchIterator implements \Iterator, StatementInterface { /** * Holds the default fetch style. + * + * @deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use + * $defaultFetchMode instead. + * + * @see https://www.drupal.org/node/3488338 */ protected int $defaultFetchStyle = \PDO::FETCH_OBJ; + /** + * Holds the default fetch mode. + */ + protected FetchAs $defaultFetchMode = FetchAs::Object; + /** * Holds fetch options. * - * @var string[] + * @var array{'class': class-string, 'constructor_args': array<mixed>, 'column': int} */ protected array $fetchOptions = [ 'class' => 'stdClass', 'constructor_args' => [], - 'object' => NULL, 'column' => 0, ]; @@ -88,12 +107,16 @@ public function getConnectionTarget(): string { * {@inheritdoc} */ public function execute($args = [], $options = []) { + if (isset($options['fetch']) && is_int($options['fetch'])) { + @trigger_error("Passing the 'fetch' key as an integer to \$options in execute() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + } + if (isset($options['fetch'])) { if (is_string($options['fetch'])) { // Default to an object. Note: db fields will be added to the object // before the constructor is run. If you need to assign fields after // the constructor is run. See https://www.drupal.org/node/315092. - $this->setFetchMode(\PDO::FETCH_CLASS, $options['fetch']); + $this->setFetchMode(FetchAs::ClassObject, $options['fetch']); } else { $this->setFetchMode($options['fetch']); @@ -114,8 +137,8 @@ public function execute($args = [], $options = []) { // Prepare and execute the statement. try { - $statement = $this->getStatement($this->queryString, $args); - $return = $statement->execute($args); + $this->clientStatement = $this->getStatement($this->queryString, $args); + $return = $this->clientExecute($args, $options); } catch (\Exception $e) { if (isset($startEvent) && $this->connection->isEventEnabled(StatementExecutionFailureEvent::class)) { @@ -132,16 +155,17 @@ public function execute($args = [], $options = []) { $e->getMessage(), )); } + unset($this->clientStatement); throw $e; } // Fetch all the data from the reply, in order to release any lock as soon // as possible. - $this->data = $statement->fetchAll(\PDO::FETCH_ASSOC); - $this->rowCount = $this->rowCountEnabled ? $statement->rowCount() : NULL; + $this->data = $this->clientFetchAll(FetchAs::Associative); + $this->rowCount = $this->rowCountEnabled ? $this->clientRowCount() : NULL; // Destroy the statement as soon as possible. See the documentation of // \Drupal\sqlite\Driver\Database\sqlite\Statement for an explanation. - unset($statement); + unset($this->clientStatement); $this->markResultsetIterable($return); $this->columnNames = count($this->data) > 0 ? array_keys($this->data[0]) : []; @@ -190,24 +214,27 @@ public function getQueryString() { * {@inheritdoc} */ public function setFetchMode($mode, $a1 = NULL, $a2 = []) { - assert(in_array($mode, $this->supportedFetchModes), 'Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.'); + if (is_int($mode)) { + @trigger_error("Passing the \$mode argument as an integer to setFetchMode() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + $mode = $this->pdoToFetchAs($mode); + } - $this->defaultFetchStyle = $mode; + $this->defaultFetchMode = $mode; + // @todo Remove backwards compatibility statement below in drupal:12.0.0. + // @phpstan-ignore property.deprecated + $this->defaultFetchStyle = $this->fetchAsToPdo($mode); switch ($mode) { - case \PDO::FETCH_CLASS: + case FetchAs::ClassObject: $this->fetchOptions['class'] = $a1; if ($a2) { $this->fetchOptions['constructor_args'] = $a2; } break; - case \PDO::FETCH_COLUMN: + case FetchAs::Column: $this->fetchOptions['column'] = $a1; break; - case \PDO::FETCH_INTO: - $this->fetchOptions['object'] = $a1; - break; } } @@ -228,6 +255,11 @@ public function rowCount() { * {@inheritdoc} */ public function fetch($fetch_style = NULL, $cursor_orientation = \PDO::FETCH_ORI_NEXT, $cursor_offset = NULL) { + if (is_int($fetch_style)) { + @trigger_error("Passing the \$fetch_style argument as an integer to fetch() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + $fetch_style = $this->pdoToFetchAs($fetch_style); + } + $currentKey = $this->getResultsetCurrentRowIndex(); // We can remove the current record from the prefetched data, before @@ -242,14 +274,13 @@ public function fetch($fetch_style = NULL, $cursor_orientation = \PDO::FETCH_ORI // Now, format the next prefetched record according to the required fetch // style. $rowAssoc = $this->data[$currentKey]; - $mode = $fetch_style ?? $this->defaultFetchStyle; + $mode = $fetch_style ?? $this->defaultFetchMode; $row = match($mode) { - \PDO::FETCH_ASSOC => $rowAssoc, - \PDO::FETCH_CLASS, \PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE => $this->assocToClass($rowAssoc, $this->fetchOptions['class'], $this->fetchOptions['constructor_args']), - \PDO::FETCH_COLUMN => $this->assocToColumn($rowAssoc, $this->columnNames, $this->fetchOptions['column']), - \PDO::FETCH_NUM => $this->assocToNum($rowAssoc), - \PDO::FETCH_OBJ => $this->assocToObj($rowAssoc), - default => throw new DatabaseExceptionWrapper('Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.'), + FetchAs::Associative => $rowAssoc, + FetchAs::ClassObject => $this->assocToClass($rowAssoc, $this->fetchOptions['class'], $this->fetchOptions['constructor_args']), + FetchAs::Column => $this->assocToColumn($rowAssoc, $this->columnNames, $this->fetchOptions['column']), + FetchAs::List => $this->assocToNum($rowAssoc), + FetchAs::Object => $this->assocToObj($rowAssoc), }; $this->setResultsetCurrentRow($row); return $row; @@ -270,7 +301,7 @@ public function fetchColumn($index = 0) { * {@inheritdoc} */ public function fetchField($index = 0) { - if ($row = $this->fetch(\PDO::FETCH_ASSOC)) { + if ($row = $this->fetch(FetchAs::Associative)) { return $this->assocToColumn($row, $this->columnNames, $index); } return FALSE; @@ -281,30 +312,32 @@ public function fetchField($index = 0) { */ public function fetchObject(?string $class_name = NULL, array $constructor_arguments = []) { if (!isset($class_name)) { - return $this->fetch(\PDO::FETCH_OBJ); + return $this->fetch(FetchAs::Object); } $this->fetchOptions = [ 'class' => $class_name, 'constructor_args' => $constructor_arguments, ]; - return $this->fetch(\PDO::FETCH_CLASS); + return $this->fetch(FetchAs::ClassObject); } /** * {@inheritdoc} */ public function fetchAssoc() { - return $this->fetch(\PDO::FETCH_ASSOC); + return $this->fetch(FetchAs::Associative); } /** * {@inheritdoc} */ public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) { - $fetchStyle = $mode ?? $this->defaultFetchStyle; - - assert(in_array($fetchStyle, $this->supportedFetchModes), 'Fetch mode ' . ($this->fetchModeLiterals[$fetchStyle] ?? $fetchStyle) . ' is not supported. Use supported modes only.'); + if (is_int($mode)) { + @trigger_error("Passing the \$mode argument as an integer to fetchAll() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + $mode = $this->pdoToFetchAs($mode); + } + $fetchStyle = $mode ?? $this->defaultFetchMode; if (isset($column_index)) { $this->fetchOptions['column'] = $column_index; } @@ -342,7 +375,7 @@ public function fetchAllKeyed($key_index = 0, $value_index = 1) { $value = $this->columnNames[$value_index]; $result = []; - while ($row = $this->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $this->fetch(FetchAs::Associative)) { $result[$row[$key]] = $row[$value]; } return $result; @@ -351,11 +384,14 @@ public function fetchAllKeyed($key_index = 0, $value_index = 1) { /** * {@inheritdoc} */ - public function fetchAllAssoc($key, $fetch_style = NULL) { - $fetchStyle = $fetch_style ?? $this->defaultFetchStyle; + public function fetchAllAssoc($key, $fetch = NULL) { + if (is_int($fetch)) { + @trigger_error("Passing the \$fetch argument as an integer to fetchAllAssoc() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + $fetch = $this->pdoToFetchAs($fetch); + } $result = []; - while ($row = $this->fetch($fetchStyle)) { + while ($row = $this->fetch($fetch ?? $this->defaultFetchMode)) { $result[$this->data[$this->getResultsetCurrentRowIndex()][$key]] = $row; } return $result; diff --git a/core/lib/Drupal/Core/Database/StatementWrapperIterator.php b/core/lib/Drupal/Core/Database/StatementWrapperIterator.php index 980ef74ed2e103575fd361ce00c92baa8f3dc0b5..364cbe05b4159f58b8f191a7b99f9030f40f9cfd 100644 --- a/core/lib/Drupal/Core/Database/StatementWrapperIterator.php +++ b/core/lib/Drupal/Core/Database/StatementWrapperIterator.php @@ -5,6 +5,8 @@ use Drupal\Core\Database\Event\StatementExecutionEndEvent; use Drupal\Core\Database\Event\StatementExecutionFailureEvent; use Drupal\Core\Database\Event\StatementExecutionStartEvent; +use Drupal\Core\Database\Statement\FetchAs; +use Drupal\Core\Database\Statement\PdoTrait; // cSpell:ignore maxlen driverdata INOUT @@ -28,8 +30,9 @@ */ class StatementWrapperIterator implements \Iterator, StatementInterface { - use StatementIteratorTrait; use FetchModeTrait; + use PdoTrait; + use StatementIteratorTrait; /** * The client database Statement object. @@ -38,6 +41,22 @@ class StatementWrapperIterator implements \Iterator, StatementInterface { */ protected object $clientStatement; + /** + * Holds the default fetch mode. + */ + protected FetchAs $defaultFetchMode = FetchAs::Object; + + /** + * Holds fetch options. + * + * @var array{'class': class-string, 'constructor_args': array<mixed>, 'column': int} + */ + protected array $fetchOptions = [ + 'class' => 'stdClass', + 'constructor_args' => [], + 'column' => 0, + ]; + /** * Constructs a StatementWrapperIterator object. * @@ -60,19 +79,7 @@ public function __construct( protected readonly bool $rowCountEnabled = FALSE, ) { $this->clientStatement = $clientConnection->prepare($query, $options); - $this->setFetchMode(\PDO::FETCH_OBJ); - } - - /** - * Returns the client-level database statement object. - * - * This method should normally be used only within database driver code. - * - * @return object - * The client-level database statement, for example \PDOStatement. - */ - public function getClientStatement(): object { - return $this->clientStatement; + $this->setFetchMode(FetchAs::Object); } /** @@ -86,11 +93,13 @@ public function getConnectionTarget(): string { * {@inheritdoc} */ public function execute($args = [], $options = []) { + if (isset($options['fetch']) && is_int($options['fetch'])) { + @trigger_error("Passing the 'fetch' key as an integer to \$options in execute() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + } + if (isset($options['fetch'])) { if (is_string($options['fetch'])) { - // \PDO::FETCH_PROPS_LATE tells __construct() to run before properties - // are added to the object. - $this->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $options['fetch']); + $this->setFetchMode(FetchAs::ClassObject, $options['fetch']); } else { $this->setFetchMode($options['fetch']); @@ -110,7 +119,7 @@ public function execute($args = [], $options = []) { } try { - $return = $this->clientStatement->execute($args); + $return = $this->clientExecute($args, $options); $this->markResultsetIterable($return); } catch (\Exception $e) { @@ -150,23 +159,28 @@ public function execute($args = [], $options = []) { * {@inheritdoc} */ public function getQueryString() { - return $this->clientStatement->queryString; + return $this->clientQueryString(); } /** * {@inheritdoc} */ public function fetchCol($index = 0) { - return $this->fetchAll(\PDO::FETCH_COLUMN, $index); + return $this->fetchAll(FetchAs::Column, $index); } /** * {@inheritdoc} */ public function fetchAllAssoc($key, $fetch = NULL) { + if (is_int($fetch)) { + @trigger_error("Passing the \$fetch argument as an integer to fetchAllAssoc() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + $fetch = $this->pdoToFetchAs($fetch); + } + if (isset($fetch)) { if (is_string($fetch)) { - $this->setFetchMode(\PDO::FETCH_CLASS, $fetch); + $this->setFetchMode(FetchAs::ClassObject, $fetch); } else { $this->setFetchMode($fetch); @@ -193,7 +207,7 @@ public function fetchAllAssoc($key, $fetch = NULL) { * {@inheritdoc} */ public function fetchAllKeyed($key_index = 0, $value_index = 1) { - $this->setFetchMode(\PDO::FETCH_NUM); + $this->setFetchMode(FetchAs::List); // Return early if the statement was already fully traversed. if (!$this->isResultsetIterable) { @@ -213,8 +227,7 @@ public function fetchAllKeyed($key_index = 0, $value_index = 1) { * {@inheritdoc} */ public function fetchField($index = 0) { - // Call \PDOStatement::fetchColumn to fetch the field. - $column = $this->clientStatement->fetchColumn($index); + $column = $this->clientFetchColumn($index); if ($column === FALSE) { $this->markResultsetFetchingComplete(); @@ -229,19 +242,14 @@ public function fetchField($index = 0) { * {@inheritdoc} */ public function fetchAssoc() { - return $this->fetch(\PDO::FETCH_ASSOC); + return $this->fetch(FetchAs::Associative); } /** * {@inheritdoc} */ public function fetchObject(?string $class_name = NULL, array $constructor_arguments = []) { - if ($class_name) { - $row = $this->clientStatement->fetchObject($class_name, $constructor_arguments); - } - else { - $row = $this->clientStatement->fetchObject(); - } + $row = $this->clientFetchObject($class_name, $constructor_arguments); if ($row === FALSE) { $this->markResultsetFetchingComplete(); @@ -258,7 +266,7 @@ public function fetchObject(?string $class_name = NULL, array $constructor_argum public function rowCount() { // SELECT query should not use the method. if ($this->rowCountEnabled) { - return $this->clientStatement->rowCount(); + return $this->clientRowCount(); } else { throw new RowCountException(); @@ -269,32 +277,43 @@ public function rowCount() { * {@inheritdoc} */ public function setFetchMode($mode, $a1 = NULL, $a2 = []) { - assert(in_array($mode, $this->supportedFetchModes), 'Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.'); - - // Call \PDOStatement::setFetchMode to set fetch mode. - // \PDOStatement is picky about the number of arguments in some cases so we - // need to be pass the exact number of arguments we where given. - return match(func_num_args()) { - 1 => $this->clientStatement->setFetchMode($mode), - 2 => $this->clientStatement->setFetchMode($mode, $a1), - default => $this->clientStatement->setFetchMode($mode, $a1, $a2), - }; + if (is_int($mode)) { + @trigger_error("Passing the \$mode argument as an integer to setFetchMode() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + $mode = $this->pdoToFetchAs($mode); + } + + $this->defaultFetchMode = $mode; + switch ($mode) { + case FetchAs::ClassObject: + $this->fetchOptions['class'] = $a1; + if ($a2) { + $this->fetchOptions['constructor_args'] = $a2; + } + break; + + case FetchAs::Column: + $this->fetchOptions['column'] = $a1; + break; + + } + + return $this->clientSetFetchMode($mode, $a1, $a2); } /** * {@inheritdoc} */ public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL) { - assert(!isset($mode) || in_array($mode, $this->supportedFetchModes), 'Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.'); + if (is_int($mode)) { + @trigger_error("Passing the \$mode argument as an integer to fetch() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + $mode = $this->pdoToFetchAs($mode); + } - // Call \PDOStatement::fetchAll to fetch all rows. - // \PDOStatement is picky about the number of arguments in some cases so we - // need to pass the exact number of arguments we were given. $row = match(func_num_args()) { - 0 => $this->clientStatement->fetch(), - 1 => $this->clientStatement->fetch($mode), - 2 => $this->clientStatement->fetch($mode, $cursor_orientation), - default => $this->clientStatement->fetch($mode, $cursor_orientation, $cursor_offset), + 0 => $this->clientFetch(), + 1 => $this->clientFetch($mode), + 2 => $this->clientFetch($mode, $cursor_orientation), + default => $this->clientFetch($mode, $cursor_orientation, $cursor_offset), }; if ($row === FALSE) { @@ -310,17 +329,20 @@ public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = * {@inheritdoc} */ public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) { - assert(!isset($mode) || in_array($mode, $this->supportedFetchModes), 'Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.'); - - // Call \PDOStatement::fetchAll to fetch all rows. - // \PDOStatement is picky about the number of arguments in some cases so we - // need to be pass the exact number of arguments we where given. - $return = match(func_num_args()) { - 0 => $this->clientStatement->fetchAll(), - 1 => $this->clientStatement->fetchAll($mode), - 2 => $this->clientStatement->fetchAll($mode, $column_index), - default => $this->clientStatement->fetchAll($mode, $column_index, $constructor_arguments), - }; + if (is_int($mode)) { + @trigger_error("Passing the \$mode argument as an integer to fetchAll() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + $mode = $this->pdoToFetchAs($mode); + } + + $fetchMode = $mode ?? $this->defaultFetchMode; + if (isset($column_index)) { + $this->fetchOptions['column'] = $column_index; + } + if (isset($constructor_arguments)) { + $this->fetchOptions['constructor_args'] = $constructor_arguments; + } + + $return = $this->clientFetchAll($fetchMode, $column_index, $constructor_arguments); $this->markResultsetFetchingComplete(); diff --git a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php index a3b18a70c3d9e92ba9e45ddd82ec8dbab3a43958..ca9c21a1c1b9d6bf15f596344fb2ce32bb3a0d9a 100644 --- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php +++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php @@ -70,6 +70,7 @@ class DrupalDateTime extends DateTimePlus { * timezone are ignored when the $time parameter either is a UNIX timestamp * (e.g. @946684800) or specifies a timezone * (e.g. 2010-01-28T15:00:00+02:00). + * phpcs:ignore Drupal.Commenting.FunctionComment.ParamCommentFullStop * @see http://php.net/manual/datetime.construct.php * @param array $settings * - validate_format: (optional) Boolean choice to validate the diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/BackwardsCompatibilityClassLoaderPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/BackwardsCompatibilityClassLoaderPass.php new file mode 100644 index 0000000000000000000000000000000000000000..d698b45cde009af8b51949ec8249c72475051054 --- /dev/null +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/BackwardsCompatibilityClassLoaderPass.php @@ -0,0 +1,35 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Core\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +/** + * Defines a compiler pass to merge moved classes into a single container parameter. + */ +class BackwardsCompatibilityClassLoaderPass implements CompilerPassInterface { + + /** + * {@inheritdoc} + */ + public function process(ContainerBuilder $container): void { + $moved_classes = $container->hasParameter('core.moved_classes') ? $container->getParameter('core.moved_classes') : []; + $modules = array_keys($container->getParameter('container.modules')); + foreach ($modules as $module) { + $parameter_name = $module . '.moved_classes'; + if ($container->hasParameter($parameter_name)) { + $module_moved = $container->getParameter($parameter_name); + \assert(is_array($module_moved)); + \assert(count($module_moved) === count(array_column($module_moved, 'class')), 'Missing class key for moved classes in ' . $module); + $moved_classes = $moved_classes + $module_moved; + } + } + if (!empty($moved_classes)) { + $container->setParameter('moved_classes', $moved_classes); + } + } + +} diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index b962ffe589eee5fcf2eea8e290fced302947a5f7..3082c0a6989abeafcc176c8a93766397f8c437b8 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -8,6 +8,7 @@ use Drupal\Component\Serialization\PhpSerialize; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Cache\DatabaseBackend; +use Drupal\Core\ClassLoader\BackwardsCompatibilityClassLoader; use Drupal\Core\Config\BootstrapConfigStorageFactory; use Drupal\Core\Config\NullStorage; use Drupal\Core\DependencyInjection\ContainerBuilder; @@ -513,6 +514,11 @@ public function boot() { $this->classLoader->setApcuPrefix($prefix); } + if ($this->container->hasParameter('moved_classes')) { + $bc_class_loader = new BackwardsCompatibilityClassLoader($this->container->getParameter('moved_classes')); + spl_autoload_register([$bc_class_loader, 'loadClass']); + } + $this->booted = TRUE; return $this; @@ -726,9 +732,9 @@ public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TR * Converts an exception into a response. * * @param \Exception $e - * An exception + * An exception. * @param \Symfony\Component\HttpFoundation\Request $request - * A Request instance + * A Request instance. * @param int $type * The type of the request (one of HttpKernelInterface::MAIN_REQUEST or * HttpKernelInterface::SUB_REQUEST) @@ -1256,7 +1262,7 @@ public function invalidateContainer() { * Attach synthetic values on to kernel. * * @param \Symfony\Component\DependencyInjection\ContainerInterface $container - * Container object + * Container object. * * @return \Symfony\Component\DependencyInjection\ContainerInterface * The container object with the kernel and the class loader added. @@ -1581,7 +1587,7 @@ protected static function validateHostnameLength($host) { * Validates the hostname supplied from the HTTP request. * * @param \Symfony\Component\HttpFoundation\Request $request - * The request object + * The request object. * * @return bool * TRUE if the hostname is valid, or FALSE otherwise. diff --git a/core/lib/Drupal/Core/Entity/Controller/EntityController.php b/core/lib/Drupal/Core/Entity/Controller/EntityController.php index 8240d9a5f8b0bc6e637724aaf15ca00a98a901c6..9a873730466d0ae4b5f80220a72fe3ad6b3991d7 100644 --- a/core/lib/Drupal/Core/Entity/Controller/EntityController.php +++ b/core/lib/Drupal/Core/Entity/Controller/EntityController.php @@ -297,9 +297,8 @@ public function editTitle(RouteMatchInterface $route_match, ?EntityInterface $_e * The title for the entity delete page. */ public function deleteTitle(RouteMatchInterface $route_match, ?EntityInterface $_entity = NULL) { - if ($entity = $this->doGetEntity($route_match, $_entity)) { - return $this->t('Delete %label', ['%label' => $entity->label()]); - } + $entity = $this->doGetEntity($route_match, $_entity); + return $entity ? $this->t('Delete %label', ['%label' => $entity->label()]) : ''; } /** diff --git a/core/lib/Drupal/Core/Entity/EntityFieldManager.php b/core/lib/Drupal/Core/Entity/EntityFieldManager.php index 6bab070150eb622baad73d9b6753b60ff4d153f5..29d96b24bc5468e1efe3ef00cc66aeff5b833aa1 100644 --- a/core/lib/Drupal/Core/Entity/EntityFieldManager.php +++ b/core/lib/Drupal/Core/Entity/EntityFieldManager.php @@ -577,7 +577,7 @@ public function getFieldMapByFieldType($field_type) { * * @param string $entity_type_id * The entity type ID. Only entity types that implement - * \Drupal\Core\Entity\FieldableEntityInterface are supported + * \Drupal\Core\Entity\FieldableEntityInterface are supported. * * @return \Drupal\Core\Field\FieldStorageDefinitionInterface[] * An array of field storage definitions, keyed by field name. diff --git a/core/lib/Drupal/Core/Entity/EntityTypeManager.php b/core/lib/Drupal/Core/Entity/EntityTypeManager.php index 0a6c80f5cc5613584b155b96a57c125d28f12b57..a34437d246b0e1b9e208465d789f99702ee774c3 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeManager.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeManager.php @@ -68,7 +68,7 @@ class EntityTypeManager extends DefaultPluginManager implements EntityTypeManage * * @param \Traversable $namespaces * An object that implements \Traversable which contains the root paths - * keyed by the corresponding namespace to look for plugin implementations, + * keyed by the corresponding namespace to look for plugin implementations. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\Core\Cache\CacheBackendInterface $cache diff --git a/core/lib/Drupal/Core/Entity/Query/QueryBase.php b/core/lib/Drupal/Core/Entity/Query/QueryBase.php index 02d5c665a29ee9ecdaaaffca5e7e61bbba881706..4cf908ce5e24e5def0c93a975fba8298551c84e7 100644 --- a/core/lib/Drupal/Core/Entity/Query/QueryBase.php +++ b/core/lib/Drupal/Core/Entity/Query/QueryBase.php @@ -498,7 +498,7 @@ public static function getNamespaces($object) { * @param string $short_class_name * A class name without namespace. * - * @return string + * @return string|null * The fully qualified name of the class. */ public static function getClass(array $namespaces, $short_class_name) { @@ -508,6 +508,7 @@ public static function getClass(array $namespaces, $short_class_name) { return $class; } } + return NULL; } /** diff --git a/core/lib/Drupal/Core/Entity/Routing/EntityRouteProviderInterface.php b/core/lib/Drupal/Core/Entity/Routing/EntityRouteProviderInterface.php index 706994aa880e25b6ef90c7eeba6d0101e3a2b2b0..5b91c351d31afbec9d69c1e60c01c45d45bfea54 100644 --- a/core/lib/Drupal/Core/Entity/Routing/EntityRouteProviderInterface.php +++ b/core/lib/Drupal/Core/Entity/Routing/EntityRouteProviderInterface.php @@ -13,7 +13,7 @@ interface EntityRouteProviderInterface { * Provides routes for entities. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type + * The entity type. * * @return \Symfony\Component\Routing\RouteCollection|\Symfony\Component\Routing\Route[] * Returns a route collection or an array of routes keyed by name, like diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index eeb714f6ad48434d5e2e25043a177c4ab103b8d3..78d6061100f66644fa3da068dad6b566f4bfb79f 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -7,6 +7,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Database\SchemaException; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\ContentEntityStorageBase; use Drupal\Core\Entity\ContentEntityTypeInterface; @@ -530,7 +531,7 @@ protected function loadFromSharedTables(array &$values, array &$translations, $l // latest revision. Otherwise we fall back to the data table. $table = $this->revisionDataTable ?: $this->dataTable; $alias = $this->revisionDataTable ? 'revision' : 'data'; - $query = $this->database->select($table, $alias, ['fetch' => \PDO::FETCH_ASSOC]) + $query = $this->database->select($table, $alias, ['fetch' => FetchAs::Associative]) ->fields($alias) ->condition($alias . '.' . $record_key, array_keys($values), 'IN') ->orderBy($alias . '.' . $record_key); @@ -1641,7 +1642,7 @@ protected function readFieldItemsToPurge(FieldDefinitionInterface $field_definit $table_name = $table_mapping->getDedicatedDataTableName($storage_definition, $storage_definition->isDeleted()); // Get the entities which we want to purge first. - $entity_query = $this->database->select($table_name, 't', ['fetch' => \PDO::FETCH_ASSOC]); + $entity_query = $this->database->select($table_name, 't', ['fetch' => FetchAs::Associative]); $or = $entity_query->orConditionGroup(); foreach ($storage_definition->getColumns() as $column_name => $data) { $or->isNotNull($table_mapping->getFieldColumnName($storage_definition, $column_name)); @@ -1661,7 +1662,7 @@ protected function readFieldItemsToPurge(FieldDefinitionInterface $field_definit $entities = []; $items_by_entity = []; foreach ($entity_query->execute() as $row) { - $item_query = $this->database->select($table_name, 't', ['fetch' => \PDO::FETCH_ASSOC]) + $item_query = $this->database->select($table_name, 't', ['fetch' => FetchAs::Associative]) ->fields('t') ->condition('entity_id', $row['entity_id']) ->condition('deleted', 1) diff --git a/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php index f70c566342c5909a974fc13af73057e21ecd49c3..04b3ead1bb7f72548945d5347c991ba046f25746 100644 --- a/core/lib/Drupal/Core/Entity/entity.api.php +++ b/core/lib/Drupal/Core/Entity/entity.api.php @@ -686,9 +686,9 @@ * The entity to check access to. * @param string $operation * The operation that is to be performed on $entity. Usually one of: - * - "view" - * - "update" - * - "delete" + * - "view". + * - "update". + * - "delete". * @param \Drupal\Core\Session\AccountInterface $account * The account trying to access the entity. * @@ -727,7 +727,7 @@ function hook_entity_access(\Drupal\Core\Entity\EntityInterface $entity, $operat * The operation that is to be performed on $entity. Usually one of: * - "view" * - "update" - * - "delete" + * - "delete". * @param \Drupal\Core\Session\AccountInterface $account * The account trying to access the entity. * diff --git a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php index f15512a558c3163dfbd5f0fb9229f53aa2010b7e..fac11c88176d293fa1fcaa4aea89bb7d6ea02ff0 100644 --- a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php +++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php @@ -115,7 +115,7 @@ class ExtensionDiscovery { * determines if the deprecated file cache property is set to maintain BC in * Drupal 11. * @param string[] $profile_directories - * The available profile directories + * The available profile directories. * @param string $site_path * The path to the site. */ diff --git a/core/lib/Drupal/Core/File/FileSystemInterface.php b/core/lib/Drupal/Core/File/FileSystemInterface.php index 9aefe00ba88c93f8c8d29e328c3d243ad51760b2..f3beabfe22093d74e1329d02ddb49fdfb3148d4a 100644 --- a/core/lib/Drupal/Core/File/FileSystemInterface.php +++ b/core/lib/Drupal/Core/File/FileSystemInterface.php @@ -121,7 +121,7 @@ public function chmod($uri, $mode = NULL); * @param string $uri * A URI or pathname. * @param resource $context - * Refer to http://php.net/manual/ref.stream.php + * Refer to http://php.net/manual/ref.stream.php. * * @return bool * Boolean TRUE on success, or FALSE on failure. @@ -204,7 +204,7 @@ public function basename($uri, $suffix = NULL); * Create directories recursively, defaults to FALSE. Cannot work with a * mode which denies writing or execution to the owner of the process. * @param resource $context - * Refer to http://php.net/manual/ref.stream.php + * Refer to http://php.net/manual/ref.stream.php. * * @return bool * Boolean TRUE on success, or FALSE on failure. @@ -227,7 +227,7 @@ public function mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL); * @param string $uri * A URI or pathname. * @param resource $context - * Refer to http://php.net/manual/ref.stream.php + * Refer to http://php.net/manual/ref.stream.php. * * @return bool * Boolean TRUE on success, or FALSE on failure. diff --git a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php index 0a9ee284c472d53fdedb415fddd5f77420841746..548f1159673de737cc10d615b1bec8debfd1cafe 100644 --- a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php +++ b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php @@ -381,7 +381,7 @@ abstract protected function removeFileJailed($destination); * Checks if a particular path is a directory. * * @param string $path - * The path to check + * The path to check. * * @return bool * TRUE if the specified path is a directory, FALSE otherwise. diff --git a/core/lib/Drupal/Core/Form/EnforcedResponseException.php b/core/lib/Drupal/Core/Form/EnforcedResponseException.php index b94722ebc483c9ce488877b86bbdbbbad9603539..5f300ec50a5d6c8c0e366dc5b313341947fa1feb 100644 --- a/core/lib/Drupal/Core/Form/EnforcedResponseException.php +++ b/core/lib/Drupal/Core/Form/EnforcedResponseException.php @@ -26,7 +26,7 @@ class EnforcedResponseException extends \Exception { * @param int $code * (optional) A user defined exception code. * @param \Throwable $previous - * (optional) The previous exception for nested exceptions + * (optional) The previous exception for nested exceptions. */ public function __construct(Response $response, $message = "", $code = 0, ?\Throwable $previous = NULL) { parent::__construct($message, $code, $previous); diff --git a/core/lib/Drupal/Core/Form/FormStateInterface.php b/core/lib/Drupal/Core/Form/FormStateInterface.php index f4a9e114e38310f7466df616e2fb96efdab6f469..028d1558bc46061b2391ed59a44fbc0532800a6c 100644 --- a/core/lib/Drupal/Core/Form/FormStateInterface.php +++ b/core/lib/Drupal/Core/Form/FormStateInterface.php @@ -117,7 +117,7 @@ public function getResponse(); * Sets the redirect for the form. * * @param string $route_name - * The name of the route + * The name of the route. * @param array $route_parameters * (optional) An associative array of parameter names and values. * @param array $options diff --git a/core/lib/Drupal/Core/Http/HandlerStackConfigurator.php b/core/lib/Drupal/Core/Http/HandlerStackConfigurator.php index 79ba7748432c94c94728cd858d6ebad0ee988031..f1e4e42d0a2923859c1f2f9bb3d5cd3e6a9daa78 100644 --- a/core/lib/Drupal/Core/Http/HandlerStackConfigurator.php +++ b/core/lib/Drupal/Core/Http/HandlerStackConfigurator.php @@ -77,7 +77,7 @@ protected function initializeMiddlewares() { * Configures the stack using services tagged as http_client_middleware. * * @param \GuzzleHttp\HandlerStack $handler_stack - * The handler stack + * The handler stack. */ public function configure(HandlerStack $handler_stack) { $this->initializeMiddlewares(); diff --git a/core/lib/Drupal/Core/Link.php b/core/lib/Drupal/Core/Link.php index 2b97938d5ecfedca0b5771068fe121b03ee19b7b..6d3c65831c1cfa37bf4f391c4c5978ef9a1b78c1 100644 --- a/core/lib/Drupal/Core/Link.php +++ b/core/lib/Drupal/Core/Link.php @@ -63,7 +63,7 @@ public function __construct($text, Url $url) { * the output of \Drupal\Component\Utility\Xss::filter() or * \Drupal\Component\Render\FormattableMarkup. * @param string $route_name - * The name of the route + * The name of the route. * @param array $route_parameters * (optional) An associative array of parameter names and values. * @param array $options @@ -139,7 +139,7 @@ public function getUrl() { * Sets the URL of this link. * * @param Url $url - * The URL object to set + * The URL object to set. * * @return $this */ diff --git a/core/lib/Drupal/Core/Mail/MailManager.php b/core/lib/Drupal/Core/Mail/MailManager.php index 5e3a3ecc5f6242b4819bd5c920ea13d69c7ec808..be95a6d2b2f22e349eb1634e387c35889c494626 100644 --- a/core/lib/Drupal/Core/Mail/MailManager.php +++ b/core/lib/Drupal/Core/Mail/MailManager.php @@ -197,10 +197,10 @@ public function mail($module, $key, $to, $langcode, $params = [], $reply = NULL, * formatting of this string will be validated with the * @link http://php.net/manual/filter.filters.validate.php PHP email validation filter. @endlink * Some examples are: - * - user@example.com - * - user@example.com, anotheruser@example.com - * - User <user@example.com> - * - User <user@example.com>, Another User <anotheruser@example.com> + * - "user@example.com". + * - "user@example.com, anotheruser@example.com" + * - "User <user@example.com>". + * - "User <user@example.com>, Another User <anotheruser@example.com>". * @param string $langcode * Language code to use to compose the email. * @param array $params diff --git a/core/lib/Drupal/Core/Mail/MailManagerInterface.php b/core/lib/Drupal/Core/Mail/MailManagerInterface.php index bfdd291d8043b3c59c7e6c525a888db3c390c578..65ce14802bb5df73dd025f0442ad3c4e35589f64 100644 --- a/core/lib/Drupal/Core/Mail/MailManagerInterface.php +++ b/core/lib/Drupal/Core/Mail/MailManagerInterface.php @@ -95,10 +95,10 @@ interface MailManagerInterface extends PluginManagerInterface { * formatting of this string will be validated with the * @link http://php.net/manual/filter.filters.validate.php PHP email validation filter. @endlink * Some examples are: - * - user@example.com - * - user@example.com, anotheruser@example.com - * - User <user@example.com> - * - User <user@example.com>, Another User <anotheruser@example.com> + * - "user@example.com". + * - "user@example.com, anotheruser@example.com". + * - "User <user@example.com>". + * - "User <user@example.com>, Another User <anotheruser@example.com>". * @param string $langcode * Language code to use to compose the email. * @param array $params diff --git a/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php b/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php index 66341b3c3aa6cfeeb182b63cba79f884fe4f37aa..86581d857e446339574d4dc8d2ceff33e86988d6 100644 --- a/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php +++ b/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php @@ -60,7 +60,7 @@ class MenuLinkDefaultForm implements MenuLinkFormInterface, ContainerInjectionIn * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * The string translation. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler; + * The module handler. * @param \Drupal\Core\Extension\ModuleExtensionList|null $moduleExtensionList * The module extension list. */ diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index 2dc2fd53c6f1def085a5a528d97f0c94c2cc2783..fb5d75a9c2dd46bcaee7f349babd786f2143bd6b 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -10,6 +10,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Database\DatabaseException; use Drupal\Core\Database\Query\SelectInterface; +use Drupal\Core\Database\Statement\FetchAs; // cspell:ignore mlid @@ -642,7 +643,7 @@ public function loadByProperties(array $properties) { } $query->condition($name, $value); } - $loaded = $this->safeExecuteSelect($query)->fetchAllAssoc('id', \PDO::FETCH_ASSOC); + $loaded = $this->safeExecuteSelect($query)->fetchAllAssoc('id', FetchAs::Associative); foreach ($loaded as $id => $link) { $loaded[$id] = $this->prepareLink($link); } @@ -671,7 +672,7 @@ public function loadByRoute($route_name, array $route_parameters = [], $menu_nam $query->orderBy('depth'); $query->orderBy('weight'); $query->orderBy('id'); - $loaded = $this->safeExecuteSelect($query)->fetchAllAssoc('id', \PDO::FETCH_ASSOC); + $loaded = $this->safeExecuteSelect($query)->fetchAllAssoc('id', FetchAs::Associative); foreach ($loaded as $id => $link) { $loaded[$id] = $this->prepareLink($link); } @@ -688,7 +689,7 @@ public function loadMultiple(array $ids) { $query = $this->connection->select($this->table, NULL, $this->options); $query->fields($this->table, $this->definitionFields()); $query->condition('id', $missing_ids, 'IN'); - $loaded = $this->safeExecuteSelect($query)->fetchAllAssoc('id', \PDO::FETCH_ASSOC); + $loaded = $this->safeExecuteSelect($query)->fetchAllAssoc('id', FetchAs::Associative); foreach ($loaded as $id => $link) { $this->definitions[$id] = $this->prepareLink($link); } @@ -734,7 +735,7 @@ protected function loadFullMultiple(array $ids) { $query = $this->connection->select($this->table, NULL, $this->options); $query->fields($this->table); $query->condition('id', $ids, 'IN'); - $loaded = $this->safeExecuteSelect($query)->fetchAllAssoc('id', \PDO::FETCH_ASSOC); + $loaded = $this->safeExecuteSelect($query)->fetchAllAssoc('id', FetchAs::Associative); foreach ($loaded as &$link) { foreach ($this->serializedFields() as $name) { if (isset($link[$name])) { @@ -755,7 +756,7 @@ public function getRootPathIds($id) { // https://www.drupal.org/node/2302043 $subquery->fields($this->table, ['p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9']); $subquery->condition('id', $id); - $result = current($subquery->execute()->fetchAll(\PDO::FETCH_ASSOC)); + $result = current($subquery->execute()->fetchAll(FetchAs::Associative)); $ids = array_filter($result); if ($ids) { $query = $this->connection->select($this->table, NULL, $this->options); @@ -942,7 +943,7 @@ protected function loadLinks($menu_name, MenuTreeParameters $parameters) { } } - $links = $this->safeExecuteSelect($query)->fetchAllAssoc('id', \PDO::FETCH_ASSOC); + $links = $this->safeExecuteSelect($query)->fetchAllAssoc('id', FetchAs::Associative); return $links; } diff --git a/core/lib/Drupal/Core/Menu/StaticMenuLinkOverridesInterface.php b/core/lib/Drupal/Core/Menu/StaticMenuLinkOverridesInterface.php index e587d87879e120599efda528e11deaf16f32ecee..82ce8236a3767b68bc62a074f3cfdef56e12db63 100644 --- a/core/lib/Drupal/Core/Menu/StaticMenuLinkOverridesInterface.php +++ b/core/lib/Drupal/Core/Menu/StaticMenuLinkOverridesInterface.php @@ -68,11 +68,11 @@ public function loadMultipleOverrides(array $ids); * A menu link plugin ID. * @param array $definition * The definition values to override. Supported keys: - * - menu_name - * - parent - * - weight - * - expanded - * - enabled + * - "menu_name". + * - "parent". + * - "weight". + * - "expanded". + * - "enabled". * * @return array * A list of properties which got saved. diff --git a/core/lib/Drupal/Core/Messenger/MessengerInterface.php b/core/lib/Drupal/Core/Messenger/MessengerInterface.php index 0d5e63ac95f072275b9bc41322ff84fcf0fc1662..2742521516781fab2d864c8d06f9c46a242d3c51 100644 --- a/core/lib/Drupal/Core/Messenger/MessengerInterface.php +++ b/core/lib/Drupal/Core/Messenger/MessengerInterface.php @@ -30,9 +30,9 @@ interface MessengerInterface { * The messages will be displayed in the order they got added later. * * @param string|\Drupal\Component\Render\MarkupInterface $message - * (optional) The translated message to be displayed to the user. For - * consistency with other messages, it should begin with a capital letter - * and end with a period. + * The translated message to be displayed to the user. For consistency with + * other messages, it should begin with a capital letter and end with a + * period. * @param string $type * (optional) The message's type. Either self::TYPE_STATUS, * self::TYPE_WARNING, or self::TYPE_ERROR. @@ -48,9 +48,9 @@ public function addMessage($message, $type = self::TYPE_STATUS, $repeat = FALSE) * Adds a new status message to the queue. * * @param string|\Drupal\Component\Render\MarkupInterface $message - * (optional) The translated message to be displayed to the user. For - * consistency with other messages, it should begin with a capital letter - * and end with a period. + * The translated message to be displayed to the user. For consistency with + * other messages, it should begin with a capital letter and end with a + * period. * @param bool $repeat * (optional) If this is FALSE and the message is already set, then the * message won't be repeated. Defaults to FALSE. @@ -63,9 +63,9 @@ public function addStatus($message, $repeat = FALSE); * Adds a new error message to the queue. * * @param string|\Drupal\Component\Render\MarkupInterface $message - * (optional) The translated message to be displayed to the user. For - * consistency with other messages, it should begin with a capital letter - * and end with a period. + * The translated message to be displayed to the user. For consistency with + * other messages, it should begin with a capital letter and end with a + * period. * @param bool $repeat * (optional) If this is FALSE and the message is already set, then the * message won't be repeated. Defaults to FALSE. @@ -78,9 +78,9 @@ public function addError($message, $repeat = FALSE); * Adds a new warning message to the queue. * * @param string|\Drupal\Component\Render\MarkupInterface $message - * (optional) The translated message to be displayed to the user. For - * consistency with other messages, it should begin with a capital letter - * and end with a period. + * The translated message to be displayed to the user. For consistency with + * other messages, it should begin with a capital letter and end with a + * period. * @param bool $repeat * (optional) If this is FALSE and the message is already set, then the * message won't be repeated. Defaults to FALSE. diff --git a/core/lib/Drupal/Core/Path/PathValidator.php b/core/lib/Drupal/Core/Path/PathValidator.php index 99b44a58e958c2cceecb7971bb0bb7da7c4fbfe7..ee18e53b20eb093ffbd1c3ff4fac06ab2705c904 100644 --- a/core/lib/Drupal/Core/Path/PathValidator.php +++ b/core/lib/Drupal/Core/Path/PathValidator.php @@ -60,7 +60,7 @@ class PathValidator implements PathValidatorInterface { * @param \Drupal\Core\Session\AccountInterface $account * The current user. * @param \Drupal\Core\PathProcessor\InboundPathProcessorInterface $path_processor - * The path processor; + * The path processor. */ public function __construct(AccessAwareRouterInterface $access_aware_router, UrlMatcherInterface $access_unaware_router, AccountInterface $account, InboundPathProcessorInterface $path_processor) { $this->accessAwareRouter = $access_aware_router; diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php index b33fc071a80b424572d5d25b4e3397c152c6b8e5..08e9fb072d5ab75ce73a89b7433220fcaf618ebb 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -355,7 +355,7 @@ protected function findDefinitions() { * * @param mixed $plugin_definition * The plugin definition. Usually either an array or an instance of - * \Drupal\Component\Plugin\Definition\PluginDefinitionInterface + * \Drupal\Component\Plugin\Definition\PluginDefinitionInterface. * * @return string|null * The provider string, if it exists. NULL otherwise. diff --git a/core/lib/Drupal/Core/Render/Element/Button.php b/core/lib/Drupal/Core/Render/Element/Button.php index 0aefec8dd7ec69860c628607977c830f25a057b5..a8f12e93963690cbcf909789678489de57420cc7 100644 --- a/core/lib/Drupal/Core/Render/Element/Button.php +++ b/core/lib/Drupal/Core/Render/Element/Button.php @@ -9,14 +9,21 @@ /** * Provides an action button form element. * - * When the button is pressed, the form will be submitted to Drupal, where it is - * validated and rebuilt. The submit handler is not invoked. + * When the button is pressed: + * - If #submit_button is TRUE (default), the form will be submitted to Drupal, + * where it is validated and rebuilt. The submit handler is not invoked. + * - If #submit_button is FALSE, the button will act as a regular HTML button + * (with the 'type' attribute set to 'button') and will not trigger a form + * submission. This allows developers to define custom client-side behavior + * using JavaScript or other mechanisms. * * Properties: * - #limit_validation_errors: An array of form element keys that will block * form submission when validation for these elements or any child elements * fails. Specify an empty array to suppress all form validation errors. * - #value: The text to be shown on the button. + * - #submit_button: This has a default value of TRUE. If set to FALSE, the + * 'type' attribute is set to 'button.' * * * Usage Example: @@ -40,6 +47,7 @@ public function getInfo() { '#input' => TRUE, '#name' => 'op', '#is_button' => TRUE, + '#submit_button' => TRUE, '#executes_submit_callback' => FALSE, '#limit_validation_errors' => FALSE, '#process' => [ @@ -71,15 +79,21 @@ public static function processButton(&$element, FormStateInterface $form_state, * * @param array $element * An associative array containing the properties of the element. - * Properties used: #attributes, #button_type, #name, #value. The - * #button_type property accepts any value, though core themes have CSS that - * styles the following button_types appropriately: 'primary', 'danger'. + * Properties used: #attributes, #button_type, #name, #submit_button, + * #value. The #button_type property accepts any value, though core themes + * have CSS that styles the following button_types appropriately: + * 'primary', 'danger'. * * @return array * The $element with prepared variables ready for input.html.twig. */ public static function preRenderButton($element) { - $element['#attributes']['type'] = 'submit'; + if ($element['#submit_button']) { + $element['#attributes']['type'] = 'submit'; + } + else { + $element['#attributes']['type'] = 'button'; + } Element::setAttributes($element, ['id', 'name', 'value']); $element['#attributes']['class'][] = 'button'; diff --git a/core/lib/Drupal/Core/Render/Element/FormElementBase.php b/core/lib/Drupal/Core/Render/Element/FormElementBase.php index 7ca6ba2c8e3fd6d59a0e9269c2841185b5e21515..65d3793110c08d4081d930120d175502b7fab34a 100644 --- a/core/lib/Drupal/Core/Render/Element/FormElementBase.php +++ b/core/lib/Drupal/Core/Render/Element/FormElementBase.php @@ -178,7 +178,7 @@ public static function validatePattern(&$element, FormStateInterface $form_state * - #autocomplete_route_parameters: The parameters to be used in * conjunction with the route name. * - #autocomplete_query_parameters: The parameters to be used in - * query string + * query string. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * @param array $complete_form diff --git a/core/lib/Drupal/Core/Render/Element/RenderElementBase.php b/core/lib/Drupal/Core/Render/Element/RenderElementBase.php index 7981e30c0c42b478bb2a430e0d4edeb2d471fb7d..d60da389f237aacd886707457e1b6a9635b31716 100644 --- a/core/lib/Drupal/Core/Render/Element/RenderElementBase.php +++ b/core/lib/Drupal/Core/Render/Element/RenderElementBase.php @@ -241,16 +241,16 @@ public static function processAjaxForm(&$element, FormStateInterface $form_state * @param array $element * An associative array containing the properties of the element. * Properties used: - * - #ajax['event'] - * - #ajax['prevent'] - * - #ajax['url'] - * - #ajax['httpMethod'] - * - #ajax['callback'] - * - #ajax['options'] - * - #ajax['wrapper'] - * - #ajax['parameters'] - * - #ajax['effect'] - * - #ajax['accepts'] + * - "#ajax['event']". + * - "#ajax['prevent']". + * - "#ajax['url']". + * - "#ajax['httpMethod']". + * - "#ajax['callback']". + * - "#ajax['options']". + * - "#ajax['wrapper']". + * - "#ajax['parameters']". + * - "#ajax['effect']". + * - "#ajax['accepts']". * * @return array * The processed element with the necessary JavaScript attached to it. diff --git a/core/lib/Drupal/Core/Render/Element/StatusMessages.php b/core/lib/Drupal/Core/Render/Element/StatusMessages.php index f0b9e25c9874391a4a62930f1b5e1be0475c7b34..23048ef3dfd5607893c6d9116de2a99de4acf4da 100644 --- a/core/lib/Drupal/Core/Render/Element/StatusMessages.php +++ b/core/lib/Drupal/Core/Render/Element/StatusMessages.php @@ -75,10 +75,10 @@ public static function generatePlaceholder(array $element) { * Limit the messages returned by type. Defaults to NULL, meaning all types. * Passed on to \Drupal\Core\Messenger\Messenger::deleteByType(). These * values are supported: - * - NULL - * - 'status' - * - 'warning' - * - 'error' + * - NULL. + * - 'status'. + * - 'warning'. + * - 'error'. * * @return array * A renderable array containing the messages. diff --git a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php index 6ac379012c68c9a79fb8bff075757bfba94b5583..4e0ccfadc31601d876169cce9fb632bcceade926 100644 --- a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php +++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php @@ -328,7 +328,7 @@ protected function renderHtmlResponseAttachmentPlaceholders(HtmlResponse $respon * - The header value. * - (optional) Whether to replace a current value with the new one, or add * it to the others. If the value is not replaced, it will be appended, - * resulting in a header like this: 'Header: value1,value2' + * resulting in a header like this: 'Header: value1,value2'. */ protected function setHeaders(HtmlResponse $response, array $headers) { foreach ($headers as $values) { diff --git a/core/lib/Drupal/Core/Routing/CompiledRoute.php b/core/lib/Drupal/Core/Routing/CompiledRoute.php index 6b5306414e6bfccf9bf7dde280ebf6660ca78fc0..57cfb2f51c180a6f0582c10c10b63e04799e2e9a 100644 --- a/core/lib/Drupal/Core/Routing/CompiledRoute.php +++ b/core/lib/Drupal/Core/Routing/CompiledRoute.php @@ -45,19 +45,19 @@ class CompiledRoute extends SymfonyCompiledRoute { * @param int $num_parts * The number of parts in the path. * @param string $staticPrefix - * The static prefix of the compiled route + * The static prefix of the compiled route. * @param string $regex - * The regular expression to use to match this route + * The regular expression to use to match this route. * @param array $tokens - * An array of tokens to use to generate URL for this route + * An array of tokens to use to generate URL for this route. * @param array $pathVariables - * An array of path variables + * An array of path variables. * @param string|null $hostRegex - * Host regex + * Host regex. * @param array $hostTokens - * Host tokens + * Host tokens. * @param array $hostVariables - * An array of host variables + * An array of host variables. * @param array $variables * An array of variables (variables defined in the path and in the host * patterns) diff --git a/core/lib/Drupal/Core/Routing/LazyRouteCollection.php b/core/lib/Drupal/Core/Routing/LazyRouteCollection.php index cf5e80874df34f7f3281099bfa3aa85d7db7629d..d795d3162b9d223a779a9b7088667dfa1acf476d 100644 --- a/core/lib/Drupal/Core/Routing/LazyRouteCollection.php +++ b/core/lib/Drupal/Core/Routing/LazyRouteCollection.php @@ -52,7 +52,7 @@ public function all(): array { * Gets a route by name. * * @param string $name - * The route name + * The route name. * * @return \Symfony\Component\Routing\Route|null * A Route instance or null when not found diff --git a/core/lib/Drupal/Core/Routing/RouteProvider.php b/core/lib/Drupal/Core/Routing/RouteProvider.php index ef456eca5195824c211126330af9c4d2efe7a620..ab06f6ea274de085ab4b5e386bb4bfaaed5d3bdd 100644 --- a/core/lib/Drupal/Core/Routing/RouteProvider.php +++ b/core/lib/Drupal/Core/Routing/RouteProvider.php @@ -5,6 +5,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheTagsInvalidatorInterface; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Path\CurrentPathStack; @@ -123,7 +124,7 @@ class RouteProvider implements CacheableRouteProviderInterface, PreloadableRoute * The cache tag invalidator. * @param string $table * (Optional) The table in the database to use for matching. Defaults to - * 'router' + * 'router'. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * (Optional) The language manager. */ @@ -199,7 +200,7 @@ public function getRouteCollectionForRequest(Request $request) { * Find the route using the provided route name. * * @param string $name - * The route name to fetch + * The route name to fetch. * * @return \Symfony\Component\Routing\Route * The found route. @@ -383,7 +384,7 @@ protected function getRoutesByPath($path) { ':patterns[]' => $ancestors, ':count_parts' => count($parts), ]) - ->fetchAll(\PDO::FETCH_ASSOC); + ->fetchAll(FetchAs::Associative); } catch (\Exception) { $routes = []; diff --git a/core/lib/Drupal/Core/Routing/RouteProviderInterface.php b/core/lib/Drupal/Core/Routing/RouteProviderInterface.php index 197ae5737bf45993bc323b775b61a2b6ed264789..30cea25af86f00c90f7ac917c7459d8bfba5ebcf 100644 --- a/core/lib/Drupal/Core/Routing/RouteProviderInterface.php +++ b/core/lib/Drupal/Core/Routing/RouteProviderInterface.php @@ -27,7 +27,7 @@ interface RouteProviderInterface { * may then be filtered in memory more completely. * * @param \Symfony\Component\HttpFoundation\Request $request - * A request against which to match + * A request against which to match. * * @return \Symfony\Component\Routing\RouteCollection * All Routes that could potentially match $request. @@ -39,7 +39,7 @@ public function getRouteCollectionForRequest(Request $request); * Find the route using the provided route name. * * @param string $name - * The route name to fetch + * The route name to fetch. * * @return \Symfony\Component\Routing\Route * The Symfony route object. @@ -67,7 +67,7 @@ public function getRouteByName($name); * * @param array|null $names * The list of names to retrieve, In case of null, the provider will - * determine what routes to return + * determine what routes to return. * * @return \Symfony\Component\Routing\Route|\Symfony\Component\Routing\Alias[] * Iterable list with the keys being the names from the $names array diff --git a/core/lib/Drupal/Core/Routing/Router.php b/core/lib/Drupal/Core/Routing/Router.php index 69d308846296682b8a4d86b88777461bb25cb6f2..91ff280e91172081e3822b8f2a70a1d10bf62614 100644 --- a/core/lib/Drupal/Core/Routing/Router.php +++ b/core/lib/Drupal/Core/Routing/Router.php @@ -151,7 +151,7 @@ protected function matchCollection($pathinfo, RouteCollection $routes): array { * RouteProvider::getRoutesByPath(). * * @param string $pathinfo - * The path info to be parsed + * The path info to be parsed. * @param \Symfony\Component\Routing\RouteCollection $routes * The set of routes. * @param bool $case_sensitive diff --git a/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php b/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php index 37054a6aa0f9c136b426466e4fe3a14cbdc469be..5ff1e6f24fcc2f028d58da0d49e13c3354afec32 100644 --- a/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php +++ b/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php @@ -29,7 +29,7 @@ class NegotiationMiddleware implements HttpKernelInterface { * Constructs a new NegotiationMiddleware. * * @param \Symfony\Component\HttpKernel\HttpKernelInterface $app - * The wrapper HTTP kernel + * The wrapper HTTP kernel. */ public function __construct(HttpKernelInterface $app) { $this->app = $app; diff --git a/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php b/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php index be5c9ebdc217f36f0aa207b3a3df30fb70683f04..04c858216fc8ff6118343ac4612572595f46839a 100644 --- a/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php +++ b/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php @@ -21,7 +21,7 @@ class StaticTranslation implements TranslatorInterface { * Constructs a translator from an array of translations. * * @param array $translations - * Array of override strings indexed by language and context + * Array of override strings indexed by language and context. */ public function __construct($translations = []) { $this->translations = $translations; diff --git a/core/lib/Drupal/Core/Template/AttributeValueBase.php b/core/lib/Drupal/Core/Template/AttributeValueBase.php index 3dfdf4cf4d7a820a3c5eada8ef557088eb954bae..35ef176b14563962dd07799ace6fc2943da58ed8 100644 --- a/core/lib/Drupal/Core/Template/AttributeValueBase.php +++ b/core/lib/Drupal/Core/Template/AttributeValueBase.php @@ -46,7 +46,7 @@ public function __construct($name, $value) { * While __toString only returns the value in a string form, render() * contains the name of the attribute as well. * - * @return string + * @return string|null * The string representation of the attribute. */ public function render() { @@ -54,6 +54,7 @@ public function render() { if (isset($this->value) && static::RENDER_EMPTY_ATTRIBUTE || !empty($value)) { return Html::escape($this->name) . '="' . $value . '"'; } + return NULL; } /** diff --git a/core/lib/Drupal/Core/Test/TestDiscovery.php b/core/lib/Drupal/Core/Test/TestDiscovery.php index 716c925323ae948dd384accdeb592e53f9780a29..07a9168ad7ec9a8abe830b9a1bb8a72bd677d12b 100644 --- a/core/lib/Drupal/Core/Test/TestDiscovery.php +++ b/core/lib/Drupal/Core/Test/TestDiscovery.php @@ -242,10 +242,10 @@ public function findAllClassFiles($extension = NULL, ?string $directory = NULL) * @param string $namespace_prefix * The namespace prefix to use for discovered classes. Must contain a * trailing namespace separator (backslash). - * For example: 'Drupal\\node\\Tests\\' + * For example: 'Drupal\\node\\Tests\\'. * @param string $path * The directory path to scan. - * For example: '/path/to/drupal/core/modules/node/tests/src' + * For example: '/path/to/drupal/core/modules/node/tests/src'. * * @return array * An associative array whose keys are fully-qualified class names and whose diff --git a/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php b/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php index e93d4d25382c5ff793dee96730d5bb1aef06825e..c22a4d04e01d6ab42deb925c4e43b8f2884bd792 100644 --- a/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php +++ b/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php @@ -139,7 +139,7 @@ public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL); * @param string|array $type * A string describing the type of the alterable $data. * @param mixed $data - * The variable that will be passed to $theme_TYPE_alter() implementations + * The variable that will be passed to $theme_TYPE_alter() implementations. * @param mixed $context1 * (optional) An additional variable that is passed by reference. * @param mixed $context2 diff --git a/core/lib/Drupal/Core/TypedData/Validation/ContextualValidatorInterface.php b/core/lib/Drupal/Core/TypedData/Validation/ContextualValidatorInterface.php index aff6bfba20f91976ab093ae7dcd753a601e1151b..af429a4149abd984d5a7f4fcfb27d881f63252ed 100644 --- a/core/lib/Drupal/Core/TypedData/Validation/ContextualValidatorInterface.php +++ b/core/lib/Drupal/Core/TypedData/Validation/ContextualValidatorInterface.php @@ -16,7 +16,7 @@ interface ContextualValidatorInterface extends ContextualValidatorInterfaceBase * \Symfony\Component\Validator\Constraints\Valid is assumed. * * @param mixed $value - * The value to validate + * The value to validate. * @param \Symfony\Component\Validator\Constraint|\Symfony\Component\Validator\Constraint[] $constraints * The constraint(s) to validate against. * @param array|null $groups diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index 8f0de5f32244e69c0462b94e7e6ddd2aaada4846..9641284b0754a2321ab4d5a0b404b66ffe6c5bad 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -112,7 +112,7 @@ class Url implements TrustedCallbackInterface { * code more self-documenting. * * @param string $route_name - * The name of the route + * The name of the route. * @param array $route_parameters * (optional) An associative array of parameter names and values. * @param array $options @@ -138,7 +138,7 @@ public function __construct($route_name, $route_parameters = [], $options = []) * path (like robots.txt) use Url::fromUri() with the base: scheme. * * @param string $route_name - * The name of the route + * The name of the route. * @param array $route_parameters * (optional) An associative array of route parameter names and values. * @param array $options diff --git a/core/lib/Drupal/Core/Utility/token.api.php b/core/lib/Drupal/Core/Utility/token.api.php index 227335d1786091cc8c7aaff6dd399ed456cd4fed..18df7042ae975751457e367850752f8843ea7509 100644 --- a/core/lib/Drupal/Core/Utility/token.api.php +++ b/core/lib/Drupal/Core/Utility/token.api.php @@ -137,10 +137,10 @@ function hook_tokens($type, $tokens, array $data, array $options, \Drupal\Core\R * The context in which hook_tokens() was called. An associative array with * the following keys, which have the same meaning as the corresponding * parameters of hook_tokens(): - * - 'type' - * - 'tokens' - * - 'data' - * - 'options' + * - 'type'. + * - 'tokens'. + * - 'data'. + * - 'options'. * @param \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata * The bubbleable metadata. In case you alter an existing token based upon * a data source that isn't in $context['data'], you must add that diff --git a/core/misc/cspell/dictionary.txt b/core/misc/cspell/dictionary.txt index 076d0372fe451806f3a4925143bd5c4bdae5f6ed..68acdf882bb6884ea2b1104fcbd36c16480be8e5 100644 --- a/core/misc/cspell/dictionary.txt +++ b/core/misc/cspell/dictionary.txt @@ -34,6 +34,7 @@ autoplace autoplay autoreply autosubmit +avif backlink bakeware barchart @@ -234,6 +235,7 @@ icann iconwrap idekey iframeupload +imageavif imagecache indexname inglés diff --git a/core/modules/big_pipe/tests/modules/big_pipe_regression_test/src/BigPipeRegressionTestController.php b/core/modules/big_pipe/tests/modules/big_pipe_regression_test/src/BigPipeRegressionTestController.php index fe5a0e00ce46557a45444cdb1347f2ce90cec454..2d894da837ebe7ec364c0ffe9c7810d994203f53 100644 --- a/core/modules/big_pipe/tests/modules/big_pipe_regression_test/src/BigPipeRegressionTestController.php +++ b/core/modules/big_pipe/tests/modules/big_pipe_regression_test/src/BigPipeRegressionTestController.php @@ -87,6 +87,7 @@ public static function largeContentBuilder() { * #lazy_builder callback; builds <time> markup with current time. * * @return array + * Render array with a <time> markup with current time and cache settings. */ public static function currentTime() { return [ diff --git a/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipePlaceholderTestCases.php b/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipePlaceholderTestCases.php index 451523e0941a85901fa8784778776f3973f45dba..48471501c405b7244df50a9fb36d92f5ca05a598 100644 --- a/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipePlaceholderTestCases.php +++ b/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipePlaceholderTestCases.php @@ -32,6 +32,7 @@ class BigPipePlaceholderTestCases { * Optional. Necessary to get the embedded AJAX/HTML responses. * * @return \Drupal\big_pipe_test\BigPipePlaceholderTestCase[] + * An array of placeholder test cases. */ public static function cases(?ContainerInterface $container = NULL, ?AccountInterface $user = NULL) { // Define the two types of cacheability that we expect to see. These will be diff --git a/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php b/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php index de8716231b914d1613677c1fb960ba07b533601c..c625f7d2d23d7c92d29000e057ce33051df9bd98 100644 --- a/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php +++ b/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php @@ -19,6 +19,7 @@ class BigPipeTestController implements TrustedCallbackInterface { * Returns all BigPipe placeholder test case render arrays. * * @return array + * Render array containing various Big Pipe placeholder test cases. */ public function test() { $has_session = \Drupal::service('session_configuration')->hasSession(\Drupal::requestStack()->getMainRequest()); @@ -63,6 +64,7 @@ public function test() { /** * @return array + * List of all BigPipe placeholder test cases. */ public static function nope() { return ['#markup' => '<p>Nope.</p>']; @@ -74,6 +76,7 @@ public static function nope() { * @see \Drupal\Tests\big_pipe\Functional\BigPipeTest::testBigPipeMultiOccurrencePlaceholders() * * @return array + * Render array with multiple placeholders using a lazy builder. */ public function multiOccurrence() { return [ @@ -96,6 +99,9 @@ public function multiOccurrence() { * A page with placeholder preview. * * @return array[] + * A render array with two containers: + * - 'user_container': Loads the user’s display name via a lazy builder. + * - 'user_links_container': Loads user links with a placeholder preview. */ public function placeholderPreview() { return [ @@ -129,6 +135,8 @@ public function placeholderPreview() { * Note: does not actually use current time, that would complicate testing. * * @return array + * A render array containing a <time> element with a predefined date + * and disabled caching for dynamic rendering. */ public static function currentTime() { return [ @@ -141,6 +149,8 @@ public static function currentTime() { * #lazy_builder callback; suspends its own execution then returns markup. * * @return array + * A render array with a pig-themed message wrapped in a <span>, + * and caching disabled to ensure dynamic rendering. */ public static function piggy(): array { // Immediately call Fiber::suspend(), so that other placeholders are @@ -159,6 +169,8 @@ public static function piggy(): array { * #lazy_builder callback; says "hello" or "hi". * * @return array + * A render array with a marquee message using BigPipeMarkup, + * with caching disabled and a custom cache tag. */ public static function helloOrHi() { return [ @@ -185,6 +197,7 @@ public static function exception() { * @see \Drupal\big_pipe_test\EventSubscriber\BigPipeTestSubscriber::onRespondTriggerException() * * @return array + * A render array with plain text for testing BigPipe error handling. */ public static function responseException() { return ['#plain_text' => BigPipeTestSubscriber::CONTENT_TRIGGER_EXCEPTION]; @@ -273,7 +286,16 @@ public static function redirectUntrusted(): void { * {@inheritdoc} */ public static function trustedCallbacks() { - return ['currentTime', 'piggy', 'helloOrHi', 'exception', 'responseException', 'counter', 'redirectTrusted', 'redirectUntrusted']; + return [ + 'currentTime', + 'piggy', + 'helloOrHi', + 'exception', + 'responseException', + 'counter', + 'redirectTrusted', + 'redirectUntrusted', + ]; } } diff --git a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php index 1fac58c811528928dac2d8cfeaf4a4529922d76c..e6e2784fc11ee2261ddf4235fbe5262295a149a3 100644 --- a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php +++ b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php @@ -461,6 +461,7 @@ protected function setCsrfTokenSeedInTestEnvironment(): void { /** * @return \Drupal\big_pipe_test\BigPipePlaceholderTestCase[] + * An array of test cases. */ protected function getTestCases($has_session = TRUE) { return BigPipePlaceholderTestCases::cases($this->container, $this->rootUser); diff --git a/core/modules/big_pipe/tests/src/Unit/Render/FiberPlaceholderTest.php b/core/modules/big_pipe/tests/src/Unit/Render/FiberPlaceholderTest.php index 644ed8eb051800b8ae3431301f4144ad8f661070..b64095ecbdc12847f1f118dc0645c21123575105 100644 --- a/core/modules/big_pipe/tests/src/Unit/Render/FiberPlaceholderTest.php +++ b/core/modules/big_pipe/tests/src/Unit/Render/FiberPlaceholderTest.php @@ -110,6 +110,9 @@ public function testLongPlaceholderFiberSuspendingLoop(): void { } +/** + * Test class for testing fiber placeholders. + */ class TurtleLazyBuilder implements TrustedCallbackInterface { /** @@ -118,6 +121,7 @@ class TurtleLazyBuilder implements TrustedCallbackInterface { * Suspends its own execution twice to simulate long operation. * * @return array + * The lazy builder callback. */ public static function turtle(): array { if (\Fiber::getCurrent() !== NULL) { diff --git a/core/modules/block/src/BlockRepositoryInterface.php b/core/modules/block/src/BlockRepositoryInterface.php index 09f91168406b5f6a5d8801fb1050254cf8667471..d6cee45acc1f0544abad22396821f7cf214e1afb 100644 --- a/core/modules/block/src/BlockRepositoryInterface.php +++ b/core/modules/block/src/BlockRepositoryInterface.php @@ -2,6 +2,9 @@ namespace Drupal\block; +/** + * Provides an interface for the block repository. + */ interface BlockRepositoryInterface { /** diff --git a/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php b/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php index eb36cded0bc73558cbe70f74abc4d7ed74f4523c..f91f832e94747a329905bf1439cb2469a56cfbbd 100644 --- a/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php +++ b/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php @@ -12,6 +12,9 @@ use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * Determines the block plugin ID. + */ #[MigrateProcess('block_plugin_id')] class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginInterface { diff --git a/core/modules/block/src/Plugin/migrate/process/BlockRegion.php b/core/modules/block/src/Plugin/migrate/process/BlockRegion.php index f60471ca7027840b2337fa78caef135f997f50f7..e957adde2cb131679a593ed55d01c3bc65a6d450 100644 --- a/core/modules/block/src/Plugin/migrate/process/BlockRegion.php +++ b/core/modules/block/src/Plugin/migrate/process/BlockRegion.php @@ -9,6 +9,9 @@ use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * Determines the region for a block. + */ #[MigrateProcess('block_region')] class BlockRegion extends StaticMap implements ContainerFactoryPluginInterface { diff --git a/core/modules/block/src/Plugin/migrate/process/BlockTheme.php b/core/modules/block/src/Plugin/migrate/process/BlockTheme.php index f9b337ec02fab6e1bcc2c5b9e3d13e5bc1a551a5..ca7e9dff106a76d46580e2c9f3f80378e820eafb 100644 --- a/core/modules/block/src/Plugin/migrate/process/BlockTheme.php +++ b/core/modules/block/src/Plugin/migrate/process/BlockTheme.php @@ -10,6 +10,9 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * Determines the theme to use for a block. + */ #[MigrateProcess('block_theme')] class BlockTheme extends ProcessPluginBase implements ContainerFactoryPluginInterface { diff --git a/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php b/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php index 91ee670ca8b5e9fb74044708b2000b9d985f5ab5..032a569ef922caf86ccbb06c4c183f69b51f7604 100644 --- a/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php +++ b/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php @@ -13,6 +13,9 @@ use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * Determines the visibility for a block. + */ #[MigrateProcess('block_visibility')] class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPluginInterface { diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestXSSTitleBlock.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestXSSTitleBlock.php deleted file mode 100644 index 9e9d02dd3dca7cd7f30645b4f162f2f1a73b225f..0000000000000000000000000000000000000000 --- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestXSSTitleBlock.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\block_test\Plugin\Block; - -/** - * Provides a block to test XSS in title. - * - * @Block( - * id = "test_xss_title", - * admin_label = "<script>alert('XSS subject');</script>" - * ) - */ -class TestXSSTitleBlock extends TestCacheBlock { -} diff --git a/core/modules/block/tests/src/Functional/BlockInstallTest.php b/core/modules/block/tests/src/Functional/BlockInstallTest.php index eebbd02c7a2f21a2e0b5b57a5c19b1e5bbed808c..c368dfd8e8477c567489358d3cf1799cd75d9492 100644 --- a/core/modules/block/tests/src/Functional/BlockInstallTest.php +++ b/core/modules/block/tests/src/Functional/BlockInstallTest.php @@ -18,6 +18,9 @@ class BlockInstallTest extends BrowserTestBase { */ protected $defaultTheme = 'stark'; + /** + * Tests cache tag invalidation after installing the block module. + */ public function testCacheTagInvalidationUponInstallation(): void { // Warm the page cache. $this->drupalGet(''); diff --git a/core/modules/block/tests/src/Functional/BlockUiTest.php b/core/modules/block/tests/src/Functional/BlockUiTest.php index 920bec6c874ea134d07f8081ebe11ec9b0e75e9f..55f103a0116877ba60e7eba0f7dc0eb0fc901c13 100644 --- a/core/modules/block/tests/src/Functional/BlockUiTest.php +++ b/core/modules/block/tests/src/Functional/BlockUiTest.php @@ -335,12 +335,12 @@ public function testBlockPlacementIndicator(): void { // block placement indicator. Click the first 'Place block' link to bring up // the list of blocks to place in the first available region. $this->clickLink('Place block'); - // Select the first available block, which is the 'test_xss_title' plugin, - // with a default machine name 'scriptalertxsssubjectscript' that is used + // Select the first available block, which is the 'test_block_instantiation' + // plugin, with a default machine name 'stark-displaymessage' that is used // for the 'block-placement' querystring parameter. $this->clickLink('Place block'); $this->submitForm([], 'Save block'); - $this->assertSession()->addressEquals('admin/structure/block/list/stark?block-placement=stark-scriptalertxsssubjectscript'); + $this->assertSession()->addressEquals('admin/structure/block/list/stark?block-placement=stark-displaymessage'); // Removing a block will remove the block placement indicator. $this->clickLink('Remove'); diff --git a/core/modules/block/tests/src/Functional/BlockXssTest.php b/core/modules/block/tests/src/Functional/BlockXssTest.php index 1bd50dfa373680094ff4912781ebec22f82a3e27..9542fd4210c4229a63973e21c93102d5ef992a8e 100644 --- a/core/modules/block/tests/src/Functional/BlockXssTest.php +++ b/core/modules/block/tests/src/Functional/BlockXssTest.php @@ -45,12 +45,14 @@ public function testNoUnexpectedEscaping(): void { * Tests XSS in title. */ public function testXssInTitle(): void { - $this->container->get('module_installer')->install(['block_test']); - $this->drupalPlaceBlock('test_xss_title', ['label' => '<script>alert("XSS label");</script>']); + $this->drupalPlaceBlock('system_powered_by_block', [ + 'label' => '<script>alert("XSS label");</script>', + 'label_display' => 'visible', + ]); - \Drupal::keyValue('block_test')->set('content', $this->randomMachineName()); $this->drupalGet(''); // Check that the block title was properly sanitized when rendered. + $this->assertSession()->assertEscaped('<script>alert("XSS label");</script>'); $this->assertSession()->responseNotContains('<script>alert("XSS label");</script>'); $this->drupalLogin($this->drupalCreateUser([ @@ -61,24 +63,10 @@ public function testXssInTitle(): void { $this->drupalGet('admin/structure/block/list/' . $default_theme); // Check that the block title was properly sanitized in Block Plugin UI // Admin page. + $this->assertSession()->assertEscaped('<script>alert("XSS label");</script>'); $this->assertSession()->responseNotContains("<script>alert('XSS subject');</script>"); } - /** - * Tests XSS in category. - */ - public function testXssInCategory(): void { - $this->container->get('module_installer')->install(['block_test']); - $this->drupalPlaceBlock('test_xss_title'); - $this->drupalLogin($this->drupalCreateUser([ - 'administer blocks', - 'access administration pages', - ])); - $this->drupalGet(Url::fromRoute('block.admin_display')); - $this->clickLink('Place block'); - $this->assertSession()->responseNotContains("<script>alert('XSS category');</script>"); - } - /** * Tests various modules that provide blocks for XSS. */ diff --git a/core/modules/block/tests/src/FunctionalJavascript/BlockFilterTest.php b/core/modules/block/tests/src/FunctionalJavascript/BlockFilterTest.php index 8914669d72c0627fb14ea5dc4be6048c8a00d2c5..3502e65a1959137a90881df5cd17f84c1b79ad49 100644 --- a/core/modules/block/tests/src/FunctionalJavascript/BlockFilterTest.php +++ b/core/modules/block/tests/src/FunctionalJavascript/BlockFilterTest.php @@ -89,6 +89,7 @@ public function testBlockFilter(): void { * An array of node elements. * * @return \Behat\Mink\Element\NodeElement[] + * An array of visible elements. */ protected function filterVisibleElements(array $elements): array { $elements = array_filter($elements, function (NodeElement $element) { diff --git a/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php b/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php index 79802e1e376a61d0679a8ccc4ec910f00d7693fe..5a8f88d710114a3e2403431977b6d1c55d0162b0 100644 --- a/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php +++ b/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php @@ -60,6 +60,8 @@ public function testAutocompleteSuggestions($string, $suggestions): void { * Data provider for testAutocompleteSuggestions(). * * @return array + * An array of test cases, each containing an input string and + * expected autocomplete suggestions. */ public static function providerTestAutocompleteSuggestions() { $test_parameters = []; diff --git a/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module index 7b85ae6de45bab4d8de771fe0ccf4ea60f299502..75bc2f1ec1e5407012dc478daa60c828c79cf130 100644 --- a/core/modules/block_content/block_content.module +++ b/core/modules/block_content/block_content.module @@ -14,7 +14,7 @@ * @param string $block_type_id * Id of the block type. * @param string $label - * (optional) The label for the body instance. Defaults to 'Body' + * (optional) The label for the body instance. Defaults to 'Body'. * * @return \Drupal\field\Entity\FieldConfig * A Body field object. diff --git a/core/modules/block_content/src/Controller/BlockContentController.php b/core/modules/block_content/src/Controller/BlockContentController.php index 20bd0f0d1caa4848ab7b13e1438d0f4f8817b868..b2776f51d7d81736c08dd5171185a13ca57b1018 100644 --- a/core/modules/block_content/src/Controller/BlockContentController.php +++ b/core/modules/block_content/src/Controller/BlockContentController.php @@ -10,6 +10,9 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; +/** + * Controller routines for custom block routes. + */ class BlockContentController extends ControllerBase { /** diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php b/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php index 41f27a800954ef948d4162dcbcdd9825c38a1456..d0a3794b978da1a73d436ab30607ed38ac7aa4b9 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php @@ -101,7 +101,7 @@ protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = * If $values is a string, it will be considered that it represents the * label. * @param bool $create_body - * Whether or not to create the body field + * Whether or not to create the body field. * * @return \Drupal\block_content\Entity\BlockContentType * Created block type. diff --git a/core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php b/core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php index 6252aa73615653441aa25dc1e6a0c567b91f5f3e..707d283b1e0bc095b34748ccf919d40584007fd5 100644 --- a/core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php +++ b/core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php @@ -125,7 +125,7 @@ protected function setUp(): void { * assert parent will not be called. * @param string $expected_access * The expected access for the user and block content. Valid values are - * class names of classes implementing AccessResultInterface + * class names of classes implementing AccessResultInterface. * @param string|null $expected_access_message * The expected access message. * diff --git a/core/modules/ckeditor5/ckeditor5.module b/core/modules/ckeditor5/ckeditor5.module index 9da40001b8dc3432906403fe755944e5c4eda7b0..551ff7f397eaf66128a296d7653025adb4f26b16 100644 --- a/core/modules/ckeditor5/ckeditor5.module +++ b/core/modules/ckeditor5/ckeditor5.module @@ -140,7 +140,7 @@ function _update_ckeditor5_html_filter(array $form, FormStateInterface $form_sta $response->addCommand(new InvokeCommand('[data-drupal-selector="edit-editor-editor"]', $ckeditor5_selected_but_errors ? 'addClass' : 'removeClass', ['error'])); $response->addCommand(new InvokeCommand('[data-drupal-selector="edit-editor-editor"]', $ckeditor5_selected_but_errors ? 'attr' : 'removeAttr', ['data-error-switching-to-ckeditor5', TRUE])); - /** + /* * Recursively find #attach items in the form and add as attachments to the * AJAX response. * diff --git a/core/modules/ckeditor5/src/Attribute/CKEditor5AspectsOfCKEditor5Plugin.php b/core/modules/ckeditor5/src/Attribute/CKEditor5AspectsOfCKEditor5Plugin.php index 26a9921e843ec8d10be070e4d32a6e9cb36558f9..66475cd7ff36351268c58d9cd88769c1cb0bbf5d 100644 --- a/core/modules/ckeditor5/src/Attribute/CKEditor5AspectsOfCKEditor5Plugin.php +++ b/core/modules/ckeditor5/src/Attribute/CKEditor5AspectsOfCKEditor5Plugin.php @@ -6,6 +6,9 @@ use Drupal\Component\Plugin\Attribute\Plugin; +/** + * Defines the CKEditor5 aspect of CKEditor5 plugin. + */ #[\Attribute(\Attribute::TARGET_CLASS)] class CKEditor5AspectsOfCKEditor5Plugin extends Plugin { diff --git a/core/modules/ckeditor5/src/Attribute/DrupalAspectsOfCKEditor5Plugin.php b/core/modules/ckeditor5/src/Attribute/DrupalAspectsOfCKEditor5Plugin.php index 167d7cedfbc29c334a019b027b72f157fef8b592..4df530b09c800246152b84731267eb962a08e3d3 100644 --- a/core/modules/ckeditor5/src/Attribute/DrupalAspectsOfCKEditor5Plugin.php +++ b/core/modules/ckeditor5/src/Attribute/DrupalAspectsOfCKEditor5Plugin.php @@ -8,6 +8,9 @@ use Drupal\Component\Plugin\Attribute\Plugin; use Drupal\Core\StringTranslation\TranslatableMarkup; +/** + * Define a Drupal aspects of CKEditor5 plugin. + */ #[\Attribute(\Attribute::TARGET_CLASS)] class DrupalAspectsOfCKEditor5Plugin extends Plugin { diff --git a/core/modules/ckeditor5/src/Hook/Ckeditor5Hooks.php b/core/modules/ckeditor5/src/Hook/Ckeditor5Hooks.php index d47451528cf58f69109246d66d1b807995fdf114..85ead6ae51dd6ab134247ab3adccc34e2869de3f 100644 --- a/core/modules/ckeditor5/src/Hook/Ckeditor5Hooks.php +++ b/core/modules/ckeditor5/src/Hook/Ckeditor5Hooks.php @@ -161,7 +161,7 @@ public function formFilterFormatFormAlter(array &$form, FormStateInterface $form 'ckeditor5_only' => 'true', ]; } - /** + /* * Recursively adds AJAX listeners to plugin settings elements. * * These are added so allowed tags and other fields that have values diff --git a/core/modules/ckeditor5/src/Plugin/ConfigAction/AddItemToToolbar.php b/core/modules/ckeditor5/src/Plugin/ConfigAction/AddItemToToolbar.php index b374e35e6d7c936eaef221398edf1bfe74945c6b..4be8fdeaa59c288b6878259a71cabb4c7d916403 100644 --- a/core/modules/ckeditor5/src/Plugin/ConfigAction/AddItemToToolbar.php +++ b/core/modules/ckeditor5/src/Plugin/ConfigAction/AddItemToToolbar.php @@ -12,6 +12,12 @@ use Drupal\editor\EditorInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * Config action plugin to add an item to the toolbar. + * + * @internal + * This API is experimental. + */ #[ConfigAction( id: 'editor:addItemToToolbar', admin_label: new TranslatableMarkup('Add an item to a CKEditor 5 toolbar'), diff --git a/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php b/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php index ade83b027d8a64c5545f58052b587f6e92957842..ff05478b2e868d4eadcd656403a4894ac61c6455 100644 --- a/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php +++ b/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php @@ -117,7 +117,7 @@ class CKEditor5 extends EditorBase implements ContainerFactoryPluginInterface { * @param \Drupal\ckeditor5\Plugin\CKEditor5PluginManagerInterface $ckeditor5_plugin_manager * The CKEditor 5 plugin manager. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager + * The language manager. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\ckeditor5\SmartDefaultSettings $smart_default_settings diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestBase.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestBase.php index 9d86c0ee392842e110a0e1837b48a5045e8f5778..427a74a7054c99d15ebef83ad3366b205f03e9c4 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestBase.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestBase.php @@ -51,6 +51,7 @@ abstract class ImageTestBase extends CKEditor5TestBase { * Provides the relevant image attributes. * * @return string[] + * An associative array with the image source, width, and height. */ protected function imageAttributes() { return [ @@ -67,6 +68,7 @@ protected function imageAttributes() { * Reverse attributes when printing them. * * @return string + * A space-separated string of image attributes. */ protected function imageAttributesAsString($reverse = FALSE) { $string = []; diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestProviderTrait.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestProviderTrait.php index 91ff49e91868fd8f78625efe52d66ba57fe3c4ba..9e7571bc79076da27c66c760eb37cb83e456a8a0 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestProviderTrait.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestProviderTrait.php @@ -243,6 +243,7 @@ public function testWidth(string $width): void { * Data provider for ::testWidth(). * * @return string[][] + * An array of test cases, each with a width value. */ public static function providerWidth(): array { return [ diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestTestBase.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestTestBase.php index c60b8d4e8f9a2059200e8707cf92b0c5056133ee..070ae0e90cadb7066e841e7decdbd44f84227a1c 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestTestBase.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestTestBase.php @@ -113,6 +113,7 @@ function (ConstraintViolationInterface $v) { * Provides the relevant image attributes. * * @return string[] + * Default image attributes for tests. */ protected function imageAttributes(): array { return [ diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/LanguageTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/LanguageTest.php index c46c5588ac32a5040890a525e1a5583ca6a4a773..47ed0b6569b51967fd96f781aa83a7cec5eb473f 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/LanguageTest.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/LanguageTest.php @@ -81,6 +81,8 @@ public function test(string $langcode, string $toolbar_item_name, string $toolba * Data provider for ensuring CKEditor 5 UI translations are loaded. * * @return string[][] + * An array of language code, CKEditor 5 plugin name, and expected + * translation. */ public static function provider(): array { return [ diff --git a/core/modules/ckeditor5/tests/src/Kernel/LanguageTest.php b/core/modules/ckeditor5/tests/src/Kernel/LanguageTest.php index 711354bd5b211013c161185d565f8775ca25ae47..227496d641912665ba0b2650a098d1c4626884dd 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/LanguageTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/LanguageTest.php @@ -99,6 +99,7 @@ public function test(string $drupal_langcode, string $cke5_langcode, bool $is_mi * Provides a list of language code pairs. * * @return string[][] + * An array of language code pairs. */ public static function provider(): array { $random_langcode = Random::machineName(); diff --git a/core/modules/ckeditor5/tests/src/Unit/SmartDefaultSettingsTest.php b/core/modules/ckeditor5/tests/src/Unit/SmartDefaultSettingsTest.php index c694c2870b45be15f885dda66f3dccfddb55485e..aeb866eaffd0afb23a7481b0657ea6b72cd94c97 100644 --- a/core/modules/ckeditor5/tests/src/Unit/SmartDefaultSettingsTest.php +++ b/core/modules/ckeditor5/tests/src/Unit/SmartDefaultSettingsTest.php @@ -38,6 +38,7 @@ public function testSurplusScore(HTMLRestrictions $surplus, HTMLRestrictions $ne * Data provider for testing computeSurplusScore(). * * @return \Generator + * Yields the data for testSurplusScore(). */ public static function providerSurplusScore(): \Generator { $needed = new HTMLRestrictions(['code' => FALSE]); @@ -103,6 +104,7 @@ public function testCandidates(HTMLRestrictions $provided, HTMLRestrictions $sti * Data provider for testing getCandidates() and ::selectCandidate(). * * @return \Generator + * Yields the data for testCandidates(). */ public static function providerCandidates(): \Generator { $generate_definition = function (string $label_and_id, array $overrides): CKEditor5PluginDefinition { diff --git a/core/modules/comment/comment.api.php b/core/modules/comment/comment.api.php index adb7c586302ec011a182acfb7a91b896c3e3429d..3934dc88c87060e058309acf06512ee1d5497f2e 100644 --- a/core/modules/comment/comment.api.php +++ b/core/modules/comment/comment.api.php @@ -23,9 +23,9 @@ * @param array &$context * Various aspects of the context in which the comment links are going to be * displayed, with the following keys: - * - 'view_mode': the view mode in which the comment is being viewed - * - 'langcode': the language in which the comment is being viewed - * - 'commented_entity': the entity to which the comment is attached + * - 'view_mode': the view mode in which the comment is being viewed. + * - 'langcode': the language in which the comment is being viewed. + * - 'commented_entity': the entity to which the comment is attached. * * @see \Drupal\comment\CommentViewBuilder::renderLinks() * @see \Drupal\comment\CommentViewBuilder::buildLinks() diff --git a/core/modules/comment/src/CommentStatistics.php b/core/modules/comment/src/CommentStatistics.php index d2d08dfc0eecc28cf286b7365d57a7d58fe40620..9c43e14fa7b66ce916e108394f0517fcc99f7e81 100644 --- a/core/modules/comment/src/CommentStatistics.php +++ b/core/modules/comment/src/CommentStatistics.php @@ -13,6 +13,9 @@ use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\user\EntityOwnerInterface; +/** + * Service for storing and retrieving comment statistics. + */ class CommentStatistics implements CommentStatisticsInterface { use StringTranslationTrait; diff --git a/core/modules/comment/src/CommentStatisticsInterface.php b/core/modules/comment/src/CommentStatisticsInterface.php index 774a4cfb2a37d4a68e740faedbbfe3e2e30fa26e..eaf2bd855e04c84c37f89ab646e71993cdb120db 100644 --- a/core/modules/comment/src/CommentStatisticsInterface.php +++ b/core/modules/comment/src/CommentStatisticsInterface.php @@ -25,7 +25,7 @@ public function getRankingInfo(); * Read comment statistics records for an array of entities. * * @param \Drupal\Core\Entity\EntityInterface[] $entities - * Array of entities on which commenting is enabled, keyed by id + * Array of entities on which commenting is enabled, keyed by id. * @param string $entity_type * The entity type of the passed entities. * @param bool $accurate diff --git a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php index 474d1cad41e21d391a0bd4e53f1141a96bd456b6..45ba7394399f0b8f524f7978532e78084c6383ec 100644 --- a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php +++ b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php @@ -4,6 +4,7 @@ use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Session\AccountSwitcherInterface; use Drupal\Core\State\StateInterface; @@ -56,9 +57,11 @@ class EntityComment extends EntityContentBase { * The state storage object. * @param \Drupal\Core\Session\AccountSwitcherInterface|null $account_switcher * The account switcher service. + * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface|null $entity_type_bundle_info + * The entity type bundle info service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, StateInterface $state, ?AccountSwitcherInterface $account_switcher = NULL) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_field_manager, $field_type_manager, $account_switcher); + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, StateInterface $state, ?AccountSwitcherInterface $account_switcher = NULL, ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_field_manager, $field_type_manager, $account_switcher, $entity_type_bundle_info); $this->state = $state; } @@ -77,7 +80,8 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('entity_field.manager'), $container->get('plugin.manager.field.field_type'), $container->get('state'), - $container->get('account_switcher') + $container->get('account_switcher'), + $container->get('entity_type.bundle.info'), ); } diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d7/CommentEntityTranslationCheckRequirementsTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d7/CommentEntityTranslationCheckRequirementsTest.php index 47dc5969acdb893a0e7387ceec89da490cf90ef6..26f84a0f1e36f050f19e5270f339a21f6854f902 100644 --- a/core/modules/comment/tests/src/Kernel/Migrate/d7/CommentEntityTranslationCheckRequirementsTest.php +++ b/core/modules/comment/tests/src/Kernel/Migrate/d7/CommentEntityTranslationCheckRequirementsTest.php @@ -47,6 +47,7 @@ public function testCheckRequirements($module): void { * Provides data for testCheckRequirements. * * @return string[][] + * An array of module machine names. */ public static function providerTestCheckRequirements() { return [ diff --git a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php index 1d26daaf4a91a8a46a841aa2a0cc37b7f482a31d..2fea7255687cdf809ca41b118ff018ff1e7deca9 100644 --- a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php +++ b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php @@ -263,9 +263,9 @@ public static function getLinkCombinations() { * @param bool $has_field * TRUE if the node has the 'comment' field. * @param int $comment_status - * One of CommentItemInterface::OPEN|HIDDEN|CLOSED + * One of CommentItemInterface::OPEN|HIDDEN|CLOSED. * @param int $form_location - * One of CommentItemInterface::FORM_BELOW|FORM_SEPARATE_PAGE + * One of CommentItemInterface::FORM_BELOW|FORM_SEPARATE_PAGE. * @param int $comment_count * Number of comments against the field. * diff --git a/core/modules/config/src/Form/ConfigSync.php b/core/modules/config/src/Form/ConfigSync.php index f59b9d6fced523228f088a957f6163369a9c1686..bb464479ede0758c5693851f6707ec6acbbac89d 100644 --- a/core/modules/config/src/Form/ConfigSync.php +++ b/core/modules/config/src/Form/ConfigSync.php @@ -57,7 +57,7 @@ class ConfigSync extends FormBase { * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer. * @param \Drupal\Core\Extension\ModuleExtensionList $moduleExtensionList - * The module extension list + * The module extension list. * @param \Drupal\Core\Config\ImportStorageTransformer $importTransformer * The import transformer service. * @param \Drupal\Core\Extension\ThemeExtensionList $themeExtensionList diff --git a/core/modules/config/tests/config_action_duplicate_test/src/Plugin/ConfigAction/DuplicateConfigAction.php b/core/modules/config/tests/config_action_duplicate_test/src/Plugin/ConfigAction/DuplicateConfigAction.php index d2a2dd573deda378f9c72ee071a2dcba79b91697..431d4114f85b4e33a064f7c8101e01e0e5d3573e 100644 --- a/core/modules/config/tests/config_action_duplicate_test/src/Plugin/ConfigAction/DuplicateConfigAction.php +++ b/core/modules/config/tests/config_action_duplicate_test/src/Plugin/ConfigAction/DuplicateConfigAction.php @@ -8,6 +8,12 @@ use Drupal\Core\Config\Action\ConfigActionPluginInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; +/** + * Test config action for testing duplicating a config action. + * + * @internal + * This API is experimental. + */ #[ConfigAction( id: 'config_action_duplicate_test:config_test.dynamic:setProtectedProperty', admin_label: new TranslatableMarkup('A duplicate config action'), diff --git a/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php b/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php index ed5dd77ac5bbd45c5f713906d340322bf41fe6a9..1c21974ad1ed496f3897db27e6558ffc8fb17574 100644 --- a/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php +++ b/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php @@ -9,6 +9,9 @@ use Drupal\Core\State\StateInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +/** + * Event subscriber for testing configuration collection. + */ class EventSubscriber implements EventSubscriberInterface { /** diff --git a/core/modules/config/tests/config_events_test/src/EventSubscriber.php b/core/modules/config/tests/config_events_test/src/EventSubscriber.php index b92f79b8344fcf5819d975434c59cb04239a3843..aca5b8d2d83f74f75dcb27446c44beeea5c248ef 100644 --- a/core/modules/config/tests/config_events_test/src/EventSubscriber.php +++ b/core/modules/config/tests/config_events_test/src/EventSubscriber.php @@ -10,6 +10,9 @@ use Drupal\Core\State\StateInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +/** + * Event subscriber for testing configuration events. + */ class EventSubscriber implements EventSubscriberInterface { /** diff --git a/core/modules/config/tests/config_test/src/ConfigTestStorage.php b/core/modules/config/tests/config_test/src/ConfigTestStorage.php index 9a34ed66df9a39df9c6dad28fb53da5bbb4613d0..adfc970ccb3252e5d5a840d3a0c518d7bb558447 100644 --- a/core/modules/config/tests/config_test/src/ConfigTestStorage.php +++ b/core/modules/config/tests/config_test/src/ConfigTestStorage.php @@ -7,6 +7,9 @@ use Drupal\Core\Config\Entity\ConfigEntityStorage; use Drupal\Core\Config\Config; +/** + * Storage class for testing configuration entity storage. + */ class ConfigTestStorage extends ConfigEntityStorage { /** diff --git a/core/modules/config/tests/src/Functional/ConfigImportUITest.php b/core/modules/config/tests/src/Functional/ConfigImportUITest.php index c72e270779beb76b452155bde780a9bcf5cd56d2..98af0941d93307525db1f826cd89a62bf25d9b75 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportUITest.php @@ -379,6 +379,9 @@ public function testImportValidation(): void { $this->assertNotEquals($this->config('system.site')->get('name'), $new_site_name); } + /** + * Tests that the Configuration module cannot be uninstalled during config sync. + */ public function testConfigUninstallConfigException(): void { $sync = $this->container->get('config.storage.sync'); @@ -394,6 +397,9 @@ public function testConfigUninstallConfigException(): void { $this->assertSession()->pageTextContains('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'); } + /** + * Prepares a site name update by modifying the synchronized configuration. + */ public function prepareSiteNameUpdate($new_site_name): void { $sync = $this->container->get('config.storage.sync'); // Create updated configuration object. diff --git a/core/modules/config/tests/src/FunctionalJavascript/ConfigExportTest.php b/core/modules/config/tests/src/FunctionalJavascript/ConfigExportTest.php index 4323a4b2ae369ce0acaf57402899f4b3e0fea8a3..2489d31ae95871f45e36a9cd5aa2f11971c6bade 100644 --- a/core/modules/config/tests/src/FunctionalJavascript/ConfigExportTest.php +++ b/core/modules/config/tests/src/FunctionalJavascript/ConfigExportTest.php @@ -64,6 +64,7 @@ protected function setUp(): void { * Title of the block. * * @return \Drupal\block_content\Entity\BlockContent + * The created block content entity. * * @throws \Drupal\Core\Entity\EntityStorageException */ diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php index feecfb0319075c6260f2be70056264334f3240bf..f9b9dbe42fc9db24e70335b1a6619e95b12693e7 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php @@ -64,6 +64,9 @@ protected function getPo($langcode): string { PO; } + /** + * Tests install of Configuration Translation module. + */ public function testConfigTranslation(): void { \Drupal::service('module_installer')->install(['node', 'field_ui']); $this->createContentType(['type' => 'article']); diff --git a/core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php b/core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php index 68eb18dbb8b33ee9e145b8f4985a2681cc5e09d1..e3c5fa7836f26f2e10639aa787a773ae0c14cf82 100644 --- a/core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php +++ b/core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php @@ -31,7 +31,7 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase { * Constructs the event subscriber. * * @param \Drupal\Core\Config\ConfigManagerInterface $config_manager - * The config manager + * The config manager. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. */ diff --git a/core/modules/content_moderation/src/Plugin/ConfigAction/AddModeration.php b/core/modules/content_moderation/src/Plugin/ConfigAction/AddModeration.php index a2df177036ba003bf9c1c51c3e96132c2c5817f4..eafabbe1f227091a6f065ebb79ac0d714d807d5c 100644 --- a/core/modules/content_moderation/src/Plugin/ConfigAction/AddModeration.php +++ b/core/modules/content_moderation/src/Plugin/ConfigAction/AddModeration.php @@ -12,6 +12,10 @@ use Drupal\workflows\WorkflowInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * @internal + * This API is experimental. + */ #[ConfigAction( id: 'add_moderation', entity_types: ['workflow'], diff --git a/core/modules/content_moderation/src/Plugin/ConfigAction/AddModerationDeriver.php b/core/modules/content_moderation/src/Plugin/ConfigAction/AddModerationDeriver.php index fec8c773e66303f7bde3b41db91a8b92f725c205..7f9829c5f9a057ff297ea27a0a8acd288179e28c 100644 --- a/core/modules/content_moderation/src/Plugin/ConfigAction/AddModerationDeriver.php +++ b/core/modules/content_moderation/src/Plugin/ConfigAction/AddModerationDeriver.php @@ -14,6 +14,9 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\String\Inflector\EnglishInflector; +/** + * Deriver for moderation config actions plugins. + */ final class AddModerationDeriver extends DeriverBase implements ContainerDeriverInterface { use StringTranslationTrait; diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index 87b511c645b0e0be340e52bd15053a2e947d8969..50e003726e222d724ba32a80dabe8b2c1860c0fb 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -75,7 +75,7 @@ function content_translation_field_sync_widget(FieldDefinitionInterface $field, } /** - * (proxied) Implements hook_form_FORM_ID_alter(). + * Injects translation settings into the content language settings form. */ function _content_translation_form_language_content_settings_form_alter(array &$form, FormStateInterface $form_state): void { // Inject into the content language settings the translation settings if the @@ -189,7 +189,7 @@ function _content_translation_is_field_translatability_configurable(EntityTypeIn } /** - * (proxied) Implements hook_preprocess_HOOK(). + * Injects translation settings into the language content settings table. */ function _content_translation_preprocess_language_content_settings_table(&$variables): void { // Alter the 'build' variable injecting the translation settings if the user diff --git a/core/modules/content_translation/src/ContentTranslationHandlerInterface.php b/core/modules/content_translation/src/ContentTranslationHandlerInterface.php index 96b2a1273956f0e9ab9739f3fdec0716f00e3dc2..c457db28e837f41d0ca27fe5045e7c7f7439a3ee 100644 --- a/core/modules/content_translation/src/ContentTranslationHandlerInterface.php +++ b/core/modules/content_translation/src/ContentTranslationHandlerInterface.php @@ -28,9 +28,9 @@ public function getFieldDefinitions(); * The entity whose translation has to be accessed. * @param string $op * The operation to be performed on the translation. Possible values are: - * - "create" - * - "update" - * - "delete" + * - "create". + * - "update". + * - "delete". * * @return \Drupal\Core\Access\AccessResultInterface * The access result. diff --git a/core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php b/core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php index 2e9ed9e26617c966ed67b1b660fee1b8916a57af..52418c280890a19e7d97c62b458559fb66564db5 100644 --- a/core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php +++ b/core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php @@ -480,6 +480,7 @@ protected function setUntranslatableFieldWidgetsDisplay($display): void { /** * @return \Drupal\Core\Entity\ContentEntityInterface + * The saved entity. */ protected function saveNewEntity() { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ diff --git a/core/modules/datetime/tests/src/Functional/DateTestBase.php b/core/modules/datetime/tests/src/Functional/DateTestBase.php index 6b128598a944d6a50758e55fe012bfb740d6f6e6..b7399930273cbdc711871fc1a0a3fb763cd8d27c 100644 --- a/core/modules/datetime/tests/src/Functional/DateTestBase.php +++ b/core/modules/datetime/tests/src/Functional/DateTestBase.php @@ -82,6 +82,7 @@ abstract class DateTestBase extends BrowserTestBase { * Returns the type of field to be tested. * * @return string + * The field type to be tested. */ abstract protected function getTestFieldType(); diff --git a/core/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php b/core/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php index 8ff735320fca06523fd854b8102d72062d50004a..96e6687ee99c3dce787aabcab8b2bb87b8d8c20c 100644 --- a/core/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php +++ b/core/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php @@ -43,7 +43,7 @@ public function getFormId() { * Process callback. * * @param array $element - * Form element + * Form element. * * @return array * Processed element. diff --git a/core/modules/editor/src/Attribute/Editor.php b/core/modules/editor/src/Attribute/Editor.php index d9aedf5631ab00de96bc0ab2ab92139a84d18a3a..56939727c8f37c9507baf8644d723bd63783d3c3 100644 --- a/core/modules/editor/src/Attribute/Editor.php +++ b/core/modules/editor/src/Attribute/Editor.php @@ -27,7 +27,7 @@ class Editor extends Plugin { * @param string $id * The plugin ID. * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label - * The human-readable name of the text editor, translated + * The human-readable name of the text editor, translated. * @param bool $supports_content_filtering * Whether the editor supports "allowed content only" filtering. * @param bool $supports_inline_editing diff --git a/core/modules/editor/tests/src/Functional/EditorLoadingTest.php b/core/modules/editor/tests/src/Functional/EditorLoadingTest.php index 50dc99e398a1d90d50fc9fc4e8aa017f4db5379c..eacc55d36f0614ec014db179ab1e17ed57fe04a8 100644 --- a/core/modules/editor/tests/src/Functional/EditorLoadingTest.php +++ b/core/modules/editor/tests/src/Functional/EditorLoadingTest.php @@ -302,6 +302,9 @@ public function testSupportedElementTypes(): void { $this->assertNotSame('edit-field-text-0-value', $select->getAttribute('data-editor-for')); } + /** + * Gets the information to check for the given field. + */ protected function getThingsToCheck($field_name, $type = 'textarea'): array { $settings = $this->getDrupalSettings(); return [ diff --git a/core/modules/editor/tests/src/Kernel/EditorValidationTest.php b/core/modules/editor/tests/src/Kernel/EditorValidationTest.php index 956177d94a1fda53f6091cb5ac9f87a462c1c644..5d5cee0cb4a0955b5e78d2f4ad4fa6bb7ed9bf2b 100644 --- a/core/modules/editor/tests/src/Kernel/EditorValidationTest.php +++ b/core/modules/editor/tests/src/Kernel/EditorValidationTest.php @@ -131,7 +131,9 @@ public function testLabelValidation(): void { } /** - * `image_upload.status = TRUE` must cause additional keys to be required. + * Test validation when dynamically changing image upload settings. + * + * Additional keys are required when image_upload.status is TRUE. */ public function testImageUploadSettingsAreDynamicallyRequired(): void { // When image uploads are disabled, no other key-value pairs are needed. diff --git a/core/modules/field/src/FieldConfigAccessControlHandler.php b/core/modules/field/src/FieldConfigAccessControlHandler.php index 6ee0e05cb655a6b32772283b2dd5d92c3a33f179..d3a297430a69f79fdc5bdb7be5e93b4a086c1d2b 100644 --- a/core/modules/field/src/FieldConfigAccessControlHandler.php +++ b/core/modules/field/src/FieldConfigAccessControlHandler.php @@ -24,7 +24,7 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter // a certain field storage config entity, it should also be allowed for all // associated field config entities. // @see \Drupal\Core\Field\FieldDefinitionInterface - /** \Drupal\field\FieldConfigInterface $entity */ + /** @var \Drupal\field\FieldConfigInterface $entity */ $field_storage_entity = $entity->getFieldStorageDefinition(); return $field_storage_entity->access($operation, $account, TRUE); } diff --git a/core/modules/field/src/FieldStorageConfigAccessControlHandler.php b/core/modules/field/src/FieldStorageConfigAccessControlHandler.php index da48556fab987acfbb8a09e8fff7c6df163f4354..bfa09a30cab042c5ab2bb5e1d238b03acc8b69d1 100644 --- a/core/modules/field/src/FieldStorageConfigAccessControlHandler.php +++ b/core/modules/field/src/FieldStorageConfigAccessControlHandler.php @@ -18,7 +18,7 @@ class FieldStorageConfigAccessControlHandler extends EntityAccessControlHandler * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { - /** \Drupal\field\FieldStorageConfigInterface $entity */ + /** @var \Drupal\field\FieldStorageConfigInterface $entity */ if ($operation === 'delete') { if ($entity->isLocked()) { return AccessResult::forbidden()->addCacheableDependency($entity); diff --git a/core/modules/field/src/Plugin/migrate/process/FieldType.php b/core/modules/field/src/Plugin/migrate/process/FieldType.php index 52d5cc5ba15a4b4abb0dcc8bade82a556affafb9..d4df1feb2f09f741d22c09beeb03a87b789be2b2 100644 --- a/core/modules/field/src/Plugin/migrate/process/FieldType.php +++ b/core/modules/field/src/Plugin/migrate/process/FieldType.php @@ -12,6 +12,9 @@ use Drupal\migrate_drupal\Plugin\MigrateFieldPluginManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * Determines the field type for a field. + */ #[MigrateProcess('field_type')] class FieldType extends StaticMap implements ContainerFactoryPluginInterface { diff --git a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php index 2fcef2b5893194e26de6b2c5a6b4e5fd2db44140..43e3b111c4853743fdb4f5924ccd0f7e269afeef 100644 --- a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php +++ b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php @@ -71,7 +71,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable * as D8 uses "KB" and "MB" respectively. * * @param string $size_string - * The size string, eg 10M + * The size string, eg "10M". * * @return string * The D8 version of the size string. diff --git a/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php b/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php index b0e8a5a3194a743774c3a6fe20d660a66feae76a..f75c8a0b0e26c13e0463d0f9e3695bd697476022 100644 --- a/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php +++ b/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php @@ -7,6 +7,9 @@ use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; +/** + * Determines the default values for a field instance. + */ #[MigrateProcess('d7_field_instance_defaults')] class FieldInstanceDefaults extends ProcessPluginBase { diff --git a/core/modules/field/src/Plugin/migrate/process/d7/FieldSettings.php b/core/modules/field/src/Plugin/migrate/process/d7/FieldSettings.php index bcf0ed0e91e57f6043de37cf9a0514ab4e1b7896..125a8e273a01997b5889f2737a2ed85ab0845e7a 100644 --- a/core/modules/field/src/Plugin/migrate/process/d7/FieldSettings.php +++ b/core/modules/field/src/Plugin/migrate/process/d7/FieldSettings.php @@ -7,6 +7,9 @@ use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; +/** + * Determines the field settings values for a field. + */ #[MigrateProcess('d7_field_settings')] class FieldSettings extends ProcessPluginBase { diff --git a/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php b/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php index ccd88b412d2c75a4c7780d14519fba1bf24f76c6..eb95cf9e287e7a8a70a0823d63a117c069c45732 100644 --- a/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php +++ b/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php @@ -105,7 +105,11 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $entity_2 = $form_state->get('entity_2'); $entity_2->save(); - $this->messenger()->addStatus($this->t('test_entities @id_1 and @id_2 have been updated.', ['@id_1' => $entity_1->id(), '@id_2' => $entity_2->id()])); + $this->messenger() + ->addStatus($this->t('test_entities @id_1 and @id_2 have been updated.', [ + '@id_1' => $entity_1->id(), + '@id_2' => $entity_2->id(), + ])); } } diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php index d32ed11821ca65dc51ee036cb7cd7ffae34ba908..8c98e6d2d3ad91c70aea439dfb3c145e08891dbd 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php @@ -53,7 +53,10 @@ public function settingsForm(array $form, FormStateInterface $form_state) { */ public function settingsSummary() { $summary = []; - $summary[] = $this->t('@setting: @value', ['@setting' => 'test_formatter_setting', '@value' => $this->getSetting('test_formatter_setting')]); + $summary[] = $this->t('@setting: @value', [ + '@setting' => 'test_formatter_setting', + '@value' => $this->getSetting('test_formatter_setting'), + ]); return $summary; } diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php index b25f4f200cf6371b23e8954a443d16eddd1379f5..bc3339fd550c13bc34bad98c952a6eff064822eb 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php @@ -54,7 +54,10 @@ public function settingsForm(array $form, FormStateInterface $form_state) { */ public function settingsSummary() { $summary = []; - $summary[] = $this->t('@setting: @value', ['@setting' => 'test_formatter_setting_multiple', '@value' => $this->getSetting('test_formatter_setting_multiple')]); + $summary[] = $this->t('@setting: @value', [ + '@setting' => 'test_formatter_setting_multiple', + '@value' => $this->getSetting('test_formatter_setting_multiple'), + ]); return $summary; } diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php index 4fc25b1930790b9c9fdc6dad334d018a995adb45..7082bcc032a125fbb026222a46c5a95106a1c31d 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php @@ -52,7 +52,10 @@ public function settingsForm(array $form, FormStateInterface $form_state) { */ public function settingsSummary() { $summary = []; - $summary[] = $this->t('@setting: @value', ['@setting' => 'test_formatter_setting_additional', '@value' => $this->getSetting('test_formatter_setting_additional')]); + $summary[] = $this->t('@setting: @value', [ + '@setting' => 'test_formatter_setting_additional', + '@value' => $this->getSetting('test_formatter_setting_additional'), + ]); return $summary; } diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php index e9ca1a5d8df973ef5288e7cf743abdffcd27042a..9e89b21e9e772559fb3de22bc22b9b85f208ca9b 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php @@ -129,7 +129,11 @@ public function getConstraints() { 'value' => [ 'TestField' => [ 'value' => -1, - 'message' => $this->t('%name does not accept the value @value.', ['%name' => $this->getFieldDefinition()->getLabel(), '@value' => -1]), + 'message' => $this->t('%name does not accept the value @value.', [ + '%name' => $this->getFieldDefinition() + ->getLabel(), + '@value' => -1, + ]), ], ], ]); diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php index c80449feea4a6ca823f26abd2e6e0a7b6c7ebee2..27ce0b32b0959b364e97f92a11028fd2ad2fe8d0 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php @@ -57,7 +57,10 @@ public function settingsForm(array $form, FormStateInterface $form_state) { */ public function settingsSummary() { $summary = []; - $summary[] = $this->t('@setting: @value', ['@setting' => 'test_widget_setting', '@value' => $this->getSetting('test_widget_setting')]); + $summary[] = $this->t('@setting: @value', [ + '@setting' => 'test_widget_setting', + '@value' => $this->getSetting('test_widget_setting'), + ]); return $summary; } diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php index 5f9f29627f5bd5542eccb79276cb513cc0615388..8453640d2b3f3cd6eba1b3779315a73e0dd99dfe 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php @@ -58,7 +58,10 @@ public function settingsForm(array $form, FormStateInterface $form_state) { */ public function settingsSummary() { $summary = []; - $summary[] = $this->t('@setting: @value', ['@setting' => 'test_widget_setting_multiple', '@value' => $this->getSetting('test_widget_setting_multiple')]); + $summary[] = $this->t('@setting: @value', [ + '@setting' => 'test_widget_setting_multiple', + '@value' => $this->getSetting('test_widget_setting_multiple'), + ]); return $summary; } diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php index 58272b6eca8ce611bdd5969c35f995cad1d558a5..2570f2a73e97130489d60fc33d0364d53ad94b03 100644 --- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php @@ -384,7 +384,7 @@ public function testMultipleTargetBundles(): void { * Creates a new Entity Reference fields with a given target type. * * @param string $target_type - * The name of the target type + * The name of the target type. * @param string[] $bundles * A list of bundle IDs. Defaults to []. * diff --git a/core/modules/field/tests/src/Functional/FieldDefaultValueCallbackTest.php b/core/modules/field/tests/src/Functional/FieldDefaultValueCallbackTest.php index e61cb2d54a0bf54fe61f968a07b95b7bcb541d8a..471edd08fbb0678842f887720478c1e345bb0c64 100644 --- a/core/modules/field/tests/src/Functional/FieldDefaultValueCallbackTest.php +++ b/core/modules/field/tests/src/Functional/FieldDefaultValueCallbackTest.php @@ -54,6 +54,9 @@ protected function setUp(): void { } + /** + * Tests the default value callback functionality for fields. + */ public function testDefaultValueCallbackForm(): void { // Create a field and storage for checking. FieldStorageConfig::create([ diff --git a/core/modules/field/tests/src/Functional/FieldTestBase.php b/core/modules/field/tests/src/Functional/FieldTestBase.php index 112cbb827a1c4ca19dc5c3212b588b5c4e2883d8..1199eab5531016a5ce61eb05f55a775d72205dda 100644 --- a/core/modules/field/tests/src/Functional/FieldTestBase.php +++ b/core/modules/field/tests/src/Functional/FieldTestBase.php @@ -39,7 +39,7 @@ public function _generateTestFieldValues($cardinality) { * @param \Drupal\Core\Entity\EntityInterface $entity * The entity to test. * @param string $field_name - * The name of the field to test + * The name of the field to test. * @param array $expected_values * The array of expected values. * @param string $langcode diff --git a/core/modules/field/tests/src/Functional/FormTest.php b/core/modules/field/tests/src/Functional/FormTest.php index f88acfe0647e258b7a8f3b1431c161bad01b7f82..e5c8838f353d30dc85e5cffa7d33b4f29f930478 100644 --- a/core/modules/field/tests/src/Functional/FormTest.php +++ b/core/modules/field/tests/src/Functional/FormTest.php @@ -99,6 +99,9 @@ protected function setUp(): void { ]; } + /** + * Tests the single-value field form functionality. + */ public function testFieldFormSingle(): void { $field_storage = $this->fieldStorageSingle; $field_name = $field_storage['field_name']; @@ -209,6 +212,9 @@ public function testFieldFormDefaultValue(): void { $this->assertTrue($entity->{$field_name}->isEmpty(), 'Field is now empty.'); } + /** + * Tests the required single-value field form. + */ public function testFieldFormSingleRequired(): void { $field_storage = $this->fieldStorageSingle; $field_name = $field_storage['field_name']; @@ -249,6 +255,9 @@ public function testFieldFormSingleRequired(): void { $this->assertSession()->pageTextContains("{$this->field['label']} field is required."); } + /** + * Tests the unlimited-value field form. + */ public function testFieldFormUnlimited(): void { $field_storage = $this->fieldStorageUnlimited; $field_name = $field_storage['field_name']; diff --git a/core/modules/field/tests/src/Functional/Views/FieldTestBase.php b/core/modules/field/tests/src/Functional/Views/FieldTestBase.php index 049b3d69584aeb8a6f87f5bb74b4882e5e7e268e..7953abcf7459bb71aeb59a8900a662c580fc0bbc 100644 --- a/core/modules/field/tests/src/Functional/Views/FieldTestBase.php +++ b/core/modules/field/tests/src/Functional/Views/FieldTestBase.php @@ -53,6 +53,9 @@ protected function setUp($import_test_views = TRUE, $modules = ['field_test_view ])->save(); } + /** + * Sets up field storages for testing. + */ public function setUpFieldStorages($amount = 3, $type = 'string') { // Create three fields. $field_names = []; @@ -68,6 +71,9 @@ public function setUpFieldStorages($amount = 3, $type = 'string') { return $field_names; } + /** + * Sets up fields for a given bundle. + */ public function setUpFields($bundle = 'page') { foreach ($this->fieldStorages as $key => $field_storage) { $this->fields[$key] = FieldConfig::create([ diff --git a/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php b/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php index 5e2b060e7b4a29e50ce6c36ca3be5618dbe21748..3cdb5be8490517605b55a539a405f12e59181200 100644 --- a/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php +++ b/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php @@ -188,7 +188,7 @@ protected function _generateTestFieldValues($cardinality) { * @param \Drupal\Core\Entity\EntityInterface $entity * The entity to test. * @param string $field_name - * The name of the field to test + * The name of the field to test. * @param array $expected_values * The array of expected values. * @param string $langcode diff --git a/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php b/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php index a69f0b3b772b0e2e88d91950e83f5cd1c95e6d0f..b859835906812368463dce63e4862554a01a92b6 100644 --- a/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php @@ -170,7 +170,7 @@ public function testEnforcedCardinality(): void { * Tests invalid enforced cardinality. * * @param mixed $enforced_cardinality - * Enforced cardinality + * Enforced cardinality. * * @covers ::getCardinality * @dataProvider providerInvalidEnforcedCardinality diff --git a/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php b/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php index 90d08a236d6be06879c435017558d657fd10b291..78532ef5f56c5da7a3179358cba2f6c64ecaf011 100644 --- a/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php +++ b/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php @@ -42,6 +42,9 @@ protected function setUp(): void { } + /** + * Tests that the indentation classes are present in the content type display settings. + */ public function testIndentation(): void { $this->drupalGet('admin/structure/types/manage/page/display'); $this->assertSession()->responseContains('js-indentation indentation'); diff --git a/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php b/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php index ab2baa5d6d0ebb7e8a6a880f210ce9f44a659032..9428031e6dedd828b25031ba133e890fe37a21ed 100644 --- a/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php +++ b/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php @@ -11,6 +11,9 @@ use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * Determines the settings for a Drupal 6 file field. + */ #[MigrateProcess('d6_field_file')] class FieldFile extends ProcessPluginBase implements ContainerFactoryPluginInterface { diff --git a/core/modules/file/tests/file_test/src/FileTestCdn.php b/core/modules/file/tests/file_test/src/FileTestCdn.php index b3796f6f74c851466cd0612610a39213754bf714..f65a3120b616afbbc1c144a241c85b1f186af540 100644 --- a/core/modules/file/tests/file_test/src/FileTestCdn.php +++ b/core/modules/file/tests/file_test/src/FileTestCdn.php @@ -9,12 +9,12 @@ */ enum FileTestCdn: string { - /** + /* * First Cdn. */ case First = 'http://cdn1.example.com'; - /** + /* * Second Cdn. */ case Second = 'http://cdn2.example.com'; diff --git a/core/modules/file/tests/file_test/src/FileTestHelper.php b/core/modules/file/tests/file_test/src/FileTestHelper.php index c478cd0b6a0d5b657939f84e985b8066cce01bfd..9a5bc42dfbd4050e29214cc17faa168fb2fac7a5 100644 --- a/core/modules/file/tests/file_test/src/FileTestHelper.php +++ b/core/modules/file/tests/file_test/src/FileTestHelper.php @@ -118,7 +118,7 @@ public static function setReturn($op, $value): void { * returned. * * @param string|null $filepath - * File path + * File path. * @param bool $reset * (optional) If to reset the internal memory cache. If TRUE is passed, the * first parameter has no effect. Defaults to FALSE. diff --git a/core/modules/filter/src/FilterFormatFormBase.php b/core/modules/filter/src/FilterFormatFormBase.php index 336e49f64062caf01632a22286cc1c8dbab0a399..7e694188e4dcfa7d848b7cb18f15600353e5d210 100644 --- a/core/modules/filter/src/FilterFormatFormBase.php +++ b/core/modules/filter/src/FilterFormatFormBase.php @@ -172,7 +172,7 @@ public function form(array $form, FormStateInterface $form_state) { * Determines if the format already exists. * * @param string $format_id - * The format ID + * The format ID. * * @return bool * TRUE if the format exists, FALSE otherwise. diff --git a/core/modules/filter/tests/src/Kernel/Plugin/migrate/process/FilterSettingsTest.php b/core/modules/filter/tests/src/Kernel/Plugin/migrate/process/FilterSettingsTest.php index 75d2845c4774b8770f872010d4f38c6d90e73cd4..c44651dd6e320ba4a6d4c474b99d6e38c37cf564 100644 --- a/core/modules/filter/tests/src/Kernel/Plugin/migrate/process/FilterSettingsTest.php +++ b/core/modules/filter/tests/src/Kernel/Plugin/migrate/process/FilterSettingsTest.php @@ -43,6 +43,7 @@ public function testTransform($value, $destination_id, $expected_value): void { * The test data provider. * * @return array + * An array of test data. */ public static function dataProvider() { return [ diff --git a/core/modules/help/tests/modules/help_topics_test/src/Hook/HelpTopicsTestHooks.php b/core/modules/help/tests/modules/help_topics_test/src/Hook/HelpTopicsTestHooks.php index a363dc709af71bbdeaa05efb1fb415a0eb843f73..6451ff7d37b98cc38d0f90cef6b45b5386c81997 100644 --- a/core/modules/help/tests/modules/help_topics_test/src/Hook/HelpTopicsTestHooks.php +++ b/core/modules/help/tests/modules/help_topics_test/src/Hook/HelpTopicsTestHooks.php @@ -31,7 +31,8 @@ public function help($route_name, RouteMatchInterface $route_match): ?string { public function helpTopicsInfoAlter(array &$info): void { // To prevent false positive search results limit list to testing topis // only. - $filter = fn(string $key) => str_starts_with($key, 'help_topics_test') || in_array($key, ['help_topics_test_direct_yml', 'help_topics_derivatives:test_derived_topic'], TRUE); + $filter = fn(string $key) => str_starts_with($key, 'help_topics_test') + || in_array($key, ['help_topics_test_direct_yml', 'help_topics_derivatives:test_derived_topic'], TRUE); $info = array_filter($info, $filter, ARRAY_FILTER_USE_KEY); $info['help_topics_test.test']['top_level'] = \Drupal::state()->get('help_topics_test.test:top_level', TRUE); } diff --git a/core/modules/image/src/Plugin/migrate/field/d7/ImageField.php b/core/modules/image/src/Plugin/migrate/field/d7/ImageField.php index 4e81630e675cf758e1bfabf319d42510a1cc2838..c3f419976a0472ced49a872107d5aee36f9a8644 100644 --- a/core/modules/image/src/Plugin/migrate/field/d7/ImageField.php +++ b/core/modules/image/src/Plugin/migrate/field/d7/ImageField.php @@ -6,6 +6,9 @@ use Drupal\migrate_drupal\Attribute\MigrateField; use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase; +/** + * Migrate field plugin for Drupal 7 image fields. + */ #[MigrateField( id: 'image', core: [7], diff --git a/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php b/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php index afe4695687438ed4cf0eef76c2b1b3890e700285..8b15f60acade38846a45fc2507780c2bb52449e5 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php @@ -272,6 +272,7 @@ public static function providerTestEmpty() { * The maximum width and height setting. * * @return array + * List of field settings. */ protected function getFieldSettings($min_resolution, $max_resolution): array { return [ diff --git a/core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageCacheTest.php b/core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageCacheTest.php index 9b3615b99e6aa58415abe23331747e6b7410e683..d239882c460936df5e7eef8a3065a5cba9339f7f 100644 --- a/core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageCacheTest.php +++ b/core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageCacheTest.php @@ -145,7 +145,7 @@ public function testInvalidCropValues(): void { * Assert that a given image effect is migrated. * * @param \Drupal\image\ImageEffectPluginCollection $collection - * Collection of effects + * Collection of effects. * @param string $id * Id that should exist in the collection. * @param array $config diff --git a/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php b/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php index 006653f7acfb5fff5bc771108d0edc8be691617b..cbd07fab5ed7bfb0c8ca4e4665a721586331c0d5 100644 --- a/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php +++ b/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php @@ -47,9 +47,9 @@ public function testImageStylesMigration(): void { * @param string $label * The expected image style label. * @param array $expected_effect_plugins - * An array of expected plugins attached to the image style entity + * An array of expected plugins attached to the image style entity. * @param array $expected_effect_config - * An array of expected configuration for each effect in the image style + * An array of expected configuration for each effect in the image style. */ protected function assertEntity(string $id, string $label, array $expected_effect_plugins, array $expected_effect_config): void { $style = ImageStyle::load($id); diff --git a/core/modules/jsonapi/src/JsonApiResource/ResourceIdentifier.php b/core/modules/jsonapi/src/JsonApiResource/ResourceIdentifier.php index 33b63999263d80323ae87993baf4612be2291377..06e125d0474df7afb89207eb7188d9d8a7ef5d28 100644 --- a/core/modules/jsonapi/src/JsonApiResource/ResourceIdentifier.php +++ b/core/modules/jsonapi/src/JsonApiResource/ResourceIdentifier.php @@ -390,7 +390,7 @@ public static function fromEntity(EntityInterface $entity) { * The entity reference item for which to determine the entity property * name. * - * @return string + * @return string|null * The property name which has an entity as its value. */ protected static function getDataReferencePropertyName(EntityReferenceItem $item) { @@ -399,6 +399,7 @@ protected static function getDataReferencePropertyName(EntityReferenceItem $item return $property_name; } } + return NULL; } /** diff --git a/core/modules/jsonapi/tests/modules/jsonapi_test_meta_events/src/EventSubscriber/MetaEventSubscriber.php b/core/modules/jsonapi/tests/modules/jsonapi_test_meta_events/src/EventSubscriber/MetaEventSubscriber.php index a28716f0340809daafd449be17d969295f44e662..3315e025fcd9786ecb8e7d3087b9a6686490bb3d 100644 --- a/core/modules/jsonapi/tests/modules/jsonapi_test_meta_events/src/EventSubscriber/MetaEventSubscriber.php +++ b/core/modules/jsonapi/tests/modules/jsonapi_test_meta_events/src/EventSubscriber/MetaEventSubscriber.php @@ -29,8 +29,6 @@ public static function getSubscribedEvents(): array { /** * @param \Drupal\jsonapi\Events\CollectResourceObjectMetaEvent $event * Event to be processed. - * - * @return void */ public function addResourceObjectMeta(CollectResourceObjectMetaEvent $event): void { $config = \Drupal::state()->get('jsonapi_test_meta_events.object_meta', [ @@ -72,8 +70,6 @@ public function addResourceObjectMeta(CollectResourceObjectMetaEvent $event): vo /** * @param \Drupal\jsonapi\Events\CollectRelationshipMetaEvent $event * Event to be processed. - * - * @return void */ public function addRelationshipMeta(CollectRelationshipMetaEvent $event): void { $config = \Drupal::state()->get('jsonapi_test_meta_events.relationship_meta', [ @@ -138,6 +134,8 @@ public function addRelationshipMeta(CollectRelationshipMetaEvent $event): void { /** * @return string + * The value 'yes' if the current user has an admin role, 'no' otherwise. + * * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ diff --git a/core/modules/jsonapi/tests/src/Functional/CommentExtrasTest.php b/core/modules/jsonapi/tests/src/Functional/CommentExtrasTest.php index 4de862de7fc5fc9bc80b2df56625c28d0ffbcb15..847dd1aa86f2fd4a0e54c09bd4f3aabf433bf19e 100644 --- a/core/modules/jsonapi/tests/src/Functional/CommentExtrasTest.php +++ b/core/modules/jsonapi/tests/src/Functional/CommentExtrasTest.php @@ -16,6 +16,9 @@ */ class CommentExtrasTest extends CommentTest { + /** + * {@inheritdoc} + */ public function setUp(): void { // Don't run any test methods from CommentTest because those will get run // for CommentTest itself. diff --git a/core/modules/jsonapi/tests/src/Functional/EntityTestComputedFieldTest.php b/core/modules/jsonapi/tests/src/Functional/EntityTestComputedFieldTest.php index 14d00fcbef6c1d332b1b448288fb2b6257e85231..fa275bfe76bd54e96ff2190ea48d7e427abc3f0d 100644 --- a/core/modules/jsonapi/tests/src/Functional/EntityTestComputedFieldTest.php +++ b/core/modules/jsonapi/tests/src/Functional/EntityTestComputedFieldTest.php @@ -170,6 +170,9 @@ protected function getSparseFieldSets(): array { ])); } + /** + * Retrieves the expected cache contexts for the response. + */ protected function getExpectedCacheContexts(?array $sparse_fieldset = NULL) { $cache_contexts = parent::getExpectedCacheContexts($sparse_fieldset); if ($sparse_fieldset === NULL || in_array('computed_test_cacheable_string_field', $sparse_fieldset)) { @@ -179,6 +182,9 @@ protected function getExpectedCacheContexts(?array $sparse_fieldset = NULL) { return $cache_contexts; } + /** + * Retrieves the expected cache tags for the response. + */ protected function getExpectedCacheTags(?array $sparse_fieldset = NULL) { $expected_cache_tags = parent::getExpectedCacheTags($sparse_fieldset); if ($sparse_fieldset === NULL || in_array('computed_test_cacheable_string_field', $sparse_fieldset)) { diff --git a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php index 813c218bb8aa5a05999fb2d8649e2633d4a9b97a..43cd406f61bc3f0636bb80355830034425140e2e 100644 --- a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php +++ b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php @@ -328,6 +328,9 @@ protected function setUpFields(EntityInterface $entity, UserInterface $account): return $this->resaveEntity($entity, $account); } + /** + * Reloads and updates an entity with test field values before saving it. + */ protected function resaveEntity(EntityInterface $entity, AccountInterface $account): EntityInterface { // Reload entity so that it has the new field. $reloaded_entity = $this->entityLoadUnchanged($entity->id()); diff --git a/core/modules/jsonapi/tests/src/Kernel/Normalizer/LinkCollectionNormalizerTest.php b/core/modules/jsonapi/tests/src/Kernel/Normalizer/LinkCollectionNormalizerTest.php index a4cdb4f5444c568835bd64b83e0063810500fb53..2d15edb34802b2f6264d53c6da16582a618e645f 100644 --- a/core/modules/jsonapi/tests/src/Kernel/Normalizer/LinkCollectionNormalizerTest.php +++ b/core/modules/jsonapi/tests/src/Kernel/Normalizer/LinkCollectionNormalizerTest.php @@ -169,6 +169,7 @@ public function testLinkAccess($current_user_id, $edit_form_uid, $expected_link_ * Provides test cases for testing link access checking. * * @return array[] + * An array of test cases for testLinkAccess(). */ public static function linkAccessTestData() { return [ diff --git a/core/modules/jsonapi/tests/src/Traits/JsonApiJsonSchemaTestTrait.php b/core/modules/jsonapi/tests/src/Traits/JsonApiJsonSchemaTestTrait.php index 5c073834e99835e04267f83877e4618b9742710d..793710d1d4eb9ac26c72bc8f6880785919fb5fc1 100644 --- a/core/modules/jsonapi/tests/src/Traits/JsonApiJsonSchemaTestTrait.php +++ b/core/modules/jsonapi/tests/src/Traits/JsonApiJsonSchemaTestTrait.php @@ -11,6 +11,9 @@ use JsonSchema\Uri\UriRetriever; use JsonSchema\Validator; +/** + * Support methods for testing JSON API schema. + */ trait JsonApiJsonSchemaTestTrait { use JsonSchemaTestTrait { diff --git a/core/modules/language/src/LanguageNegotiationMethodManager.php b/core/modules/language/src/LanguageNegotiationMethodManager.php index 849e846c768043b4b077e19ba88f15b85c5bcdce..b04c25be111369ebfdabeb8f3a1c6b1aa201f20b 100644 --- a/core/modules/language/src/LanguageNegotiationMethodManager.php +++ b/core/modules/language/src/LanguageNegotiationMethodManager.php @@ -19,9 +19,9 @@ class LanguageNegotiationMethodManager extends DefaultPluginManager { * An object that implements \Traversable which contains the root paths * keyed by the corresponding namespace to look for plugin implementations. * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend - * An object that implements CacheBackendInterface + * An object that implements CacheBackendInterface. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * An object that implements ModuleHandlerInterface + * An object that implements ModuleHandlerInterface. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) { parent::__construct('Plugin/LanguageNegotiation', $namespaces, $module_handler, LanguageNegotiationMethodInterface::class, LanguageNegotiation::class, 'Drupal\language\Annotation\LanguageNegotiation'); diff --git a/core/modules/language/tests/language_events_test/src/EventSubscriber.php b/core/modules/language/tests/language_events_test/src/EventSubscriber.php index 3dc455629b50783449f3b078e1029d39dd14c56b..806dd621afe02815b2d7b2d8116ffab66e521dee 100644 --- a/core/modules/language/tests/language_events_test/src/EventSubscriber.php +++ b/core/modules/language/tests/language_events_test/src/EventSubscriber.php @@ -9,6 +9,9 @@ use Drupal\language\Config\LanguageConfigOverrideCrudEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +/** + * Event subscriber for testing Language events. + */ class EventSubscriber implements EventSubscriberInterface { /** diff --git a/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php b/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php index 95d72569ee60bee14d9f366f8cac04894419f4c0..12697f62b966a4ef92f1953d053372728dc61a28 100644 --- a/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php +++ b/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php @@ -23,6 +23,9 @@ class LanguageBlockSettingsVisibilityTest extends BrowserTestBase { */ protected $defaultTheme = 'stark'; + /** + * Tests languages displayed in the language switcher. + */ public function testUnnecessaryLanguageSettingsVisibility(): void { $admin_user = $this->drupalCreateUser([ 'administer languages', diff --git a/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php b/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php index 14e55ed1b5a8d88624dfa6f9d2fe56c7977641d3..a1a760a48bb7bf70f0ed88a0b04ea0b79be4390d 100644 --- a/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php +++ b/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php @@ -45,6 +45,7 @@ protected function setUp(): void { * Returns the configurable language manager. * * @return \Drupal\language\ConfigurableLanguageManager + * The language manager. */ protected function languageManager() { return $this->container->get('language_manager'); diff --git a/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php index 49a8671d48086ea188e31f04bc3f915b1dd5e96b..858685053db6381c92cfae788dfe9981c9f24615 100644 --- a/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php @@ -414,6 +414,9 @@ public function testUILanguageNegotiation(): void { } } + /** + * Runs common tests for the language user interface. + */ protected function doRunTest($test): void { $test += ['path_options' => []]; if (!empty($test['language_negotiation'])) { diff --git a/core/modules/language/tests/src/Unit/Plugin/LanguageNegotiation/LanguageNegotiationTestBase.php b/core/modules/language/tests/src/Unit/Plugin/LanguageNegotiation/LanguageNegotiationTestBase.php index e35731c47b9fa315bbe6ba78c05edf1a656fa2bb..07d825127e4258cc618c1cd31dcc3c078dcc227b 100644 --- a/core/modules/language/tests/src/Unit/Plugin/LanguageNegotiation/LanguageNegotiationTestBase.php +++ b/core/modules/language/tests/src/Unit/Plugin/LanguageNegotiation/LanguageNegotiationTestBase.php @@ -26,6 +26,7 @@ abstract protected function getPluginClass(): string; * Creates a @LanguageNegotiation plugin using the factory ::create method. * * @return \Drupal\language\LanguageNegotiationMethodInterface + * The created language negotiation plugin. */ protected function createLanguageNegotiationPlugin(array $configuration = [], $plugin_definition = NULL) { $class = $this->getPluginClass(); diff --git a/core/modules/layout_builder/tests/src/Kernel/SectionListTraitTest.php b/core/modules/layout_builder/tests/src/Kernel/SectionListTraitTest.php index 58a5a1e6e53d7f7580b53961c984914c74edd2d4..e882777b75db6b32604a936310d89992350ef227 100644 --- a/core/modules/layout_builder/tests/src/Kernel/SectionListTraitTest.php +++ b/core/modules/layout_builder/tests/src/Kernel/SectionListTraitTest.php @@ -33,6 +33,9 @@ public function testAddBlankSection(): void { } +/** + * Test item list class for layout section fields. + */ class TestSectionList implements SectionListInterface { use SectionListTrait { diff --git a/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php b/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php index 7768658940e39ade3a8fb02e5c5db99a067709b2..62df6192c8256f8dcc5f72bbf70e0beb278389cd 100644 --- a/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php @@ -6,6 +6,9 @@ use Drupal\migrate_drupal\Attribute\MigrateField; use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase; +/** + * Migrate field plugin for Drupal 6 link fields. + */ #[MigrateField( id: 'link', core: [6], diff --git a/core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php b/core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php index c1c9104e298b24962c87aa97c5dda06f15793616..159865cc8ea07bbaf6f97851cd53c7a1b7dec948 100644 --- a/core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php +++ b/core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php @@ -67,6 +67,9 @@ protected function setUp($import_test_views = TRUE, $modules = ['link_test_views } + /** + * Tests the link views tokens. + */ public function testLinkViewsTokens(): void { // Array of URI's to test. $uris = [ diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 69bafff84c4b83641c211a0a0965fcd0c72929ce..0ad1941d816986d2866f0ac66cbe4f539e331614 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -898,7 +898,7 @@ function _locale_invalidate_js($langcode = NULL) { } /** - * (Re-)Creates the JavaScript translation file for a language. + * Creates or recreates the JavaScript translation file for a language. * * @param string|null $langcode * (optional) The language that the translation file should be (re)created diff --git a/core/modules/locale/src/LocaleConfigManager.php b/core/modules/locale/src/LocaleConfigManager.php index a248d2a8c2d743e0ba8c977cea7e8b3a8a52cd32..fd923da2d6ab2c27685d83e9e42a75bb28aecc72 100644 --- a/core/modules/locale/src/LocaleConfigManager.php +++ b/core/modules/locale/src/LocaleConfigManager.php @@ -106,7 +106,7 @@ class LocaleConfigManager { * @param \Drupal\locale\StringStorageInterface $locale_storage * The locale storage to use for reading string translations. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The configuration factory + * The configuration factory. * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config * The typed configuration manager. * @param \Drupal\language\ConfigurableLanguageManagerInterface $language_manager diff --git a/core/modules/locale/src/LocaleDefaultConfigStorage.php b/core/modules/locale/src/LocaleDefaultConfigStorage.php index a2979d6f872309d7ed1622f0fbede9933452e7e9..0f0b00a5458f838061059527e03d232217215511 100644 --- a/core/modules/locale/src/LocaleDefaultConfigStorage.php +++ b/core/modules/locale/src/LocaleDefaultConfigStorage.php @@ -117,7 +117,7 @@ public function listAll() { * Get all configuration names and folders for a list of modules or themes. * * @param string $type - * Type of components: 'module' | 'theme' | 'profile' + * Type of components: 'module' | 'theme' | 'profile'. * @param array $list * Array of theme or module names. * diff --git a/core/modules/locale/src/StringDatabaseStorage.php b/core/modules/locale/src/StringDatabaseStorage.php index 74e94fca5d160ee85be61e572144ec962f51f38b..f023d1968ae765329a9f649a1cd280831c6807fb 100644 --- a/core/modules/locale/src/StringDatabaseStorage.php +++ b/core/modules/locale/src/StringDatabaseStorage.php @@ -268,7 +268,7 @@ protected function dbFieldTable($field) { * @param \Drupal\locale\StringInterface $string * The string object. * - * @return string + * @return string|null * The table name. */ protected function dbStringTable($string) { @@ -278,6 +278,7 @@ protected function dbStringTable($string) { elseif ($string->isTranslation()) { return 'locales_target'; } + return NULL; } /** diff --git a/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php b/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php index c45087d40bb2d3523afe5f0bb8a6c2c93f9806a7..eb59ced8042470079c9173fccf2f7fe14a2148fd 100644 --- a/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php @@ -27,6 +27,9 @@ class LocaleJavascriptTranslationTest extends BrowserTestBase { */ protected $defaultTheme = 'stark'; + /** + * @covers ::\_locale_parse_js_file + */ public function testFileParsing(): void { // This test is for ensuring that the regular expression in diff --git a/core/modules/locale/tests/src/Functional/LocaleUpdateDevelopmentReleaseTest.php b/core/modules/locale/tests/src/Functional/LocaleUpdateDevelopmentReleaseTest.php index 6988c62cec13858a589f86d39f51b478f5ba578a..0f0bb3bac340630feeda21ef82800bcc07f30bc6 100644 --- a/core/modules/locale/tests/src/Functional/LocaleUpdateDevelopmentReleaseTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleUpdateDevelopmentReleaseTest.php @@ -40,6 +40,9 @@ protected function setUp(): void { $this->submitForm(['predefined_langcode' => 'hu'], 'Add language'); } + /** + * @covers ::\locale_translation_build_projects + */ public function testLocaleUpdateDevelopmentRelease(): void { $projects = locale_translation_build_projects(); $this->assertEquals('8.0.x', $projects['drupal']->info['version'], 'The branch of the core dev release.'); diff --git a/core/modules/media/src/Annotation/MediaSource.php b/core/modules/media/src/Annotation/MediaSource.php index 12d940922a12ec769c71a927e33af51144610721..cd9c2347fc19b5cc08f92c0bf0a89d9938fd300e 100644 --- a/core/modules/media/src/Annotation/MediaSource.php +++ b/core/modules/media/src/Annotation/MediaSource.php @@ -104,7 +104,7 @@ class MediaSource extends Plugin { public $thumbnail_height_metadata_attribute = 'thumbnail_height'; /** - * (optional) The metadata attribute name to provide the thumbnail alt. + * The metadata attribute name to provide the thumbnail alt. * * "Thumbnail" will be used if the attribute name is not provided. * @@ -113,7 +113,7 @@ class MediaSource extends Plugin { public $thumbnail_alt_metadata_attribute; /** - * (optional) The metadata attribute name to provide the thumbnail title. + * The metadata attribute name to provide the thumbnail title. * * The name of the media item will be used if the attribute name is not * provided. diff --git a/core/modules/media/tests/src/Functional/FieldFormatter/OEmbedFormatterTest.php b/core/modules/media/tests/src/Functional/FieldFormatter/OEmbedFormatterTest.php index 88c2cbf8e01dc126f834b2d825c07f748b1e59f2..80d0a653d162ea7ec9a922cf89bb898cd3db0e4e 100644 --- a/core/modules/media/tests/src/Functional/FieldFormatter/OEmbedFormatterTest.php +++ b/core/modules/media/tests/src/Functional/FieldFormatter/OEmbedFormatterTest.php @@ -58,6 +58,7 @@ protected function setUp(): void { * @see ::testRender() * * @return array + * An array of test data. */ public static function providerRender() { return [ diff --git a/core/modules/media/tests/src/Functional/ResourceFetcherTest.php b/core/modules/media/tests/src/Functional/ResourceFetcherTest.php index ec327a73ac73c8fcbd8da891499d2c8ace7f4545..8542b3a2a4dbb58025992d6506cea6b087f20435 100644 --- a/core/modules/media/tests/src/Functional/ResourceFetcherTest.php +++ b/core/modules/media/tests/src/Functional/ResourceFetcherTest.php @@ -38,6 +38,7 @@ protected function setUp(): void { * Data provider for testFetchResource(). * * @return array + * An array of test data. */ public static function providerFetchResource() { return [ diff --git a/core/modules/media/tests/src/Functional/UrlResolverTest.php b/core/modules/media/tests/src/Functional/UrlResolverTest.php index bbd12372a3f2d2d781ca974f9251fbdc9a1a369e..e6629104f46b037410f2b97eebe05cf3d78366c2 100644 --- a/core/modules/media/tests/src/Functional/UrlResolverTest.php +++ b/core/modules/media/tests/src/Functional/UrlResolverTest.php @@ -39,6 +39,7 @@ protected function setUp(): void { * @see ::testEndpointMatching() * * @return array + * An array of test data. */ public static function providerEndpointMatching() { return [ @@ -103,6 +104,7 @@ public function testResourceUrlAlterHook(): void { * @see ::testUrlDiscovery() * * @return array + * An array of test data. */ public static function providerUrlDiscovery() { return [ diff --git a/core/modules/media/tests/src/Kernel/MediaThumbnailFormatterTest.php b/core/modules/media/tests/src/Kernel/MediaThumbnailFormatterTest.php index e7f6ee635b556c98a00b3d20c1473b32ddfdbdf8..124d3f490cfb16cce2be2727b66fc5f65dc63062 100644 --- a/core/modules/media/tests/src/Kernel/MediaThumbnailFormatterTest.php +++ b/core/modules/media/tests/src/Kernel/MediaThumbnailFormatterTest.php @@ -91,6 +91,7 @@ public function testSettingsSummary(array $settings, array $expected_summary): v * Data provider for testSettingsSummary(). * * @return array[] + * An array of test data. */ public static function providerTestSettingsSummary(): array { return [ diff --git a/core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php b/core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php index 050050004713047339f603245c1a67f800761b33..76b2523c56853cd9b724dcfa9d146cde346a87a3 100644 --- a/core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php +++ b/core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php @@ -28,6 +28,7 @@ class OEmbedIframeControllerTest extends MediaKernelTestBase { * Data provider for testBadHashParameter(). * * @return array + * An array of test cases.OffCanvasDialogTest.php */ public static function providerBadHashParameter() { return [ diff --git a/core/modules/media/tests/src/Kernel/ProviderRepositoryTest.php b/core/modules/media/tests/src/Kernel/ProviderRepositoryTest.php index c8ed11cdf4434224d79816bb98b129bdf8e28c5e..1fff55829bfcb51962027d68a4f79fd7c99f8b09 100644 --- a/core/modules/media/tests/src/Kernel/ProviderRepositoryTest.php +++ b/core/modules/media/tests/src/Kernel/ProviderRepositoryTest.php @@ -43,6 +43,7 @@ public function testEmptyProviderList($content): void { * @see ::testEmptyProviderList() * * @return array + * An array of test cases. */ public static function providerEmptyProviderList() { return [ @@ -77,6 +78,7 @@ public function testNonExistingProviderDatabase($providers_url, $exception_messa * @see ::testEmptyProviderList() * * @return array + * An array of test cases. */ public static function providerNonExistingProviderDatabase() { return [ diff --git a/core/modules/media/tests/src/Traits/OEmbedTestTrait.php b/core/modules/media/tests/src/Traits/OEmbedTestTrait.php index 273b2513301abb19c2520af702cbd96c92537bf5..b57de1350459e10d1434df0903003fac6b61ed54 100644 --- a/core/modules/media/tests/src/Traits/OEmbedTestTrait.php +++ b/core/modules/media/tests/src/Traits/OEmbedTestTrait.php @@ -17,6 +17,7 @@ trait OEmbedTestTrait { * Returns the relative path to the oEmbed fixtures directory. * * @return string + * The relative path to the oEmbed fixtures directory. */ protected function getFixturesDirectory(): string { return \Drupal::service('extension.list.module')->getPath('media') . '/tests/fixtures/oembed'; @@ -26,6 +27,7 @@ protected function getFixturesDirectory(): string { * Returns the absolute URL of the oEmbed fixtures directory. * * @return string + * The absolute URL of the oEmbed fixtures directory. */ protected function getFixturesUrl(): string { return $this->baseUrl . '/' . $this->getFixturesDirectory(); diff --git a/core/modules/media/tests/src/Unit/IFrameUrlHelperTest.php b/core/modules/media/tests/src/Unit/IFrameUrlHelperTest.php index cd384efb2b4d0a41709b35b9ae1811bf6657bcff..389fb37c23d2caa186f54ffa3f6f4125b39bdcc7 100644 --- a/core/modules/media/tests/src/Unit/IFrameUrlHelperTest.php +++ b/core/modules/media/tests/src/Unit/IFrameUrlHelperTest.php @@ -22,6 +22,7 @@ class IFrameUrlHelperTest extends UnitTestCase { * @see ::testIsSecure() * * @return array + * An array of test data. */ public static function providerIsSecure() { return [ diff --git a/core/modules/migrate/src/Event/EventBase.php b/core/modules/migrate/src/Event/EventBase.php index b999de229c44ea0cac9fed79eb00b999324fed36..0ea16346c9bef4703c2c17c1a77c395588282817 100644 --- a/core/modules/migrate/src/Event/EventBase.php +++ b/core/modules/migrate/src/Event/EventBase.php @@ -6,6 +6,9 @@ use Drupal\migrate\MigrateMessageInterface; use Drupal\Component\EventDispatcher\Event; +/** + * Base class for migration events. + */ class EventBase extends Event { /** diff --git a/core/modules/migrate/src/Event/MigrateIdMapMessageEvent.php b/core/modules/migrate/src/Event/MigrateIdMapMessageEvent.php index 5aa830acf5481160144ade062ed63c9bcdb4a5d3..b0e200bb231813cd99308e10f2aaa63f4ebe66c4 100644 --- a/core/modules/migrate/src/Event/MigrateIdMapMessageEvent.php +++ b/core/modules/migrate/src/Event/MigrateIdMapMessageEvent.php @@ -46,7 +46,7 @@ class MigrateIdMapMessageEvent extends Event { * @param array $source_id_values * Values represent the source ID. * @param string $message - * The message + * The message. * @param int $level * Severity level (one of the MigrationInterface::MESSAGE_* constants). */ diff --git a/core/modules/migrate/src/MigrateBuildDependencyInterface.php b/core/modules/migrate/src/MigrateBuildDependencyInterface.php index d5a900d70de1c5b8db775a6bdcd0dd7e641808c4..252c48179c512475b81552e8e16f91e1c5d61fa2 100644 --- a/core/modules/migrate/src/MigrateBuildDependencyInterface.php +++ b/core/modules/migrate/src/MigrateBuildDependencyInterface.php @@ -2,6 +2,9 @@ namespace Drupal\migrate; +/** + * Interface for migration plugin manager for building dependencies. + */ interface MigrateBuildDependencyInterface { /** diff --git a/core/modules/migrate/src/MigrateExecutableInterface.php b/core/modules/migrate/src/MigrateExecutableInterface.php index d816bdd8a9168f67f589be90a915b13a1138bfc5..0d78d38c73dcef5c600af5c8d6b4461063b58284 100644 --- a/core/modules/migrate/src/MigrateExecutableInterface.php +++ b/core/modules/migrate/src/MigrateExecutableInterface.php @@ -4,6 +4,9 @@ use Drupal\migrate\Plugin\MigrationInterface; +/** + * Interface for the migration executable. + */ interface MigrateExecutableInterface { /** diff --git a/core/modules/migrate/src/MigrateMessageInterface.php b/core/modules/migrate/src/MigrateMessageInterface.php index efb30da3a2b4c43792cba4c009c995d4d7f8ee22..a19dd13cc0744cce9850ae247f967637a7b8ca02 100644 --- a/core/modules/migrate/src/MigrateMessageInterface.php +++ b/core/modules/migrate/src/MigrateMessageInterface.php @@ -2,6 +2,9 @@ namespace Drupal\migrate; +/** + * Interface for migration messages. + */ interface MigrateMessageInterface { /** diff --git a/core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php b/core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php index 9491f7813fa51098c2ef022c998f66b41b7a6969..3949eb2745a6becd33e1331c5cec5f60db93cc9c 100644 --- a/core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php +++ b/core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php @@ -5,6 +5,9 @@ use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * The migrate entity deriver. + */ class MigrateEntity implements ContainerDeriverInterface { /** diff --git a/core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php b/core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php index 4d16063ad10947abb3ab799da78a333ec6cf0549..6620e7aceae5f97549a864d87e972233bac19dba 100644 --- a/core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php +++ b/core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php @@ -5,6 +5,9 @@ use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * The migrate entity revision deriver. + */ class MigrateEntityRevision implements ContainerDeriverInterface { /** diff --git a/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php b/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php index 382aeb2bb7f5048fcaa0788860b0fb97ad2ab298..403f39f3768c40cb54e16be3e18584ce2ec74cab 100644 --- a/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php +++ b/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php @@ -86,6 +86,9 @@ public function getIds(); * @return array * - Keys: machine names of the fields * - Values: Human-friendly descriptions of the fields. + * + * @throws \Drupal\migrate\MigrateException + * Thrown when the destination plugin is not configured correctly. */ public function fields(); diff --git a/core/modules/migrate/src/Plugin/MigratePluginManagerInterface.php b/core/modules/migrate/src/Plugin/MigratePluginManagerInterface.php index 32564a5c6a769b8e5e66184f484027dc6df1064a..2d21fc34ab6c5fc54e2e891830c52adccd264f96 100644 --- a/core/modules/migrate/src/Plugin/MigratePluginManagerInterface.php +++ b/core/modules/migrate/src/Plugin/MigratePluginManagerInterface.php @@ -4,6 +4,9 @@ use Drupal\Component\Plugin\PluginManagerInterface; +/** + * Interface for the migration plugin manager. + */ interface MigratePluginManagerInterface extends PluginManagerInterface { /** diff --git a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php index b41fe489ce365a35739f1edc946082ba15032e45..ecc6dba4d6da1c29afbc61607a28ef93d5617e09 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php @@ -23,7 +23,8 @@ * * Available configuration keys: * - default_bundle: (optional) The bundle to use for this row if 'bundle' is - * not defined on the row. + * not defined on the row. Setting this also allows the fields() method to + * return bundle fields as well as base fields. * * Examples: * @@ -149,7 +150,7 @@ public function getBundle(Row $row) { * {@inheritdoc} */ public function fields() { - // @todo Implement fields() method. + return []; } /** diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php index 63daca44246044826de163318c4ad5f164fa29ab..0a7409afd259f0daaf83356eadc706adecd3642b 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php @@ -6,6 +6,7 @@ use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Session\AccountSwitcherInterface; @@ -113,6 +114,13 @@ class EntityContentBase extends Entity implements HighestIdInterface, MigrateVal */ protected $accountSwitcher; + /** + * Entity type bundle info. + * + * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface + */ + protected EntityTypeBundleInfoInterface $entityTypeBundleInfo; + /** * Constructs a content entity. * @@ -134,12 +142,19 @@ class EntityContentBase extends Entity implements HighestIdInterface, MigrateVal * The field type plugin manager service. * @param \Drupal\Core\Session\AccountSwitcherInterface $account_switcher * The account switcher service. + * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface|null $entity_type_bundle_info + * The entity type bundle info service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, ?AccountSwitcherInterface $account_switcher = NULL) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, ?AccountSwitcherInterface $account_switcher = NULL, ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL) { parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles); $this->entityFieldManager = $entity_field_manager; $this->fieldTypeManager = $field_type_manager; $this->accountSwitcher = $account_switcher; + if ($entity_type_bundle_info === NULL) { + @trigger_error('Calling ' . __NAMESPACE__ . '\EntityContentBase::__construct() without the $entity_type_bundle_info argument is deprecated in drupal:11.2.0 and will be required in drupal:12.0.0. See https://www.drupal.org/node/3476634', E_USER_DEPRECATED); + $entity_type_bundle_info = \Drupal::service('entity_type.bundle.info'); + } + $this->entityTypeBundleInfo = $entity_type_bundle_info; } /** @@ -156,7 +171,8 @@ public static function create(ContainerInterface $container, array $configuratio array_keys($container->get('entity_type.bundle.info')->getBundleInfo($entity_type)), $container->get('entity_field.manager'), $container->get('plugin.manager.field.field_type'), - $container->get('account_switcher') + $container->get('account_switcher'), + $container->get('entity_type.bundle.info'), ); } @@ -401,4 +417,48 @@ public function getHighestId() { return (int) current($values); } + /** + * {@inheritdoc} + */ + public function fields(): array { + $entity_type = $this->storage->getEntityType(); + // Retrieving fields from a non-fieldable content entity will return a + // LogicException. Return an empty list of fields instead. + if (!$entity_type->entityClassImplements(FieldableEntityInterface::class)) { + return []; + } + + // Try to determine the bundle to use when getting fields. + $bundle_info = $this->entityTypeBundleInfo->getBundleInfo($entity_type->id()); + + if (!empty($this->configuration['default_bundle'])) { + // If the migration destination configuration specifies a default_bundle, + // then use that. + $bundle = $this->configuration['default_bundle']; + + if (!isset($bundle_info[$bundle])) { + throw new MigrateException(sprintf("The default_bundle value '%s' is not a valid bundle for the destination entity type '%s'.", $bundle, $entity_type->id())); + } + } + elseif (count($bundle_info) === 1) { + // If the destination entity type has only one bundle, use that. + $bundle = array_key_first($bundle_info); + } + + if (isset($bundle)) { + // If we have a bundle, get all the fields. + $field_definitions = $this->entityFieldManager->getFieldDefinitions($entity_type->id(), $bundle); + } + else { + // Without a bundle, we can only get the base fields. + $field_definitions = $this->entityFieldManager->getBaseFieldDefinitions($entity_type->id()); + } + + $fields = []; + foreach ($field_definitions as $field_name => $definition) { + $fields[$field_name] = (string) $definition->getLabel(); + } + return $fields; + } + } diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php index fcf5148c90df89f50e256437a15f1ea9c363ff22..ec18083c9ef7e17ad94b44ea251aaf8dcf4a20a4 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php @@ -5,6 +5,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Session\AccountSwitcherInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; @@ -116,11 +117,11 @@ class EntityRevision extends EntityContentBase { /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, AccountSwitcherInterface $account_switcher) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, AccountSwitcherInterface $account_switcher, ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL) { $plugin_definition += [ 'label' => new TranslatableMarkup('@entity_type revisions', ['@entity_type' => $storage->getEntityType()->getSingularLabel()]), ]; - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_field_manager, $field_type_manager, $account_switcher); + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_field_manager, $field_type_manager, $account_switcher, $entity_type_bundle_info); } /** diff --git a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php index 46775c5de0f5b803c1388fcc30ff2ac0646ed4cf..faec03c72cc45d585b3bf603c4ffd4ac1580a09a 100644 --- a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php +++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php @@ -6,6 +6,7 @@ use Drupal\Core\Database\DatabaseException; use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Database\Exception\SchemaTableKeyTooLargeException; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\PluginBase; @@ -208,7 +209,7 @@ public static function create(ContainerInterface $container, array $configuratio * Retrieves the hash of the source identifier values. * * @param array $source_id_values - * The source identifiers + * The source identifiers. * * @return string * A hash containing the hashed values of the source identifiers. @@ -655,7 +656,7 @@ public function lookupDestinationIds(array $source_id_values) { } try { - return $query->execute()->fetchAll(\PDO::FETCH_NUM); + return $query->execute()->fetchAll(FetchAs::List); } catch (DatabaseExceptionWrapper) { // It's possible that the query will cause an exception to be thrown. For diff --git a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php index 05123fe9b780502620401a075d3210aa231fe6bc..40dea1c7a2b362c597f00070659baab189836734 100644 --- a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php @@ -5,6 +5,7 @@ use Drupal\Core\Database\ConnectionNotDefinedException; use Drupal\Core\Database\Database; use Drupal\Core\Database\DatabaseException; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\State\StateInterface; use Drupal\migrate\Exception\RequirementsException; @@ -224,7 +225,7 @@ public function checkRequirements() { * Wrapper for database select. */ protected function select($table, $alias = NULL, array $options = []) { - $options['fetch'] = \PDO::FETCH_ASSOC; + $options['fetch'] = FetchAs::Associative; return $this->getDatabase()->select($table, $alias, $options); } @@ -347,7 +348,7 @@ protected function initializeIterator() { $this->query->range($this->batch * $this->batchSize, $this->batchSize); } $statement = $this->query->execute(); - $statement->setFetchMode(\PDO::FETCH_ASSOC); + $statement->setFetchMode(FetchAs::Associative); return new \IteratorIterator($statement); } diff --git a/core/modules/migrate/tests/src/Kernel/HighWaterTest.php b/core/modules/migrate/tests/src/Kernel/HighWaterTest.php index 28b4f633bfc730e829ad7f448fde0903e4021f8c..402275698bee282cacd4c7c4af8b9d974e74b409 100644 --- a/core/modules/migrate/tests/src/Kernel/HighWaterTest.php +++ b/core/modules/migrate/tests/src/Kernel/HighWaterTest.php @@ -295,6 +295,7 @@ protected function assertNodeDoesNotExist(string $title): void { * Title of the node. * * @return bool + * TRUE if node exists, FALSE otherwise. */ protected function nodeExists($title): bool { $query = \Drupal::entityQuery('node')->accessCheck(FALSE); diff --git a/core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php b/core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php index a21bca9c8682529bd69f96f5e298e02e06239c04..c4f0c4f6229fb56bed67465fe7ff5dca251fc72a 100644 --- a/core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php +++ b/core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php @@ -6,6 +6,8 @@ use Drupal\Core\Entity\EntityFieldManager; use Drupal\entity_test\Entity\EntityTestMul; +use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\KernelTests\KernelTestBase; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\migrate\MigrateExecutable; @@ -28,7 +30,13 @@ class MigrateEntityContentBaseTest extends KernelTestBase { /** * {@inheritdoc} */ - protected static $modules = ['migrate', 'user', 'language', 'entity_test']; + protected static $modules = [ + 'entity_test', + 'field', + 'language', + 'migrate', + 'user', + ]; /** * The storage for entity_test_mul. @@ -56,6 +64,9 @@ protected function setUp(): void { \Drupal::state()->set('entity_test.required_multi_default_field', TRUE); $this->installEntitySchema('entity_test_mul'); + $this->installEntitySchema('entity_test_with_bundle'); + $this->installEntitySchema('entity_test_no_bundle'); + ConfigurableLanguage::createFromLangcode('en')->save(); ConfigurableLanguage::createFromLangcode('fr')->save(); @@ -100,7 +111,8 @@ protected function createDestination(array $configuration): void { [], $this->container->get('entity_field.manager'), $this->container->get('plugin.manager.field.field_type'), - $this->container->get('account_switcher') + $this->container->get('account_switcher'), + $this->container->get('entity_type.bundle.info'), ); } @@ -352,4 +364,84 @@ public function getFieldDefinitions($entity_type_id, $bundle) { $this->createEntityStub('migrate_string_id_entity_test'); } + /** + * Test destination fields() method. + */ + public function testFields(): void { + $entity_type_manager = $this->container->get('entity_type.manager'); + // Create two bundles for the entity_test_with_bundle entity type. + $bundle_storage = $entity_type_manager->getStorage('entity_test_bundle'); + $bundle_storage->create([ + 'id' => 'test_bundle_no_fields', + 'label' => 'Test bundle without fields', + ])->save(); + $bundle_storage->create([ + 'id' => 'test_bundle_with_fields', + 'label' => 'Test bundle with fields', + ])->save(); + + // Create a mock migration and get the destination plugin manager. + $migration = $this->prophesize(MigrationInterface::class)->reveal(); + /** @var \Drupal\migrate\Plugin\MigrateDestinationPluginManager $manager */ + $manager = \Drupal::service('plugin.manager.migrate.destination'); + + // Test with an entity type with no bundles. + $destination_plugin = $manager->createInstance('entity:entity_test_no_bundle', [], $migration); + $fields = $destination_plugin->fields(); + $this->assertArrayHasKey('id', $fields); + // Confirm the test field is not found. + $this->assertArrayNotHasKey('field_text', $fields); + + // Create a text field attached to the entity with no bundles. + FieldStorageConfig::create([ + 'type' => 'string', + 'entity_type' => 'entity_test_no_bundle', + 'field_name' => 'field_text', + ])->save(); + + FieldConfig::create([ + 'entity_type' => 'entity_test_no_bundle', + 'bundle' => 'entity_test_no_bundle', + 'field_name' => 'field_text', + ])->save(); + + // Confirm that the 'field_text' is now found. + $destination_plugin = $manager->createInstance('entity:entity_test_no_bundle', [], $migration); + $fields = $destination_plugin->fields(); + $this->assertArrayHasKey('id', $fields); + $this->assertArrayHasKey('field_text', $fields); + + // Repeat the test with an entity with bundles. + $destination_plugin = $manager->createInstance('entity:entity_test_with_bundle', [], $migration); + $fields = $destination_plugin->fields(); + $this->assertArrayHasKey('id', $fields); + $this->assertArrayNotHasKey('field_text', $fields); + + // Create a text field attached to the entity with bundles. + FieldStorageConfig::create([ + 'type' => 'string', + 'entity_type' => 'entity_test_with_bundle', + 'field_name' => 'field_text', + ])->save(); + + FieldConfig::create([ + 'entity_type' => 'entity_test_with_bundle', + 'bundle' => 'test_bundle_with_fields', + 'field_name' => 'field_text', + ])->save(); + + // Confirm that the 'field_text' is found when the default bundle is set. + $destination_plugin = $manager->createInstance('entity:entity_test_with_bundle', ['default_bundle' => 'test_bundle_with_fields'], $migration); + $fields = $destination_plugin->fields(); + $this->assertArrayHasKey('id', $fields); + $this->assertArrayHasKey('field_text', $fields); + + // Confirm that the 'field_text' is not found when the default bundle is not + // set. + $destination_plugin = $manager->createInstance('entity:entity_test_with_bundle', [], $migration); + $fields = $destination_plugin->fields(); + $this->assertArrayHasKey('id', $fields); + $this->assertArrayNotHasKey('field_text', $fields); + } + } diff --git a/core/modules/migrate/tests/src/Kernel/MigrateSourceTestBase.php b/core/modules/migrate/tests/src/Kernel/MigrateSourceTestBase.php index 7d2a59e5297a9b042ced336f18566cccb4d9ec50..1999e3ad86f4cbdd61b5dd1d7d84df9e8d3bab8b 100644 --- a/core/modules/migrate/tests/src/Kernel/MigrateSourceTestBase.php +++ b/core/modules/migrate/tests/src/Kernel/MigrateSourceTestBase.php @@ -82,6 +82,7 @@ protected function setUp(): void { * Determines the plugin to be tested by reading the class @covers annotation. * * @return string + * The fully qualified class name of the plugin to be tested. */ protected function getPluginClass() { $covers = $this->getTestClassCovers(); diff --git a/core/modules/migrate/tests/src/Kernel/SqlBaseTest.php b/core/modules/migrate/tests/src/Kernel/SqlBaseTest.php index 20477876e9988c5c1abbb4ef64698a51be6e9114..2f5c2a2ceec76a49f482d633855086d4d6ab3022 100644 --- a/core/modules/migrate/tests/src/Kernel/SqlBaseTest.php +++ b/core/modules/migrate/tests/src/Kernel/SqlBaseTest.php @@ -6,6 +6,7 @@ use Drupal\Core\Database\Query\ConditionInterface; use Drupal\Core\Database\Query\SelectInterface; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Database\StatementInterface; use Drupal\migrate\Exception\RequirementsException; use Drupal\Core\Database\Database; @@ -175,7 +176,7 @@ public function testHighWater($high_water = NULL, array $query_result = []): voi } $statement = $this->createMock(StatementInterface::class); - $statement->expects($this->atLeastOnce())->method('setFetchMode')->with(\PDO::FETCH_ASSOC); + $statement->expects($this->atLeastOnce())->method('setFetchMode')->with(FetchAs::Associative); $query = $this->createMock(SelectInterface::class); $query->method('execute')->willReturn($statement); $query->expects($this->atLeastOnce())->method('orderBy')->with('order', 'ASC'); diff --git a/core/modules/migrate/tests/src/Kernel/TrackChangesTest.php b/core/modules/migrate/tests/src/Kernel/TrackChangesTest.php index 03f8d74f20cc81cb948dc31ef63d698ac907a613..fae23fd46b421a0e7ce27a6c8639d793bfd41f8d 100644 --- a/core/modules/migrate/tests/src/Kernel/TrackChangesTest.php +++ b/core/modules/migrate/tests/src/Kernel/TrackChangesTest.php @@ -225,6 +225,7 @@ protected function assertTermDoesNotExist(string $property, string $value): void * Value to evaluate. * * @return bool + * TRUE if term exists, FALSE otherwise. */ protected function termExists($property, $value): bool { $property = $property === 'description' ? 'description__value' : $property; diff --git a/core/modules/migrate/tests/src/Kernel/process/ExtractTest.php b/core/modules/migrate/tests/src/Kernel/process/ExtractTest.php index 6651337f1bf851be73179fccc8b86322bf32c4ae..641b4e5bfa87079fd34ac09ff729fd55bacc8021 100644 --- a/core/modules/migrate/tests/src/Kernel/process/ExtractTest.php +++ b/core/modules/migrate/tests/src/Kernel/process/ExtractTest.php @@ -24,6 +24,7 @@ class ExtractTest extends KernelTestBase { * Returns test migration definition. * * @return array + * The test migration definition. */ public function getDefinition() { return [ diff --git a/core/modules/migrate/tests/src/Kernel/process/HandleMultiplesTest.php b/core/modules/migrate/tests/src/Kernel/process/HandleMultiplesTest.php index c17719d6e1ef21212f99d8d7cc7334a655721bb2..35bda35ba7a2fd6ac29a038488f9251d2a8a8700 100644 --- a/core/modules/migrate/tests/src/Kernel/process/HandleMultiplesTest.php +++ b/core/modules/migrate/tests/src/Kernel/process/HandleMultiplesTest.php @@ -24,6 +24,7 @@ class HandleMultiplesTest extends KernelTestBase { * Provides the test migration definition. * * @return array + * The test migration definition. */ public function getDefinition() { return [ @@ -137,6 +138,7 @@ public function testScalarAndMultipleValues(array $source_data, array $expected_ * Provides the source data with scalar and multiple values. * * @return array + * An array of test cases. */ public static function scalarAndMultipleValuesProviderSource() { return [ diff --git a/core/modules/migrate/tests/src/Kernel/process/SubProcessWithSkipTest.php b/core/modules/migrate/tests/src/Kernel/process/SubProcessWithSkipTest.php index 7d94b673e5e2ef8c2083e794268d10d2570257cf..f3a59aaf36fb9b1f834e157f8d75434e100bb22d 100644 --- a/core/modules/migrate/tests/src/Kernel/process/SubProcessWithSkipTest.php +++ b/core/modules/migrate/tests/src/Kernel/process/SubProcessWithSkipTest.php @@ -24,6 +24,7 @@ class SubProcessWithSkipTest extends KernelTestBase { * Provides the test migration definition. * * @return array + * The test migration definition. */ public function getDefinition() { return [ @@ -110,6 +111,7 @@ public function testSubProcessSkip(string $method, array $expected_data): void { * Data provider for testNotFoundSubProcess(). * * @return array + * The data for the testNotFoundSubProcess() test. */ public static function providerTestSubProcessSkip(): array { return [ diff --git a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php index 95c8b752c91dbc05e3ebd43debc87fec2dc9850f..6b18a1bacb830dff395b6c63e8affa12e263d2d0 100644 --- a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php +++ b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\migrate\Unit\Plugin\migrate\destination; use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Session\AccountSwitcherInterface; use Drupal\migrate\MigrateException; @@ -34,7 +35,8 @@ public function testImport(): void { $bundles, $this->entityFieldManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal(), - $this->prophesize(AccountSwitcherInterface::class)->reveal() + $this->prophesize(AccountSwitcherInterface::class)->reveal(), + $this->prophesize(EntityTypeBundleInfoInterface::class)->reveal(), ); $entity = $this->prophesize(ContentEntityInterface::class); $entity->isValidationRequired() @@ -68,7 +70,8 @@ public function testImportEntityLoadFailure(): void { $bundles, $this->entityFieldManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal(), - $this->prophesize(AccountSwitcherInterface::class)->reveal() + $this->prophesize(AccountSwitcherInterface::class)->reveal(), + $this->prophesize(EntityTypeBundleInfoInterface::class)->reveal(), ); $destination->setEntity(FALSE); $this->expectException(MigrateException::class); @@ -95,7 +98,8 @@ public function testUntranslatable(): void { [], $this->entityFieldManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal(), - $this->prophesize(AccountSwitcherInterface::class)->reveal() + $this->prophesize(AccountSwitcherInterface::class)->reveal(), + $this->prophesize(EntityTypeBundleInfoInterface::class)->reveal(), ); $this->expectException(MigrateException::class); $this->expectExceptionMessage('The "foo" entity type does not support translations.'); diff --git a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityRevisionTest.php b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityRevisionTest.php index 0b7c220dcdddc74abf428053fd4bc0263b943066..610f5dbb5bf5f75618a43da0a4b4e5fff6947381 100644 --- a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityRevisionTest.php +++ b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityRevisionTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\migrate\Unit\Plugin\migrate\destination; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Session\AccountSwitcherInterface; @@ -57,7 +58,8 @@ public function testNoRevisionSupport(): void { [], $this->entityFieldManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal(), - $this->prophesize(AccountSwitcherInterface::class)->reveal() + $this->prophesize(AccountSwitcherInterface::class)->reveal(), + $this->prophesize(EntityTypeBundleInfoInterface::class)->reveal(), ); $this->expectException(MigrateException::class); $this->expectExceptionMessage('The "foo" entity type does not support revisions.'); @@ -86,7 +88,8 @@ public function testUntranslatable(): void { [], $this->entityFieldManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal(), - $this->prophesize(AccountSwitcherInterface::class)->reveal() + $this->prophesize(AccountSwitcherInterface::class)->reveal(), + $this->prophesize(EntityTypeBundleInfoInterface::class)->reveal(), ); $this->expectException(MigrateException::class); $this->expectExceptionMessage('The "foo" entity type does not support translations.'); diff --git a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php index 9883ceb413f07066b8769bc05c7fd085d39ebf0e..5c2258df3d8a938f131495aa5f556a308c0f55ec 100644 --- a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php +++ b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php @@ -7,6 +7,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\RevisionableInterface; use Drupal\Core\Entity\RevisionableStorageInterface; @@ -52,6 +53,11 @@ class EntityRevisionTest extends UnitTestCase { */ protected AccountSwitcherInterface $accountSwitcher; + /** + * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface + */ + protected EntityTypeBundleInfoInterface $entityTypeBundle; + /** * {@inheritdoc} */ @@ -72,6 +78,7 @@ protected function setUp(): void { $this->entityFieldManager = $this->prophesize(EntityFieldManagerInterface::class)->reveal(); $this->fieldTypeManager = $this->prophesize(FieldTypePluginManagerInterface::class)->reveal(); $this->accountSwitcher = $this->prophesize(AccountSwitcherInterface::class)->reveal(); + $this->entityTypeBundle = $this->prophesize(EntityTypeBundleInfoInterface::class)->reveal(); } /** @@ -199,6 +206,7 @@ protected function getEntityRevisionDestination(array $configuration = [], $plug $this->entityFieldManager, $this->fieldTypeManager, $this->accountSwitcher, + $this->entityTypeBundle, ); } diff --git a/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php b/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php index b7f69447ae3653ba5014f8afabda25a67675b905..0c2b729e8b662803da050295c6223b8e53ddeb81 100644 --- a/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php +++ b/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php @@ -47,6 +47,9 @@ public function testImport(): void { } +/** + * Test class used for testing per component entity display. + */ class TestPerComponentEntityDisplay extends ComponentEntityDisplayBase { const MODE_NAME = 'view_mode'; diff --git a/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php b/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php index 2982b5d0d8c3bdde17af839b56168fc82078b402..0ce3f69e6bb328ef4615d67005b1c7debc4c9c37 100644 --- a/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php +++ b/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php @@ -47,6 +47,9 @@ public function testImport(): void { } +/** + * Test class for testing per component entity form display. + */ class TestPerComponentEntityFormDisplay extends PerComponentEntityFormDisplay { const MODE_NAME = 'form_mode'; diff --git a/core/modules/migrate/tests/src/Unit/process/ConcatTest.php b/core/modules/migrate/tests/src/Unit/process/ConcatTest.php index d32d4391f9b8635f08b96c1a61d7a574d07bb916..31eff2be9cb330de545b842de04fcb906e349182 100644 --- a/core/modules/migrate/tests/src/Unit/process/ConcatTest.php +++ b/core/modules/migrate/tests/src/Unit/process/ConcatTest.php @@ -49,6 +49,9 @@ public function testConcatWithDelimiter(): void { } +/** + * Mock class for the concat process plugin. + */ class TestConcat extends Concat { public function __construct() { diff --git a/core/modules/migrate/tests/src/Unit/process/DefaultValueTest.php b/core/modules/migrate/tests/src/Unit/process/DefaultValueTest.php index 1f09bca84297a42dbb553c539be05f7fbfae0447..c6dfbeb776de50c6d5ba830a2145be0324fdc6a7 100644 --- a/core/modules/migrate/tests/src/Unit/process/DefaultValueTest.php +++ b/core/modules/migrate/tests/src/Unit/process/DefaultValueTest.php @@ -31,6 +31,7 @@ public function testDefaultValue($configuration, $expected_value, $value): void * Provides data for the successful lookup test. * * @return array + * An array of test cases. */ public static function defaultValueDataProvider() { return [ diff --git a/core/modules/migrate/tests/src/Unit/process/GetTest.php b/core/modules/migrate/tests/src/Unit/process/GetTest.php index fd3374e2ccf34b0870dfc2e92588bc5757f0814c..b457f850d360fdb9b6991bb99443eb6348c78f0e 100644 --- a/core/modules/migrate/tests/src/Unit/process/GetTest.php +++ b/core/modules/migrate/tests/src/Unit/process/GetTest.php @@ -96,6 +96,7 @@ public function testIntegerValues($source, $expected_value): void { * Provides data for the successful lookup test. * * @return array + * An array of data for the test. */ public static function integerValuesDataProvider() { return [ diff --git a/core/modules/migrate/tests/src/Unit/process/MigrateProcessTestCase.php b/core/modules/migrate/tests/src/Unit/process/MigrateProcessTestCase.php index d625dfc66ee36815b33c7d9121274e6fbbce7170..4ad61abae60047dcded12f78cfc8190e295038ca 100644 --- a/core/modules/migrate/tests/src/Unit/process/MigrateProcessTestCase.php +++ b/core/modules/migrate/tests/src/Unit/process/MigrateProcessTestCase.php @@ -6,6 +6,9 @@ use Drupal\Tests\migrate\Unit\MigrateTestCase; +/** + * Base class for the Migrate module migrate process unit tests. + */ abstract class MigrateProcessTestCase extends MigrateTestCase { /** diff --git a/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php b/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php index ce25ea4d21f20f30f4354465934a5383b94f7737..cd64f935ca1e6e6ec9309a3ebba006cd569f651d 100644 --- a/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php +++ b/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php @@ -5,6 +5,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Database\Database; use Drupal\Core\Database\DatabaseExceptionWrapper; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\migrate\Exception\RequirementsException; use Drupal\migrate\Plugin\RequirementsInterface; @@ -70,7 +71,7 @@ protected function getSystemData(Connection $connection) { $system_data = []; try { $results = $connection->select('system', 's', [ - 'fetch' => \PDO::FETCH_ASSOC, + 'fetch' => FetchAs::Associative, ]) ->fields('s') ->execute(); diff --git a/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManagerInterface.php b/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManagerInterface.php index ec3575910d7d007eecc5afc5615f2893f7c75df5..6bdbba88a1bfb3a373bbbe4a71a6bdfa50dee04a 100644 --- a/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManagerInterface.php +++ b/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManagerInterface.php @@ -5,6 +5,9 @@ use Drupal\migrate\Plugin\MigratePluginManagerInterface; use Drupal\migrate\Plugin\MigrationInterface; +/** + * Interface implemented by plugin manager for migrate field plugins. + */ interface MigrateFieldPluginManagerInterface extends MigratePluginManagerInterface { /** diff --git a/core/modules/migrate_drupal/tests/src/Traits/CreateMigrationsTrait.php b/core/modules/migrate_drupal/tests/src/Traits/CreateMigrationsTrait.php index 25a6ea4237d61bfc0299d7bf70230cf4ccb146f4..3cd89e92ba9e02e3ce7f0278ef88192d436c7b4a 100644 --- a/core/modules/migrate_drupal/tests/src/Traits/CreateMigrationsTrait.php +++ b/core/modules/migrate_drupal/tests/src/Traits/CreateMigrationsTrait.php @@ -4,6 +4,9 @@ namespace Drupal\Tests\migrate_drupal\Traits; +/** + * Test trait that provides instances of Drupal 6 and Drupal 7 migrations. + */ trait CreateMigrationsTrait { /** diff --git a/core/modules/migrate_drupal/tests/src/Traits/CreateTestContentEntitiesTrait.php b/core/modules/migrate_drupal/tests/src/Traits/CreateTestContentEntitiesTrait.php index c43e70191949eda796880e6cb93823518651a6a7..51f3d7fbccfe193e914ad1b3404386843b596a9a 100644 --- a/core/modules/migrate_drupal/tests/src/Traits/CreateTestContentEntitiesTrait.php +++ b/core/modules/migrate_drupal/tests/src/Traits/CreateTestContentEntitiesTrait.php @@ -13,6 +13,7 @@ trait CreateTestContentEntitiesTrait { * Gets required modules. * * @return array + * An array of required modules. */ protected function getRequiredModules(): array { return [ diff --git a/core/modules/mysql/tests/src/Unit/ConnectionTest.php b/core/modules/mysql/tests/src/Unit/ConnectionTest.php index 80104ab2b9777ba7879169594963697a3c9c865e..8865c764e193b0b300c859e92cd6e838ec1f700f 100644 --- a/core/modules/mysql/tests/src/Unit/ConnectionTest.php +++ b/core/modules/mysql/tests/src/Unit/ConnectionTest.php @@ -44,6 +44,7 @@ protected function setUp(): void { * Creates a Connection object for testing. * * @return \Drupal\mysql\Driver\Database\mysql\Connection + * A Connection object. */ private function createConnection(): Connection { $this->pdoStatement @@ -98,6 +99,7 @@ public function testVersionAndIsMariaDb(bool $expected_is_mariadb, string $serve * Provides test data. * * @return array + * An array of test data. */ public static function providerVersionAndIsMariaDb(): array { return [ diff --git a/core/modules/mysql/tests/src/Unit/InstallTasksTest.php b/core/modules/mysql/tests/src/Unit/InstallTasksTest.php index 759271d47174f8fcbb16c31485211a686ccc8ea0..a50a6f010c76fc42a2d50faef81a41e36ddcf34f 100644 --- a/core/modules/mysql/tests/src/Unit/InstallTasksTest.php +++ b/core/modules/mysql/tests/src/Unit/InstallTasksTest.php @@ -36,6 +36,7 @@ protected function setUp(): void { * Creates a Tasks object for testing. * * @return \Drupal\mysql\Driver\Database\mysql\Install\Tasks + * A Tasks object. */ private function createTasks(): Tasks { /** @var \Drupal\mysql\Driver\Database\mysql\Connection $connection */ @@ -73,6 +74,7 @@ protected function t($string, array $args = [], array $options = []) { * Creates a Tasks object for testing, without connection. * * @return \Drupal\mysql\Driver\Database\mysql\Install\Tasks + * A Tasks object. */ private function createTasksNoConnection(): Tasks { return new class() extends Tasks { @@ -116,6 +118,7 @@ public function testNameAndMinimumVersion(bool $is_mariadb, string $expected_nam * Provides test data. * * @return array + * An array of test data. */ public static function providerNameAndMinimumVersion(): array { return [ diff --git a/core/modules/navigation/js/admin-toolbar-wrapper.js b/core/modules/navigation/js/admin-toolbar-wrapper.js index 6c821d8919ddc01f44bd767770b9336a8e1da3cc..c9e2ecb9cae94d2ab273b848d37cddba2d3acd07 100644 --- a/core/modules/navigation/js/admin-toolbar-wrapper.js +++ b/core/modules/navigation/js/admin-toolbar-wrapper.js @@ -28,92 +28,78 @@ */ const SIDEBAR_CONTENT_EVENT = 'toggle-admin-toolbar-content'; - Drupal.behaviors.navigationProcessHtmlListener = { - /** - * Attaches the behavior to the context element. - * - * @param {HTMLElement} context The context element to attach the behavior to. - */ - attach: (context) => { - if (context === document) { - if ( - once( - 'admin-toolbar-document-triggers-listener', - document.documentElement, - ).length - ) { - const doc = document.documentElement; - - // This is special attribute which added to apply css - // with animations and avoid layout shift. - setTimeout(() => { - doc.setAttribute('data-admin-toolbar-transitions', true); - }, 200); - - doc.addEventListener(HTML_TRIGGER_EVENT, (e) => { - // Prevents multiple triggering while transitioning. - const newState = e.detail.state; - const isUserInput = e.detail.manual; - - document.documentElement.setAttribute( - 'data-admin-toolbar', - newState ? 'expanded' : 'collapsed', - ); + if ( + once('admin-toolbar-document-triggers-listener', document.documentElement) + .length + ) { + const doc = document.documentElement; + + // This is special attribute which added to apply css + // with animations and avoid layout shift. + setTimeout(() => { + doc.setAttribute('data-admin-toolbar-transitions', true); + }, 100); + + doc.addEventListener(HTML_TRIGGER_EVENT, (e) => { + // Prevents multiple triggering while transitioning. + const newState = e.detail.state; + const isUserInput = e.detail.manual; + + document.documentElement.setAttribute( + 'data-admin-toolbar', + newState ? 'expanded' : 'collapsed', + ); - // Set [data-admin-toolbar-body-scroll='locked'] - // See css/components/body-scroll-lock.pcss.css. + // Set [data-admin-toolbar-body-scroll='locked'] + // See css/components/body-scroll-lock.pcss.css. - document.documentElement.setAttribute( - 'data-admin-toolbar-body-scroll', - newState ? 'locked' : 'unlocked', - ); + document.documentElement.setAttribute( + 'data-admin-toolbar-body-scroll', + newState ? 'locked' : 'unlocked', + ); - doc.querySelector('.admin-toolbar')?.dispatchEvent( - new CustomEvent(SIDEBAR_CONTENT_EVENT, { - detail: { - state: newState, - }, - }), - ); + doc.querySelector('.admin-toolbar')?.dispatchEvent( + new CustomEvent(SIDEBAR_CONTENT_EVENT, { + detail: { + state: newState, + }, + }), + ); - if (isUserInput) { - document.documentElement.setAttribute( - 'data-admin-toolbar-animating', - true, - ); - } + if (isUserInput) { + document.documentElement.setAttribute( + 'data-admin-toolbar-animating', + true, + ); + } - setTimeout(() => { - document.documentElement.removeAttribute( - 'data-admin-toolbar-animating', - ); - }, 200); + setTimeout(() => { + document.documentElement.removeAttribute( + 'data-admin-toolbar-animating', + ); + }, 200); - Drupal.displace(true); - }); + Drupal.displace(true); + }); - /** - * Initialize Drupal.displace() - * - * We add the displace attribute to a separate full width element because we - * don't want this element to have transitions. Note that this element and the - * navbar share the same exact width. - */ - const initDisplace = () => { - const displaceElement = doc - .querySelector('.admin-toolbar') - ?.querySelector('.admin-toolbar__displace-placeholder'); - const edge = - document.documentElement.dir === 'rtl' ? 'right' : 'left'; - displaceElement?.setAttribute(`data-offset-${edge}`, ''); - Drupal.displace(true); - }; - - initDisplace(); - } - } - }, - }; + /** + * Initialize Drupal.displace() + * + * We add the displace attribute to a separate full width element because we + * don't want this element to have transitions. Note that this element and the + * navbar share the same exact width. + */ + const initDisplace = () => { + const displaceElement = doc + .querySelector('.admin-toolbar') + ?.querySelector('.admin-toolbar__displace-placeholder'); + const edge = document.documentElement.dir === 'rtl' ? 'right' : 'left'; + displaceElement?.setAttribute(`data-offset-${edge}`, ''); + Drupal.displace(true); + }; + + initDisplace(); + } // Any triggers on page. Inside or outside sidebar. // For now button in sidebar + mobile header and background. @@ -146,7 +132,7 @@ localStorage.setItem('Drupal.navigation.sidebarExpanded', toState); }; - if (context === document) { + if (triggers.length) { let firstState = localStorage.getItem('Drupal.navigation.sidebarExpanded') !== 'false'; diff --git a/core/modules/navigation/templates/top-bar-page-actions.html.twig b/core/modules/navigation/templates/top-bar-page-actions.html.twig index c98e8d6a3e08715f807bcc80b7d9307f3d47e63a..2fb8edce610058e35103ecb22f0e71c13ad68e25 100644 --- a/core/modules/navigation/templates/top-bar-page-actions.html.twig +++ b/core/modules/navigation/templates/top-bar-page-actions.html.twig @@ -23,6 +23,7 @@ {% include 'navigation:toolbar-button' with { icon: 'dots', + action: 'More actions'|t, attributes: create_attribute( { 'aria-expanded': 'false', diff --git a/core/modules/navigation/templates/top-bar.html.twig b/core/modules/navigation/templates/top-bar.html.twig index b294ecfaf2062fde91a8bc5c09cd5c2ea7177278..6efdeed523f9323d9425557843b0bade2ba3139d 100644 --- a/core/modules/navigation/templates/top-bar.html.twig +++ b/core/modules/navigation/templates/top-bar.html.twig @@ -13,7 +13,8 @@ */ #} {% set attributes = create_attribute() %} -<div {{ attributes.addClass('top-bar').setAttribute('data-drupal-admin-styles', '') }}> +<aside {{ attributes.addClass('top-bar').setAttribute('data-drupal-admin-styles', '').setAttribute('aria-labelledby', 'top-bar__title') }}> + <h3 id="top-bar__title" class="visually-hidden">{{ 'Administrative top bar'|t }}</h3> <div class="top-bar__content"> <div class="top-bar__tools"> {{- tools -}} @@ -25,4 +26,4 @@ {{- actions -}} </div> </div> -</div> +</aside> diff --git a/core/modules/navigation/tests/navigation_test/src/Plugin/TopBarItem/TopBarItemInstantiation.php b/core/modules/navigation/tests/navigation_test/src/Plugin/TopBarItem/TopBarItemInstantiation.php index dd0a6de715938faac579193cb795e98e21cae882..2ea1b8ad179370712ada0d3b22af7b901f8574ca 100644 --- a/core/modules/navigation/tests/navigation_test/src/Plugin/TopBarItem/TopBarItemInstantiation.php +++ b/core/modules/navigation/tests/navigation_test/src/Plugin/TopBarItem/TopBarItemInstantiation.php @@ -9,6 +9,9 @@ use Drupal\navigation\TopBarItemBase; use Drupal\navigation\TopBarRegion; +/** + * Provides a top bar item plugin for testing the top bar. + */ #[TopBarItem( id: 'test_item', region: TopBarRegion::Actions, diff --git a/core/modules/navigation/tests/src/Nightwatch/Tests/expandCollapseTest.js b/core/modules/navigation/tests/src/Nightwatch/Tests/expandCollapseTest.js index bb19167820c42aa9eb9ba295a6221df8f6c5c79a..dd68f7d7afa20c8f746e831c1a16b8838376076b 100644 --- a/core/modules/navigation/tests/src/Nightwatch/Tests/expandCollapseTest.js +++ b/core/modules/navigation/tests/src/Nightwatch/Tests/expandCollapseTest.js @@ -7,6 +7,7 @@ const selectors = { expanded: '[data-admin-toolbar="expanded"]', collapsed: '[data-admin-toolbar="collapsed"]', }, + clearCacheButton: 'input[data-drupal-selector="edit-clear"]', }; module.exports = { @@ -15,6 +16,7 @@ module.exports = { browser .drupalInstall() .drupalInstallModule('navigation', true) + .drupalInstallModule('big_pipe') .setWindowSize(1220, 800); }, after(browser) { @@ -24,7 +26,8 @@ module.exports = { 'Expand/Collapse': (browser) => { browser.drupalLoginAsAdmin(() => { browser - .drupalRelativeURL('/') + .drupalRelativeURL('/admin/config/development/performance') + .click(selectors.clearCacheButton) .waitForElementPresent( '[data-once="admin-toolbar-document-triggers-listener"]', ) diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index dac7282575fcfbf38076b252a468ec7cd0ae2597..688beef4a5745ced4b5abd03f640d2c84f11d3ab 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -408,8 +408,8 @@ function hook_ranking(): array { * @param array &$context * Various aspects of the context in which the node links are going to be * displayed, with the following keys: - * - 'view_mode': the view mode in which the node is being viewed - * - 'langcode': the language in which the node is being viewed + * - 'view_mode': the view mode in which the node is being viewed. + * - 'langcode': the language in which the node is being viewed. * * @see \Drupal\node\NodeViewBuilder::renderLinks() * @see \Drupal\node\NodeViewBuilder::buildLinks() diff --git a/core/modules/node/src/Form/NodePreviewForm.php b/core/modules/node/src/Form/NodePreviewForm.php index c7333fbe4034de230442d7930fd952367fbc3edf..fc5311fe7f0f9befb335cd51a9f9e37091f917a1 100644 --- a/core/modules/node/src/Form/NodePreviewForm.php +++ b/core/modules/node/src/Form/NodePreviewForm.php @@ -69,7 +69,7 @@ public function getFormId() { * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * @param \Drupal\Core\Entity\EntityInterface $node - * The node being previews + * The node being previews. * * @return array * The form structure. diff --git a/core/modules/node/src/Hook/NodeHooks.php b/core/modules/node/src/Hook/NodeHooks.php index 38d3fb4e69f156b586c6998aacc7eddc548c0e0b..d5f84e0359ba14e0bea48dfcf54c49f8089f47bc 100644 --- a/core/modules/node/src/Hook/NodeHooks.php +++ b/core/modules/node/src/Hook/NodeHooks.php @@ -28,7 +28,7 @@ class NodeHooks { * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager * The entity type manager. * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler - * The module handler + * The module handler. */ public function __construct( EntityTypeManagerInterface $entityTypeManager, diff --git a/core/modules/node/src/NodeGrantDatabaseStorageInterface.php b/core/modules/node/src/NodeGrantDatabaseStorageInterface.php index 8a8afbb34c8e6c43a0a3c2845a77d1c1e9673a61..cce7447656304af75fa781001018aaa189a983ca 100644 --- a/core/modules/node/src/NodeGrantDatabaseStorageInterface.php +++ b/core/modules/node/src/NodeGrantDatabaseStorageInterface.php @@ -32,10 +32,10 @@ public function checkAll(AccountInterface $account); * A list of tables that need to be part of the alter. * @param string $operation * The operation to be performed on the node. Possible values are: - * - "view" - * - "update" - * - "delete" - * - "create" + * - "view". + * - "update". + * - "delete". + * - "create". * @param \Drupal\Core\Session\AccountInterface $account * A user object representing the user for whom the operation is to be * performed. diff --git a/core/modules/node/tests/src/Functional/NodeDisplayConfigurableTest.php b/core/modules/node/tests/src/Functional/NodeDisplayConfigurableTest.php index 1d2602c18aaccd567d937de60ea65b8a5d13ca5a..48b893c866aac356be9631e258606d9d5844d9a2 100644 --- a/core/modules/node/tests/src/Functional/NodeDisplayConfigurableTest.php +++ b/core/modules/node/tests/src/Functional/NodeDisplayConfigurableTest.php @@ -153,6 +153,7 @@ protected function assertNodeHtml(NodeInterface $node, UserInterface $user, bool * Data provider for ::testDisplayConfigurable(). * * @return array + * An array of test cases. */ public static function provideThemes() { return [ diff --git a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeCompleteTest.php b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeCompleteTest.php index 90dcb8c92a4a1361fbee4b0cec3c36cec22d9565..8f30abbc564208b886f9a86de1e33b7d9ce8f4f5 100644 --- a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeCompleteTest.php +++ b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeCompleteTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\node\Kernel\Migrate\d6; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\node\NodeInterface; use Drupal\Tests\file\Kernel\Migrate\d6\FileMigrationTestTrait; use Drupal\Tests\migrate_drupal\Traits\CreateTestContentEntitiesTrait; @@ -65,14 +66,14 @@ public function testNodeCompleteMigration(): void { ->orderBy('vid') ->orderBy('langcode') ->execute() - ->fetchAll(\PDO::FETCH_ASSOC)); + ->fetchAll(FetchAs::Associative)); $this->assertEquals($this->expectedNodeFieldDataTable(), $db->select('node_field_data', 'nr') ->fields('nr') ->orderBy('nid') ->orderBy('vid') ->orderBy('langcode') ->execute() - ->fetchAll(\PDO::FETCH_ASSOC)); + ->fetchAll(FetchAs::Associative)); // Now load and test each revision, including the field 'field_text_plain' // which has text reflecting the revision. diff --git a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeCompleteTest.php b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeCompleteTest.php index 304747081ad89ef1399ba50a37e1ffaefa7aa601..cbe9b346623e49bd496b8264c3fffa3f82b94320 100644 --- a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeCompleteTest.php +++ b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeCompleteTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\node\Kernel\Migrate\d7; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\migrate\MigrateExecutable; use Drupal\migrate_drupal\NodeMigrateType; use Drupal\node\Entity\Node; @@ -112,14 +113,14 @@ public function testNodeCompleteMigration(): void { ->orderBy('vid') ->orderBy('langcode') ->execute() - ->fetchAll(\PDO::FETCH_ASSOC)); + ->fetchAll(FetchAs::Associative)); $this->assertEquals($this->expectedNodeFieldDataTable(), $db->select('node_field_data', 'nr') ->fields('nr') ->orderBy('nid') ->orderBy('vid') ->orderBy('langcode') ->execute() - ->fetchAll(\PDO::FETCH_ASSOC)); + ->fetchAll(FetchAs::Associative)); // Load and test each revision. $data = $this->expectedRevisionEntityData()[0]; diff --git a/core/modules/options/src/Plugin/migrate/field/d7/ListField.php b/core/modules/options/src/Plugin/migrate/field/d7/ListField.php index 4f6253843eb098f10eb9d206db65c549dec23b55..837f6bf303142457a15f11ce34dbf8497da4477d 100644 --- a/core/modules/options/src/Plugin/migrate/field/d7/ListField.php +++ b/core/modules/options/src/Plugin/migrate/field/d7/ListField.php @@ -5,6 +5,9 @@ use Drupal\migrate_drupal\Attribute\MigrateField; use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase; +/** + * Migrate field plugin for Drupal 7 list fields. + */ #[MigrateField( id: 'list', core: [7], diff --git a/core/modules/options/src/Plugin/migrate/field/d7/OptionsField.php b/core/modules/options/src/Plugin/migrate/field/d7/OptionsField.php index 58317a7cdcb0035057df93b93d3410086f824df5..8040ad6292646e8fb1065588d6fadd11d8064cfa 100644 --- a/core/modules/options/src/Plugin/migrate/field/d7/OptionsField.php +++ b/core/modules/options/src/Plugin/migrate/field/d7/OptionsField.php @@ -5,6 +5,9 @@ use Drupal\migrate_drupal\Attribute\MigrateField; use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase; +/** + * Migrate field plugin for Drupal 7 options fields. + */ #[MigrateField( id: 'options', core: [7], diff --git a/core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php b/core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php index d36df88308738bf82ef701b81bd375837da80143..4879aeea45f81746e9b5d9ae9e2bf05ed472ccfb 100644 --- a/core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php +++ b/core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php @@ -120,7 +120,8 @@ public function addPackage(array $package, bool $is_dev_requirement = FALSE, boo } $repo_path = $this->addRepository($package); - if (is_null($extra_files) && isset($package['type']) && in_array($package['type'], ['drupal-module', 'drupal-theme', 'drupal-profile'], TRUE)) { + if (is_null($extra_files) && isset($package['type']) + && in_array($package['type'], ['drupal-module', 'drupal-theme', 'drupal-profile'], TRUE)) { // For Drupal projects if no files are provided create an info.yml file // that assumes the project and package names match. [, $package_name] = explode('/', $package['name']); @@ -578,7 +579,12 @@ private function createPathRepo(array $package, string $repo_path, ?string $orig // Set the `extra` property in the generated composer.json file using // `composer config`, because `composer init` does not support it. foreach ($package['extra'] ?? [] as $extra_property => $extra_value) { - $this->runComposerCommand(['config', "extra.$extra_property", '--json', json_encode($extra_value, JSON_UNESCAPED_SLASHES)]); + $this->runComposerCommand([ + 'config', + "extra.$extra_property", + '--json', + json_encode($extra_value, JSON_UNESCAPED_SLASHES), + ]); } // Restore the project root as the working directory. $this->dir = $project_root_dir; diff --git a/core/modules/package_manager/tests/src/Kernel/ComposerPluginsValidatorTestBase.php b/core/modules/package_manager/tests/src/Kernel/ComposerPluginsValidatorTestBase.php index 6515796de8e77d1b27897e85be585bd98c67712f..d9b91b1a7605d3418f8d2677146e9ee98707eb22 100644 --- a/core/modules/package_manager/tests/src/Kernel/ComposerPluginsValidatorTestBase.php +++ b/core/modules/package_manager/tests/src/Kernel/ComposerPluginsValidatorTestBase.php @@ -98,6 +98,7 @@ protected function doTestValidationAfterTrustingDuringPreApply(array $composer_c * Generates simple test cases. * * @return \Generator + * The test cases. */ public static function providerSimpleValidCases(): \Generator { yield 'no composer plugins' => [ @@ -181,6 +182,7 @@ public static function providerSimpleValidCases(): \Generator { * Generates simple invalid test cases. * * @return \Generator + * The test cases. */ public static function providerSimpleInvalidCases(): \Generator { yield 'one UNsupported composer plugin — pretty package name' => [ @@ -280,6 +282,7 @@ public static function providerSimpleInvalidCases(): \Generator { * Generates complex invalid test cases based on the simple test cases. * * @return \Generator + * The test cases. */ public static function providerComplexInvalidCases(): \Generator { $valid_cases = iterator_to_array(static::providerSimpleValidCases()); diff --git a/core/modules/package_manager/tests/src/Traits/ComposerStagerTestTrait.php b/core/modules/package_manager/tests/src/Traits/ComposerStagerTestTrait.php index 9f76afd905813c71ec39c20554685f0053e91e62..544b0af95d1aa93b29afa352fdc33b603fe419be 100644 --- a/core/modules/package_manager/tests/src/Traits/ComposerStagerTestTrait.php +++ b/core/modules/package_manager/tests/src/Traits/ComposerStagerTestTrait.php @@ -24,7 +24,7 @@ trait ComposerStagerTestTrait { * A message containing optional placeholders corresponding to parameters (next). Example: * ```php * $message = 'Hello, %first_name %last_name.'; - * ``` + * ```. * @param \PhpTuf\ComposerStager\API\Translation\Value\TranslationParametersInterface|null $parameters * Translation parameters. * @param string|null $domain diff --git a/core/modules/package_manager/tests/src/Unit/StageBaseTest.php b/core/modules/package_manager/tests/src/Unit/StageBaseTest.php index 61ff2af58b81d2e541c277bd7152c89706187461..d6f544daeaec544bc983b4bf4d128327c903667c 100644 --- a/core/modules/package_manager/tests/src/Unit/StageBaseTest.php +++ b/core/modules/package_manager/tests/src/Unit/StageBaseTest.php @@ -142,6 +142,9 @@ public function testTypeMustBeExplicitlyOverridden(): void { } +/** + * Test class for testing the child stage. + */ class ChildStage extends StageBase { public function __construct() {} diff --git a/core/modules/page_cache/src/StackMiddleware/PageCache.php b/core/modules/page_cache/src/StackMiddleware/PageCache.php index e24f67717a28070a596ee02174f7fbd23e46cf03..8325b79724cc98de43d7ca1faec0e28ff80ded61 100644 --- a/core/modules/page_cache/src/StackMiddleware/PageCache.php +++ b/core/modules/page_cache/src/StackMiddleware/PageCache.php @@ -107,7 +107,7 @@ public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TR * The type of the request (one of HttpKernelInterface::MAIN_REQUEST or * HttpKernelInterface::SUB_REQUEST) * @param bool $catch - * Whether to catch exceptions or not + * Whether to catch exceptions or not. * * @return \Symfony\Component\HttpFoundation\Response * A response object. @@ -125,7 +125,7 @@ protected function pass(Request $request, $type = self::MAIN_REQUEST, $catch = T * The type of the request (one of HttpKernelInterface::MAIN_REQUEST or * HttpKernelInterface::SUB_REQUEST) * @param bool $catch - * Whether to catch exceptions or not + * Whether to catch exceptions or not. * * @return \Symfony\Component\HttpFoundation\Response * A response object. @@ -189,7 +189,7 @@ protected function lookup(Request $request, $type = self::MAIN_REQUEST, $catch = * The type of the request (one of HttpKernelInterface::MAIN_REQUEST or * HttpKernelInterface::SUB_REQUEST) * @param bool $catch - * Whether to catch exceptions or not + * Whether to catch exceptions or not. * * @return \Symfony\Component\HttpFoundation\Response * A response object. diff --git a/core/modules/path_alias/src/AliasRepository.php b/core/modules/path_alias/src/AliasRepository.php index 21eb3daef0d65bc2a85a14fd9285cea81c827c29..0172b8da57b6ed6d0bbbd4a381b094823f08ece7 100644 --- a/core/modules/path_alias/src/AliasRepository.php +++ b/core/modules/path_alias/src/AliasRepository.php @@ -4,6 +4,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Database\Query\SelectInterface; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Language\LanguageInterface; /** @@ -53,7 +54,7 @@ public function preloadPathAlias($preloaded, $langcode) { // 'base_table.id' column, as that would not guarantee other conditions // added to the query, such as those in ::addLanguageFallback, would be // reversed. - $results = $select->execute()->fetchAll(\PDO::FETCH_ASSOC); + $results = $select->execute()->fetchAll(FetchAs::Associative); $aliases = []; foreach (array_reverse($results) as $result) { $aliases[$result['path']] = $result['alias']; diff --git a/core/modules/path_alias/tests/src/Unit/PathProcessor/AliasPathProcessorTest.php b/core/modules/path_alias/tests/src/Unit/PathProcessor/AliasPathProcessorTest.php index b3a0ea3971c7c52a31c861a80461e64b250e4cf4..b49b6bbebc1f75cf6f581c97429e16a3c57d635e 100644 --- a/core/modules/path_alias/tests/src/Unit/PathProcessor/AliasPathProcessorTest.php +++ b/core/modules/path_alias/tests/src/Unit/PathProcessor/AliasPathProcessorTest.php @@ -82,6 +82,7 @@ public function testProcessOutbound($path, array $options, $expected_path): void /** * @return array + * The data provider for testProcessOutbound. */ public static function providerTestProcessOutbound() { return [ diff --git a/core/modules/pgsql/src/Driver/Database/pgsql/Schema.php b/core/modules/pgsql/src/Driver/Database/pgsql/Schema.php index 7e475245f2f0f79335a66a97e683785528c05046..b6f669d24ba6be1cbdd2dae911c6937430b2537a 100644 --- a/core/modules/pgsql/src/Driver/Database/pgsql/Schema.php +++ b/core/modules/pgsql/src/Driver/Database/pgsql/Schema.php @@ -243,6 +243,7 @@ protected function resetTableInformation($table) { * - t: constraint trigger; * - x: exclusion constraint. * Defaults to 'c' for a CHECK constraint. + * phpcs:ignore Drupal.Commenting.FunctionComment.ParamCommentFullStop * @see https://www.postgresql.org/docs/current/catalog-pg-constraint.html * * @return array diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index feea15c5e7c543c5322b0004493c906fc23d6f49..dc925fd58b809692312341fcf1cc78a2608beddf 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -79,7 +79,7 @@ class EntityResource extends ResourceBase implements DependentPluginInterface { * @param mixed $plugin_definition * The plugin implementation definition. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager + * The entity type manager. * @param array $serializer_formats * The available serialization formats. * @param \Psr\Log\LoggerInterface $logger diff --git a/core/modules/rest/src/ResourceResponseTrait.php b/core/modules/rest/src/ResourceResponseTrait.php index c61e4e634938955a5ecbb36eebb33e0e2f886885..b68a8f8428dccc50c1631848f325fe267381bcf7 100644 --- a/core/modules/rest/src/ResourceResponseTrait.php +++ b/core/modules/rest/src/ResourceResponseTrait.php @@ -2,6 +2,9 @@ namespace Drupal\rest; +/** + * Provides a trait for accessing response data that should be serialized. + */ trait ResourceResponseTrait { /** diff --git a/core/modules/rest/src/Routing/ResourceRoutes.php b/core/modules/rest/src/Routing/ResourceRoutes.php index cee498186c2eed3d409434344101200e6491065a..6f46656413c5d9752ad9c1cd8758087ffc15a407 100644 --- a/core/modules/rest/src/Routing/ResourceRoutes.php +++ b/core/modules/rest/src/Routing/ResourceRoutes.php @@ -43,7 +43,7 @@ class ResourceRoutes implements EventSubscriberInterface { * @param \Drupal\rest\Plugin\Type\ResourcePluginManager $manager * The resource plugin manager. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager + * The entity type manager. * @param \Psr\Log\LoggerInterface $logger * A logger instance. */ diff --git a/core/modules/rest/tests/modules/rest_test/src/Plugin/rest/resource/NoSerializationClassTestResource.php b/core/modules/rest/tests/modules/rest_test/src/Plugin/rest/resource/NoSerializationClassTestResource.php index 728dd209ddbdfd6001fa1991fe61bd4924c8cd8d..6ca42077130fc373113d7f3c416b8206504aa99f 100644 --- a/core/modules/rest/tests/modules/rest_test/src/Plugin/rest/resource/NoSerializationClassTestResource.php +++ b/core/modules/rest/tests/modules/rest_test/src/Plugin/rest/resource/NoSerializationClassTestResource.php @@ -27,6 +27,7 @@ class NoSerializationClassTestResource extends ResourceBase { * An array with the payload. * * @return \Drupal\rest\ResourceResponse + * The HTTP response object. */ public function post(array $data) { return new ResourceResponse($data); diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php index e2e0770648caed39d4ef365d9285d163f4d07cfc..365f7b2f06aede62a6b0f35bf2156ae01878881c 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -272,6 +272,7 @@ protected function createAnotherEntity() { * @see ::createEntity() * * @return array + * An array structure as returned by ::getExpectedNormalizedEntity(). */ abstract protected function getExpectedNormalizedEntity(); @@ -281,6 +282,7 @@ abstract protected function getExpectedNormalizedEntity(); * @see ::testPost * * @return array + * An array structure as returned by ::getNormalizedPostEntity(). */ abstract protected function getNormalizedPostEntity(); @@ -293,6 +295,7 @@ abstract protected function getNormalizedPostEntity(); * @see ::testPatch * * @return array + * An array structure as returned by ::getNormalizedPostEntity(). */ protected function getNormalizedPatchEntity() { return $this->getNormalizedPostEntity(); @@ -377,6 +380,7 @@ protected function getExpectedUnauthorizedEntityAccessCacheability($is_authentic * @see ::testGet * * @return string[] + * The expected cache tags. */ protected function getExpectedCacheTags() { $expected_cache_tags = [ @@ -395,6 +399,7 @@ protected function getExpectedCacheTags() { * @see ::testGet * * @return string[] + * The expected cache contexts. */ protected function getExpectedCacheContexts() { return [ diff --git a/core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php b/core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php index ea5003dd8ee707baa3644b5c9bb6dfe4a47c83ca..e4c1db6435df150fda856a7743886bcd09461b34 100644 --- a/core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php @@ -229,6 +229,7 @@ public function testPostFileUpload(): void { * Returns the normalized POST entity referencing the uploaded file. * * @return array + * The normalized POST entity. * * @see ::testPostFileUpload() * @see \Drupal\Tests\rest\Functional\EntityResource\EntityTest\EntityTestResourceTestBase::getNormalizedPostEntity() @@ -766,6 +767,7 @@ protected function getExpectedNormalizedEntity($fid = 1, $expected_filename = 'e * the header value to FALSE. * * @return \Psr\Http\Message\ResponseInterface + * The response object. * * @see \GuzzleHttp\ClientInterface::request() */ diff --git a/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php b/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php index fd0dce49060070d908e51622dc4ab8f5f1fecaf0..5b1c0c400b545ad101cf1b27450b64f2e11f11f3 100644 --- a/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php +++ b/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php @@ -380,6 +380,7 @@ public static function providerTestResponseFormat() { /** * @return \Drupal\rest\EventSubscriber\ResourceResponseSubscriber + * A functioning ResourceResponseSubscriber. */ protected function getFunctioningResourceResponseSubscriber(RouteMatchInterface $route_match) { // Create a dummy of the renderer service. diff --git a/core/modules/search/src/SearchIndex.php b/core/modules/search/src/SearchIndex.php index 1a0bdbdd14772237b7d539d1cd0ac8cbe71aa238..cdb1bd1a6c96fee429b221eba6ffdf4b774df920 100644 --- a/core/modules/search/src/SearchIndex.php +++ b/core/modules/search/src/SearchIndex.php @@ -27,7 +27,7 @@ class SearchIndex implements SearchIndexInterface { * @param \Drupal\search\SearchTextProcessorInterface $textProcessor * The text processor. * @param \Drupal\Component\Datetime\TimeInterface $time - * The time service + * The time service. */ public function __construct( protected ConfigFactoryInterface $configFactory, diff --git a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php index 70eaee3d85e9f5f659bb869b932e6abccfebabe3..0fd1b4ba3143a73de1952d27201ce39c4b79ddde 100644 --- a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php +++ b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php @@ -61,7 +61,10 @@ public function execute() { 'link' => Url::fromRoute('test_page_test.test_page')->toString(), 'type' => 'Dummy result type', 'title' => 'Dummy title', - 'snippet' => new FormattableMarkup("Dummy search snippet to display. Keywords: @keywords\n\nConditions: @search_parameters", ['@keywords' => $this->keywords, '@search_parameters' => print_r($this->searchParameters, TRUE)]), + 'snippet' => new FormattableMarkup("Dummy search snippet to display. Keywords: @keywords\n\nConditions: @search_parameters", [ + '@keywords' => $this->keywords, + '@search_parameters' => print_r($this->searchParameters, TRUE), + ]), ], ]; } diff --git a/core/modules/search/tests/src/Functional/SearchLanguageTest.php b/core/modules/search/tests/src/Functional/SearchLanguageTest.php index 784a953eb143e44db1859c9121f35da828c46e3e..f2ddd01796c98c3fcbad0ec295506067aca18836 100644 --- a/core/modules/search/tests/src/Functional/SearchLanguageTest.php +++ b/core/modules/search/tests/src/Functional/SearchLanguageTest.php @@ -105,6 +105,9 @@ protected function setUp(): void { $plugin->updateIndex(); } + /** + * Tests language management in the search interface. + */ public function testLanguages(): void { // Add predefined language. $edit = ['predefined_langcode' => 'fr']; diff --git a/core/modules/search/tests/src/Functional/SearchPageOverrideTest.php b/core/modules/search/tests/src/Functional/SearchPageOverrideTest.php index 425874448a653e9002f21e0732d2226949af8b03..65bd29e3501539397e33ba8a2254dc4fc302a23f 100644 --- a/core/modules/search/tests/src/Functional/SearchPageOverrideTest.php +++ b/core/modules/search/tests/src/Functional/SearchPageOverrideTest.php @@ -47,6 +47,9 @@ protected function setUp(): void { $this->drupalLogin($this->searchUser); } + /** + * Tests that the search results page can be overridden by a custom plugin. + */ public function testSearchPageHook(): void { $keys = 'bike shed ' . $this->randomMachineName(); $this->drupalGet("search/dummy_path", ['query' => ['keys' => $keys]]); diff --git a/core/modules/search/tests/src/Functional/SearchRankingTest.php b/core/modules/search/tests/src/Functional/SearchRankingTest.php index 767129dd0d8a534eedad28b178a25da3739caf91..0f6ea993a6b4ef138f41f4fcf59e6189e153aaaf 100644 --- a/core/modules/search/tests/src/Functional/SearchRankingTest.php +++ b/core/modules/search/tests/src/Functional/SearchRankingTest.php @@ -61,6 +61,9 @@ protected function setUp(): void { ])); } + /** + * Tests the impact of different ranking factors on search results. + */ public function testRankings(): void { // Add a comment field. $this->addDefaultCommentField('node', 'page'); diff --git a/core/modules/search/tests/src/Kernel/SearchMatchTest.php b/core/modules/search/tests/src/Kernel/SearchMatchTest.php index 42fae8ec073324d8befe03e166c6c3db55707c1b..cf3fee99b4878f5c9bdd89551ce0ec2d9cabc791 100644 --- a/core/modules/search/tests/src/Kernel/SearchMatchTest.php +++ b/core/modules/search/tests/src/Kernel/SearchMatchTest.php @@ -72,7 +72,7 @@ public function _setup(): void { } /** - * _test_: Helper method for generating snippets of content. + * Helper to generate lorem ipsum snippets of content. * * Generated items to test against: * 1 ipsum @@ -89,7 +89,7 @@ public function getText($n) { } /** - * _test2_: Helper method for generating snippets of content. + * Helper to generate English language snippets of content. * * Generated items to test against: * 8 dear diff --git a/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php b/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php index df793281c4c605b5891d05191819af6fa9d585d1..ce67ed1e00567518bdec6901b5cd024b5b9107a1 100644 --- a/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php +++ b/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php @@ -310,6 +310,9 @@ public function testSortSearchPages(): void { } +/** + * Mock for the configured search page entity. + */ class TestSearchPage extends SearchPage { public function __construct(array $values) { diff --git a/core/modules/serialization/src/EntityResolver/EntityResolverInterface.php b/core/modules/serialization/src/EntityResolver/EntityResolverInterface.php index 08659ecac6e52dbd3fea7b56d7b56549f35a35f5..c463615bb455c43933e77c936752c7295c15faf8 100644 --- a/core/modules/serialization/src/EntityResolver/EntityResolverInterface.php +++ b/core/modules/serialization/src/EntityResolver/EntityResolverInterface.php @@ -4,6 +4,9 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +/** + * Interface for entity resolvers. + */ interface EntityResolverInterface { /** diff --git a/core/modules/serialization/src/Normalizer/JsonSchemaReflectionTrait.php b/core/modules/serialization/src/Normalizer/JsonSchemaReflectionTrait.php index 672213756501f190b6d1d989342c85f95217d6c5..864063f79af753dfdc2c682c3ad4682bd0d266ee 100644 --- a/core/modules/serialization/src/Normalizer/JsonSchemaReflectionTrait.php +++ b/core/modules/serialization/src/Normalizer/JsonSchemaReflectionTrait.php @@ -6,6 +6,9 @@ use Drupal\Core\Serialization\Attribute\JsonSchema; +/** + * Interface for using reflection with the JSON object. + */ trait JsonSchemaReflectionTrait { /** diff --git a/core/modules/serialization/src/Normalizer/SchematicNormalizerHelperTrait.php b/core/modules/serialization/src/Normalizer/SchematicNormalizerHelperTrait.php index 81842e93b3dd16314caca4d927e2f4e12b5ee9a1..721480b724c9e0ac22697114342928b0ae70b9ed 100644 --- a/core/modules/serialization/src/Normalizer/SchematicNormalizerHelperTrait.php +++ b/core/modules/serialization/src/Normalizer/SchematicNormalizerHelperTrait.php @@ -4,6 +4,9 @@ namespace Drupal\serialization\Normalizer; +/** + * Methods for normalizing JSON schema. + */ trait SchematicNormalizerHelperTrait { use JsonSchemaReflectionTrait; diff --git a/core/modules/serialization/src/Serializer/JsonSchemaProviderSerializerInterface.php b/core/modules/serialization/src/Serializer/JsonSchemaProviderSerializerInterface.php index dfb134d40e216f59301a7476df49b15947a3e8d8..162e393c85a164acf18e415d45fc206fd3fbe3bd 100644 --- a/core/modules/serialization/src/Serializer/JsonSchemaProviderSerializerInterface.php +++ b/core/modules/serialization/src/Serializer/JsonSchemaProviderSerializerInterface.php @@ -4,6 +4,9 @@ namespace Drupal\serialization\Serializer; +/** + * Interface for JSON schema provider. + */ interface JsonSchemaProviderSerializerInterface { /** diff --git a/core/modules/serialization/src/Serializer/JsonSchemaProviderSerializerTrait.php b/core/modules/serialization/src/Serializer/JsonSchemaProviderSerializerTrait.php index 77e00675cfbf93272a9584f8749314bfe2d67b68..a239460f4cb0914cadba939212263e66e1576a65 100644 --- a/core/modules/serialization/src/Serializer/JsonSchemaProviderSerializerTrait.php +++ b/core/modules/serialization/src/Serializer/JsonSchemaProviderSerializerTrait.php @@ -7,6 +7,9 @@ use Drupal\serialization\Normalizer\SchematicNormalizerFallbackTrait; use Symfony\Component\Serializer\Exception\NotNormalizableValueException; +/** + * Trait for normalizing the JSON schema. + */ trait JsonSchemaProviderSerializerTrait { use SchematicNormalizerFallbackTrait; diff --git a/core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php b/core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php index 28d4c7fe4e4fbac8dca49944599df73fb80752da..d9ff889c5d50e3e40748dee093c2ba85cf6ed59d 100644 --- a/core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php +++ b/core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php @@ -6,6 +6,9 @@ use Symfony\Component\Serializer\Encoder\EncoderInterface; +/** + * Serialization encoder used for testing. + */ class SerializationTestEncoder implements EncoderInterface { /** diff --git a/core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php b/core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php index 1f861c504ce5732a116e34ad984ce11a4347d5b8..031e731d53123e7dcac840257149e83637727019 100644 --- a/core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php +++ b/core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php @@ -6,6 +6,9 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +/** + * Serialization normalizer used for testing. + */ class SerializationTestNormalizer implements NormalizerInterface { /** diff --git a/core/modules/serialization/tests/src/Traits/JsonSchemaTestTrait.php b/core/modules/serialization/tests/src/Traits/JsonSchemaTestTrait.php index 2a08c3214cca133bf0ed7e7fb7b9388f077c3851..a7852e7bec10268dfb02707e1ec356174e9e0218 100644 --- a/core/modules/serialization/tests/src/Traits/JsonSchemaTestTrait.php +++ b/core/modules/serialization/tests/src/Traits/JsonSchemaTestTrait.php @@ -36,6 +36,7 @@ abstract public static function jsonSchemaDataProvider(): array; * Method to make prophecy public for use in data provider closures. * * @return \Prophecy\Prophecy\ObjectProphecy<object> + * A new prophecy object. */ public function doProphesize(?string $classOrInterface = NULL): ObjectProphecy { return $this->prophesize($classOrInterface); diff --git a/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php b/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php index 37c8326d511f4a784a6aafadd57163865f254d01..e4da1fbde1fed1899ca3644f7873bf073c4fbafb 100644 --- a/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php +++ b/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php @@ -103,6 +103,9 @@ public function testDefaultEncoderHasSerializer(): void { } +/** + * Test class used for the encoding test. + */ class TestObject { public function getA() { diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php index 3e8da705c831a228ae31bb7ccfd74671df0b9a94..55d4c4e4296a3e627961d7e72e7828a8a66448ce 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php @@ -126,6 +126,7 @@ public function testNormalizeWithAccountContext(): void { * The properties the will be returned. * * @return \PHPUnit\Framework\MockObject\MockObject + * The mock content entity. */ public function createMockForContentEntity($definitions) { $content_entity_mock = $this->getMockBuilder(ContentEntityBaseMockableClass::class) @@ -154,6 +155,7 @@ public function createMockForContentEntity($definitions) { * The user context used for the access check. * * @return \Drupal\Core\Field\FieldItemListInterface|\PHPUnit\Framework\MockObject\MockObject + * The mock field list item. */ protected function createMockFieldListItem($access, $internal, ?AccountInterface $user_context = NULL) { $data_definition = $this->prophesize(DataDefinitionInterface::class); diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php index 0cf16102e6b832cc1418baa496438de70bef9eb3..4a805e19d6b343a0b7d5782bdecdbe775811cb73 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php @@ -155,6 +155,7 @@ public function testNormalizeWhenNull($parent_field_item_class, $datetime_type, * Data provider for testNormalize. * * @return array + * The data provider array. */ public static function providerTestNormalize() { return [ @@ -199,6 +200,7 @@ public function testDenormalizeValidFormats($type, $normalized, $expected): void * Data provider for testDenormalizeValidFormats. * * @return array + * An array of test cases. */ public static function providerTestDenormalizeValidFormats() { $data = []; diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php index 39e96006c06828926ae37d6ef3f8f3c979b72f68..2737f367bfe274928c2f8f422c52f2242ab40f6b 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php @@ -123,6 +123,7 @@ public function testDenormalizeValidFormats($normalized, $expected): void { * Data provider for testDenormalizeValidFormats. * * @return array + * An array of test data. */ public static function providerTestDenormalizeValidFormats() { $data = []; @@ -154,6 +155,7 @@ public function testDenormalizeUserFormats($normalized, $format, $expected): voi * Data provider for testDenormalizeUserFormats. * * @return array + * An array of test data. */ public static function providerTestDenormalizeUserFormats() { $data = []; diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php index c0cd1374ff6ad547d206c6304af61eb43c4137bf..15837fa81b840276228e55d2f4fefdb8db4af5d3 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php @@ -173,6 +173,7 @@ public function testDenormalize(): void { * Creates a TimestampItem prophecy. * * @return \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Field\Plugin\Field\FieldType\TimestampItem> + * The TimestampItem prophecy. */ protected function createTimestampItemProphecy(): ObjectProphecy { $timestamp_item = $this->prophesize(TimestampItem::class); diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php index c200bbde64feba8468407e872013beb4d420497d..e0e4c991c470f01d37667c2f0d2c74a04acfab7e 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php @@ -103,6 +103,7 @@ public function testDenormalizeValidFormats($normalized, $expected): void { * Data provider for testDenormalizeValidFormats. * * @return array + * An array of test data. */ public static function providerTestDenormalizeValidFormats() { $expected_stamp = 1478422920; diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php b/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php index 9c4c0044081df376318f96f035da3c4dfe60cdd8..a73f0b685bf2194c9401bda62cd742ada89720b1 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php @@ -68,6 +68,9 @@ protected function getNewEntityValues($langcode) { return ['title' => [['value' => $this->randomMachineName()]]] + parent::getNewEntityValues($langcode); } + /** + * Tests basic translation functionality for an entity. + */ protected function doTestBasicTranslation(): void { parent::doTestBasicTranslation(); diff --git a/core/modules/sqlite/src/Driver/Database/sqlite/Connection.php b/core/modules/sqlite/src/Driver/Database/sqlite/Connection.php index e949cdd7652a01c0657972b83178f4b8e5443664..0a353dceed05ce51d151de60f99ed24ac0e7f1ac 100644 --- a/core/modules/sqlite/src/Driver/Database/sqlite/Connection.php +++ b/core/modules/sqlite/src/Driver/Database/sqlite/Connection.php @@ -414,6 +414,9 @@ public function mapConditionOperator($operator) { */ public function prepareStatement(string $query, array $options, bool $allow_row_count = FALSE): StatementInterface { assert(!isset($options['return']), 'Passing "return" option to prepareStatement() has no effect. See https://www.drupal.org/node/3185520'); + if (isset($options['fetch']) && is_int($options['fetch'])) { + @trigger_error("Passing the 'fetch' key as an integer to \$options in prepareStatement() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + } try { $query = $this->preprocessStatement($query, $options); diff --git a/core/modules/sqlite/src/Driver/Database/sqlite/Statement.php b/core/modules/sqlite/src/Driver/Database/sqlite/Statement.php index 5a2d6b826841ce5c0145d8e79d7c334a609e0d9d..1c7378a01737a61b9bab2a7db1b3b16f3d3f1834 100644 --- a/core/modules/sqlite/src/Driver/Database/sqlite/Statement.php +++ b/core/modules/sqlite/src/Driver/Database/sqlite/Statement.php @@ -86,6 +86,10 @@ protected function getStatement(string $query, ?array &$args = []): object { * {@inheritdoc} */ public function execute($args = [], $options = []) { + if (isset($options['fetch']) && is_int($options['fetch'])) { + @trigger_error("Passing the 'fetch' key as an integer to \$options in execute() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED); + } + try { $return = parent::execute($args, $options); } diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php index ea6f4ac8877687f6d0c1e4056319d05aedfe891d..53cca91ced2840729250ba1c8cbdcc5baa4a383a 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -144,10 +144,10 @@ public static function create(ContainerInterface $container) { * * @param string $op * The update operation to perform. Can be any of the below: - * - info - * - selection - * - run - * - results + * - "info". + * - "selection". + * - "run". + * - "results". * @param \Symfony\Component\HttpFoundation\Request $request * The current request object. * diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php index d340981377db0c396d64b0fbecba98a94d78f5b3..cfac2812cfddd260470dacaed459b63e5665e6f4 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php +++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php @@ -270,7 +270,11 @@ public function save($destination) { } else { // Image types that support alpha need to be saved accordingly. - if (in_array($this->getType(), [IMAGETYPE_PNG, IMAGETYPE_WEBP], TRUE)) { + if (in_array($this->getType(), [ + IMAGETYPE_PNG, + IMAGETYPE_WEBP, + IMAGETYPE_AVIF, + ], TRUE)) { imagealphablending($this->getImage(), FALSE); imagesavealpha($this->getImage(), TRUE); } @@ -428,8 +432,12 @@ public function getRequirements() { IMG_JPG => 'JPEG', IMG_PNG => 'PNG', IMG_WEBP => 'WEBP', + IMG_AVIF => 'AVIF', ]; $supported_formats = array_filter($check_formats, fn($type) => imagetypes() & $type, ARRAY_FILTER_USE_KEY); + if (isset($supported_formats[IMG_AVIF]) && !$this->checkAvifSupport()) { + unset($supported_formats[IMG_AVIF]); + } $unsupported_formats = array_diff_key($check_formats, $supported_formats); $descriptions = []; @@ -454,6 +462,11 @@ public function getRequirements() { '@unsupported' => $unsupported, '@ref' => $fix_info, ]); + if (isset($unsupported_formats[IMG_AVIF])) { + $descriptions[] = $this->t('AVIF is not supported, likely because of PHP missing a codec for encoding images. See <a href=":cr_url">the change record</a> for more information.', [ + ':cr_url' => 'https://www.drupal.org/node/3348348', + ]); + } } // Check for filter and rotate support. @@ -528,6 +541,31 @@ public function extensionToImageType($extension) { return IMAGETYPE_UNKNOWN; } + /** + * Checks if AVIF can encode image. + * + * This method tries to create an AVIF image and save it to disk via + * imageavif(). If that fails, it's likely a codec missing, or the function + * was disabled. This is an expensive operation to run, so we cache its + * result. + * + * @return bool + * TRUE if AVIF is fully supported, FALSE otherwise. + */ + protected function checkAvifSupport(): bool { + static $supported = NULL; + + if ($supported !== NULL) { + return $supported; + } + + $tempFile = fopen('php://memory', 'r+'); + $supported = imageavif(imagecreatetruecolor(1, 1), $tempFile, 0, 10) && fstat($tempFile)['size'] > 0; + fclose($tempFile); + + return $supported; + } + /** * Returns a list of image types supported by the toolkit. * @@ -536,7 +574,13 @@ public function extensionToImageType($extension) { * IMAGETYPE_* constant (e.g. IMAGETYPE_JPEG, IMAGETYPE_PNG, etc.). */ protected static function supportedTypes() { - return [IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_WEBP]; + return [ + IMAGETYPE_PNG, + IMAGETYPE_JPEG, + IMAGETYPE_GIF, + IMAGETYPE_WEBP, + IMAGETYPE_AVIF, + ]; } } diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php index 7b15796dbce4ba403676ea0d81d02669659556c0..8da24fbaa773e0c305d04e3ee96885d296366907 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php @@ -92,6 +92,7 @@ protected function execute(array $arguments) { switch ($type) { case IMAGETYPE_PNG: case IMAGETYPE_WEBP: + case IMAGETYPE_AVIF: imagealphablending($image, FALSE); $transparency = imagecolorallocatealpha($image, 0, 0, 0, 127); imagefill($image, 0, 0, $transparency); diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/GDImageToolkitOperationBase.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/GDImageToolkitOperationBase.php index 2b0dc1336338cb3b6a298bd5377866904f143720..9a3a36e35c0c05106a0c12a015e940788c6602bc 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/GDImageToolkitOperationBase.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/GDImageToolkitOperationBase.php @@ -4,6 +4,9 @@ use Drupal\Core\ImageToolkit\ImageToolkitOperationBase; +/** + * Provides a GD base class with correctly typed image toolkit. + */ abstract class GDImageToolkitOperationBase extends ImageToolkitOperationBase { /** diff --git a/core/modules/system/src/Tests/Routing/MockAliasManager.php b/core/modules/system/src/Tests/Routing/MockAliasManager.php index a9b88bfbc5c7d470f3b6947dcd2723a4b4ec6c17..86bcd201c46fdd4a96b55caa36a3793af087c4ea 100644 --- a/core/modules/system/src/Tests/Routing/MockAliasManager.php +++ b/core/modules/system/src/Tests/Routing/MockAliasManager.php @@ -80,6 +80,7 @@ public function getPathByAlias($alias, $langcode = NULL) { * The language code. * * @return string + * The value of the alias. */ public function getAliasByPath($path, $langcode = NULL) { if ($path[0] !== '/') { diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php b/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php index df777954adffc3794da11f1c82bdd60d89ab836b..bc8692d64c72ca0e6845a4e01590f629b9ff144e 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php +++ b/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php @@ -283,7 +283,11 @@ public static function advancedCommandsAddCssCallback($form, FormStateInterface */ public static function validationFormCallback($form, FormStateInterface $form_state): array { \Drupal::messenger()->addStatus("ajax_forms_test_validation_form_callback invoked"); - \Drupal::messenger()->addStatus(t("Callback: driver_text=%driver_text, spare_required_field=%spare_required_field", ['%driver_text' => $form_state->getValue('driver_text'), '%spare_required_field' => $form_state->getValue('spare_required_field')])); + \Drupal::messenger() + ->addStatus(t("Callback: driver_text=%driver_text, spare_required_field=%spare_required_field", [ + '%driver_text' => $form_state->getValue('driver_text'), + '%spare_required_field' => $form_state->getValue('spare_required_field'), + ])); return ['#markup' => '<div id="message_area">ajax_forms_test_validation_form_callback at ' . date('c') . '</div>']; } @@ -292,7 +296,11 @@ public static function validationFormCallback($form, FormStateInterface $form_st */ public static function validationNumberFormCallback($form, FormStateInterface $form_state): array { \Drupal::messenger()->addStatus("ajax_forms_test_validation_number_form_callback invoked"); - \Drupal::messenger()->addStatus(t("Callback: driver_number=%driver_number, spare_required_field=%spare_required_field", ['%driver_number' => $form_state->getValue('driver_number'), '%spare_required_field' => $form_state->getValue('spare_required_field')])); + \Drupal::messenger() + ->addStatus(t("Callback: driver_number=%driver_number, spare_required_field=%spare_required_field", [ + '%driver_number' => $form_state->getValue('driver_number'), + '%spare_required_field' => $form_state->getValue('spare_required_field'), + ])); return ['#markup' => '<div id="message_area_number">ajax_forms_test_validation_number_form_callback at ' . date('c') . '</div>']; } diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php index b06e66e2136599d0d9f687a8131247440ad4d3ed..3e4a6474ce587eb3210891317e549c3bf4e43fbf 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php +++ b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php @@ -16,14 +16,14 @@ class AjaxFormsTestCommandsForm extends FormBase { /** - * {@inheritdoc}. + * {@inheritdoc} */ public function getFormId() { return 'ajax_forms_test_ajax_commands_form'; } /** - * {@inheritdoc}. + * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form = []; @@ -236,7 +236,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { } /** - * {@inheritdoc}. + * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { } diff --git a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestMessageCommandForm.php b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestMessageCommandForm.php index 773eb20faf7b48152a77fa17e0560eb93b3e3bbc..423a41b472c81376db36db3fa5725ab52ec06f0b 100644 --- a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestMessageCommandForm.php +++ b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestMessageCommandForm.php @@ -103,7 +103,10 @@ public function makeMessageAlternate() { */ public function makeMessageWarning() { $response = new AjaxResponse(); - return $response->addCommand(new MessageCommand('I am a warning message in the default location.', NULL, ['type' => 'warning', 'announce' => ''])); + return $response->addCommand(new MessageCommand('I am a warning message in the default location.', NULL, [ + 'type' => 'warning', + 'announce' => '', + ])); } } diff --git a/core/modules/system/tests/modules/batch_test/src/BatchTestCallbacks.php b/core/modules/system/tests/modules/batch_test/src/BatchTestCallbacks.php index 80fb233aa8bc3c49e7bdb703133a3485ddf117ba..24da9ebff8426dd5beb1b5b8966c2711f0260be3 100644 --- a/core/modules/system/tests/modules/batch_test/src/BatchTestCallbacks.php +++ b/core/modules/system/tests/modules/batch_test/src/BatchTestCallbacks.php @@ -193,7 +193,10 @@ public function finishedHelper($batch_id, $success, $results, $operations, $elap if (!$success) { // A fatal error occurred during the processing. $error_operation = reset($operations); - $messages[] = $this->t('An error occurred while processing @op with arguments:<br />@args', ['@op' => $error_operation[0], '@args' => print_r($error_operation[1], TRUE)]); + $messages[] = $this->t('An error occurred while processing @op with arguments:<br />@args', [ + '@op' => $error_operation[0], + '@args' => print_r($error_operation[1], TRUE), + ]); } // Use item list template to render the messages. diff --git a/core/modules/system/tests/modules/content_negotiation_test/src/Controller/TestController.php b/core/modules/system/tests/modules/content_negotiation_test/src/Controller/TestController.php index fd9399d3abeeaf17407df186e6ea4db92308e84c..58df87602bff234859cdb6e5cbb4a23160bfa90f 100644 --- a/core/modules/system/tests/modules/content_negotiation_test/src/Controller/TestController.php +++ b/core/modules/system/tests/modules/content_negotiation_test/src/Controller/TestController.php @@ -17,6 +17,7 @@ class TestController { * Returns a json response. * * @return \Symfony\Component\HttpFoundation\JsonResponse + * The Json response value. */ public function simple() { return new JsonResponse(['some' => 'data']); @@ -26,6 +27,7 @@ public function simple() { * Returns a simple render array. * * @return array + * A render array with only '#markup'. */ public function html() { return [ @@ -37,7 +39,7 @@ public function html() { * Returns different responses depending on the request format. * * @param \Symfony\Component\HttpFoundation\Request $request - * The request + * The request. * * @return \Symfony\Component\HttpFoundation\Response * The response. diff --git a/core/modules/system/tests/modules/database_test/database_test.install b/core/modules/system/tests/modules/database_test/database_test.install index 6f4d3b7a4f8006b71369fd2c2acc635821559e27..f152becb6cd32beaa9cc09f24efe8821e8f46ae3 100644 --- a/core/modules/system/tests/modules/database_test/database_test.install +++ b/core/modules/system/tests/modules/database_test/database_test.install @@ -57,7 +57,7 @@ function database_test_schema(): array { ]; $schema['test_classtype'] = [ - 'description' => 'A duplicate version of the test table, used for fetch_style PDO::FETCH_CLASSTYPE tests.', + 'description' => 'A duplicate version of the test table, used for obsolete fetch_style PDO::FETCH_CLASSTYPE tests.', 'fields' => [ 'classname' => [ 'description' => "A custom class name", diff --git a/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php b/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php index 6634b9d274001496d7e68659b354ee0c70ce9faf..71e23ba35bbf750ebe7ebcd257bcdd5843cbba88 100644 --- a/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php +++ b/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php @@ -52,6 +52,7 @@ public static function create(ContainerInterface $container) { * test HTTP call. * * @return \Symfony\Component\HttpFoundation\JsonResponse + * A JSON response containing the names of the test entries. */ public function pagerQueryEven($limit) { $query = $this->connection->select('test', 't'); @@ -78,6 +79,7 @@ public function pagerQueryEven($limit) { * test HTTP call. * * @return \Symfony\Component\HttpFoundation\JsonResponse + * A JSON response containing the names of the test entries. */ public function pagerQueryOdd($limit) { $query = $this->connection->select('test_task', 't'); @@ -104,6 +106,7 @@ public function pagerQueryOdd($limit) { * test HTTP call. * * @return \Symfony\Component\HttpFoundation\JsonResponse + * A JSON response containing the test tasks. */ public function testTablesort() { $header = [ @@ -136,6 +139,7 @@ public function testTablesort() { * test HTTP call. * * @return \Symfony\Component\HttpFoundation\JsonResponse + * A JSON response containing the test tasks. */ public function testTablesortFirst() { $header = [ diff --git a/core/modules/system/tests/modules/entity_reference_test/src/Hook/EntityReferenceTestHooks.php b/core/modules/system/tests/modules/entity_reference_test/src/Hook/EntityReferenceTestHooks.php index 29e12342ce253a29dfa476dd02a03adb0cd738b7..0460a323e18589393c013f61fcde9a2dfa78effe 100644 --- a/core/modules/system/tests/modules/entity_reference_test/src/Hook/EntityReferenceTestHooks.php +++ b/core/modules/system/tests/modules/entity_reference_test/src/Hook/EntityReferenceTestHooks.php @@ -35,7 +35,12 @@ public function entityBaseFieldInfo(EntityTypeInterface $entity_type): array { public function entityBaseFieldInfoAlter(&$fields, EntityTypeInterface $entity_type): void { if ($entity_type->id() === 'entity_test') { // Allow user_id field to use configurable widget. - $fields['user_id']->setSetting('handler', 'default')->setDisplayOptions('form', ['type' => 'entity_reference_autocomplete', 'weight' => 0])->setDisplayConfigurable('form', TRUE); + $fields['user_id']->setSetting('handler', 'default') + ->setDisplayOptions('form', [ + 'type' => 'entity_reference_autocomplete', + 'weight' => 0, + ]) + ->setDisplayConfigurable('form', TRUE); } } diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php index 9c7298121a0c446b3d720909e616aa88fa1ed900..39f70e5c8c8c7584f88b8ebd17252bdede801591 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php @@ -166,6 +166,7 @@ public function setName($name) { * Returns the name. * * @return string + * The name of the entity. */ public function getName() { return $this->get('name')->value; diff --git a/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php b/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php index e029ba03105880b4045188a4ef13ee123b83a004..c8fbd93ce3a69574c6d490b33237309b9176d853 100644 --- a/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php +++ b/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php @@ -62,10 +62,16 @@ public function save(array $form, FormStateInterface $form_state) { $status = $entity->save(); if ($is_new) { - $message = $this->t('%entity_type @id has been created.', ['@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()]); + $message = $this->t('%entity_type @id has been created.', [ + '@id' => $entity->id(), + '%entity_type' => $entity->getEntityTypeId(), + ]); } else { - $message = $this->t('%entity_type @id has been updated.', ['@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()]); + $message = $this->t('%entity_type @id has been updated.', [ + '@id' => $entity->id(), + '%entity_type' => $entity->getEntityTypeId(), + ]); } $this->messenger()->addStatus($message); diff --git a/core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php b/core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php index 68ae20a3f81bb3de65e51977c339d25d729b34a6..e1e5d57fc2efd3f34af109d70b63230cea7cceba 100644 --- a/core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php +++ b/core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php @@ -135,7 +135,8 @@ public function entityBundleInfo(): array { $bundles = []; $entity_types = \Drupal::entityTypeManager()->getDefinitions(); foreach ($entity_types as $entity_type_id => $entity_type) { - if ($entity_type->getProvider() == 'entity_test' && !in_array($entity_type_id, ['entity_test_with_bundle', 'entity_test_mul_with_bundle'], TRUE)) { + if ($entity_type->getProvider() == 'entity_test' + && !in_array($entity_type_id, ['entity_test_with_bundle', 'entity_test_mul_with_bundle'], TRUE)) { $bundles[$entity_type_id] = \Drupal::state()->get($entity_type_id . '.bundles', [$entity_type_id => ['label' => 'Entity Test Bundle']]); } } diff --git a/core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php b/core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php index 73b27a5526d5c2d2438afef2082eb62785608fe7..620ae77b0eddc035f3fbd29b9454d8c29fbea5a7 100644 --- a/core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php +++ b/core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php @@ -185,6 +185,9 @@ public function testGetWithFormat($text_format_id, array $expected_cache_tags): $this->assertEqualsCanonicalizing($expected_cache_tags, explode(' ', $response->getHeader('X-Drupal-Cache-Tags')[0])); } + /** + * Provides test cases for text format retrieval with expected cache tags. + */ public static function providerTestGetWithFormat() { return [ 'format specified (different from fallback format)' => [ diff --git a/core/modules/system/tests/modules/form_test/form_test.routing.yml b/core/modules/system/tests/modules/form_test/form_test.routing.yml index 54b3d115323531a6b1b28f55e3702771f96c936d..faaf0c3c5d0c305ccfdc33b0dc9a9de943673258 100644 --- a/core/modules/system/tests/modules/form_test/form_test.routing.yml +++ b/core/modules/system/tests/modules/form_test/form_test.routing.yml @@ -425,6 +425,15 @@ form_test.button_class: requirements: _access: 'TRUE' +form_test.submit_button_attribute: + path: '/form-test/submit-button-attribute/{customize}' + defaults: + _form: '\Drupal\form_test\Form\FormTestSubmitButtonAttributeForm' + _title: 'Submit button attribute testing' + customize: FALSE + requirements: + _access: 'TRUE' + form_test.details_form: path: '/form_test/details-form' defaults: diff --git a/core/modules/system/tests/modules/form_test/src/Callbacks.php b/core/modules/system/tests/modules/form_test/src/Callbacks.php index 1077ae518cadd865e6500bcb5009914b1c276f36..0cd9f7a2c6a0c45cda8f5ed56e7510243553bf2f 100644 --- a/core/modules/system/tests/modules/form_test/src/Callbacks.php +++ b/core/modules/system/tests/modules/form_test/src/Callbacks.php @@ -44,7 +44,11 @@ public function validateName(&$element, FormStateInterface $form_state) { if ($triggered) { // Output the element's value from $form_state. - \Drupal::messenger()->addStatus($this->t('@label value: @value', ['@label' => $element['#title'], '@value' => $form_state->getValue('name')])); + \Drupal::messenger() + ->addStatus($this->t('@label value: @value', [ + '@label' => $element['#title'], + '@value' => $form_state->getValue('name'), + ])); // Trigger a form validation error to see our changes. $form_state->setErrorByName(''); diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestMachineNameForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestMachineNameForm.php index 6b5415cdb5ccf4fcf6e31bf30121dc890225d57f..d072732e52a068e1f7a3b8ff777aff11673205aa 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestMachineNameForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestMachineNameForm.php @@ -87,6 +87,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { * The machine name. * * @return bool + * TRUE if the machine name is a duplicate, FALSE otherwise. */ public function load($machine_name) { return str_contains($machine_name, 'duplicate'); diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestMachineNameValidationForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestMachineNameValidationForm.php index 48e72015230f8f1072b0b1eb8dbba94bb098e281..5e14dc5e3d3e3ae7a1afaa26c7a4235c4e29ecba 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestMachineNameValidationForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestMachineNameValidationForm.php @@ -126,6 +126,7 @@ public function buildAjaxSnackConfigureForm(array $form, FormStateInterface $for * The machine name. * * @return bool + * TRUE if the machine name is a duplicate, FALSE otherwise. */ public function load($machine_name) { if (str_contains($machine_name, 'duplicate')) { diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestSubmitButtonAttributeForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestSubmitButtonAttributeForm.php new file mode 100644 index 0000000000000000000000000000000000000000..e76f10cffe4d758963cba5b3938caba7e082b38d --- /dev/null +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestSubmitButtonAttributeForm.php @@ -0,0 +1,51 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\form_test\Form; + +use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; + +/** + * Builds a simple form to test the submit_button attribute. + * + * @internal + */ +class FormTestSubmitButtonAttributeForm extends FormBase { + + /** + * {@inheritdoc} + */ + public function getFormId(): string { + return 'form_test_submit_button_attribute'; + } + + /** + * {@inheritdoc} + */ + public function buildForm(array $form, FormStateInterface $form_state, $customize = FALSE): array { + $form['submit-button-attr'] = [ + '#type' => 'button', + '#submit_button' => TRUE, + '#value' => $this->t('Try to Submit'), + ]; + + if ($customize) { + $form['submit-button-attr'] = [ + '#type' => 'button', + '#submit_button' => FALSE, + '#value' => $this->t('Submit if you can'), + ]; + } + + return $form; + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state): void { + } + +} diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php index de7230df9e4385de1b5bf9db7a97e5ea8baa09f4..781175da6f358568dc4c01bf5d0df4f0a0cc1ea4 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php @@ -61,7 +61,11 @@ public function validateForm(array &$form, FormStateInterface $form_state) { // Alter the submitted value in $form_state. $form_state->setValueForElement($form['name'], 'value changed by setValueForElement() in #validate'); // Output the element's value from $form_state. - $this->messenger()->addStatus($this->t('@label value: @value', ['@label' => $form['name']['#title'], '@value' => $form_state->getValue('name')])); + $this->messenger() + ->addStatus($this->t('@label value: @value', [ + '@label' => $form['name']['#title'], + '@value' => $form_state->getValue('name'), + ])); // Trigger a form validation error to see our changes. $form_state->setErrorByName(''); diff --git a/core/modules/system/tests/modules/many_assets_test/src/Controller/ManyAssetsTestController.php b/core/modules/system/tests/modules/many_assets_test/src/Controller/ManyAssetsTestController.php index 13307fd999a0fb6e7a1f89e2f14e83c3549c59b9..770b6fcd44356e70b3f74a0bf6801b0ff4ae6158 100644 --- a/core/modules/system/tests/modules/many_assets_test/src/Controller/ManyAssetsTestController.php +++ b/core/modules/system/tests/modules/many_assets_test/src/Controller/ManyAssetsTestController.php @@ -15,6 +15,7 @@ class ManyAssetsTestController extends ControllerBase { * The render array of the assets testing page. * * @return array + * A render array with a message and attached asset libraries. */ public function build() { return [ diff --git a/core/modules/system/tests/modules/menu_test/src/Access/AccessCheck.php b/core/modules/system/tests/modules/menu_test/src/Access/AccessCheck.php index 29ac7a741641ab04cd52b5a5d64874e510f3ca5d..9c7ff92de2c879f3f81b517f8e1339c52e3099fa 100644 --- a/core/modules/system/tests/modules/menu_test/src/Access/AccessCheck.php +++ b/core/modules/system/tests/modules/menu_test/src/Access/AccessCheck.php @@ -56,6 +56,7 @@ public function access() { /** * @return \Drupal\Core\Access\AccessResultForbidden + * The forbidden access result. */ public function menuLocalAction7() { return AccessResult::forbidden()->addCacheTags(['menu_local_action7'])->addCacheContexts(['url.query_args:menu_local_action7']); @@ -63,6 +64,7 @@ public function menuLocalAction7() { /** * @return \Drupal\Core\Access\AccessResultAllowed + * The allowed access result. */ public function menuLocalAction8() { return AccessResult::allowed()->addCacheTags(['menu_local_action8'])->addCacheContexts(['url.query_args:menu_local_action8']); diff --git a/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php b/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php index 24b29753e847aeef68362ec48a197ddff178ed16..8a21cb2fb49a6f88efd8325e25c965775609a339 100644 --- a/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php +++ b/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php @@ -118,6 +118,7 @@ public function themePage($inherited) { * A title callback for XSS breadcrumb check. * * @return string + * A string that can be used for comparison. */ public function breadcrumbTitleCallback() { return '<script>alert(123);</script>'; diff --git a/core/modules/system/tests/modules/module_autoload_test/module_autoload_test.services.yml b/core/modules/system/tests/modules/module_autoload_test/module_autoload_test.services.yml new file mode 100644 index 0000000000000000000000000000000000000000..1a34a178f7ffa3bc4119c95f0b9277d4f917d37e --- /dev/null +++ b/core/modules/system/tests/modules/module_autoload_test/module_autoload_test.services.yml @@ -0,0 +1,7 @@ +parameters: + module_autoload_test.moved_classes: + 'Drupal\module_autoload_test\Foo': + class: 'Drupal\Component\Utility\Random' + deprecation_version: drupal:11.2.0 + removed_version: drupal:12.0.0 + change_record: https://www.drupal.org/project/drupal/issues/3502882 diff --git a/core/modules/system/tests/modules/path_encoded_test/src/Controller/PathEncodedTestController.php b/core/modules/system/tests/modules/path_encoded_test/src/Controller/PathEncodedTestController.php index bdbef9f35ddc6ae4eb30fa59e2c8fbe492836b62..46b010981da326f2e72441271b099a44f850aa09 100644 --- a/core/modules/system/tests/modules/path_encoded_test/src/Controller/PathEncodedTestController.php +++ b/core/modules/system/tests/modules/path_encoded_test/src/Controller/PathEncodedTestController.php @@ -15,6 +15,7 @@ class PathEncodedTestController { * Returns an HTML simple response. * * @return \Symfony\Component\HttpFoundation\Response + * A simple HTML response. */ public function simple() { return new Response('<html><body>PathEncodedTestController works</body></html>'); diff --git a/core/modules/system/tests/modules/performance_test/src/Cache/CacheBackendDecorator.php b/core/modules/system/tests/modules/performance_test/src/Cache/CacheBackendDecorator.php index 361a6f2eba1d1f29a8e2933aacd26a9e9caefe3e..120cd312e82435ef5eb2ffe6fa17b91e152fdd0c 100644 --- a/core/modules/system/tests/modules/performance_test/src/Cache/CacheBackendDecorator.php +++ b/core/modules/system/tests/modules/performance_test/src/Cache/CacheBackendDecorator.php @@ -27,8 +27,6 @@ public function __construct(protected readonly PerformanceDataCollector $perform * The stop microtime. * @param string $operation * The type of operation being logged. - * - * @return void */ protected function logCacheOperation(string|array $cids, float $start, float $stop, string $operation): void { $this->performanceDataCollector->addCacheOperation([ diff --git a/core/modules/system/tests/modules/performance_test/src/Cache/CacheTagsChecksumDecorator.php b/core/modules/system/tests/modules/performance_test/src/Cache/CacheTagsChecksumDecorator.php index dd4675f4b62ef892a6b6903d57f972c0505006fd..23be1b43a1600517e3115de30bfe187bff6a94b1 100644 --- a/core/modules/system/tests/modules/performance_test/src/Cache/CacheTagsChecksumDecorator.php +++ b/core/modules/system/tests/modules/performance_test/src/Cache/CacheTagsChecksumDecorator.php @@ -90,8 +90,6 @@ public function registerCacheTagsForPreload(array $cache_tags): void { * The stop microtime. * @param \Drupal\performance_test\Cache\CacheTagOperation $operation * The type of operation being logged. - * - * @return void */ protected function logCacheTagOperation(array $tags, float $start, float $stop, CacheTagOperation $operation): void { $this->performanceDataCollector->addCacheTagOperation([ diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php index c6c078b62156cbe108c4370baf1fd5ef7fe4ffd8..15784dc6a85029f55a0d2152c6e0e487dfad9c36 100644 --- a/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php +++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php @@ -140,6 +140,7 @@ public function __construct() { * Whether the context definition is required. * * @return \Drupal\Core\Plugin\Context\ContextDefinition + * The context definition object. */ protected function createContextDefinition($data_type, $label, $required = TRUE) { // We cast the label to string for testing purposes only, as it may be diff --git a/core/modules/system/tests/modules/render_array_non_html_subscriber_test/src/RenderArrayNonHtmlSubscriberTestController.php b/core/modules/system/tests/modules/render_array_non_html_subscriber_test/src/RenderArrayNonHtmlSubscriberTestController.php index 41f2c7942660e55474f4496ffdc1b276ea91dca4..244c8284034f76ba4f63ddb8b9ad69178d00c6b9 100644 --- a/core/modules/system/tests/modules/render_array_non_html_subscriber_test/src/RenderArrayNonHtmlSubscriberTestController.php +++ b/core/modules/system/tests/modules/render_array_non_html_subscriber_test/src/RenderArrayNonHtmlSubscriberTestController.php @@ -14,6 +14,7 @@ class RenderArrayNonHtmlSubscriberTestController extends ControllerBase { /** * @return string + * The value of raw string. */ public function rawString() { return new Response((string) $this->t('Raw controller response.')); @@ -21,6 +22,7 @@ public function rawString() { /** * @return array + * The value of render array. */ public function renderArray() { return [ diff --git a/core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php b/core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php index 155d13ba6c92ede19be8dc48be3502a10bbbe60d..82cf68ddd3c886d6c2e56324b491a8611e4f2b1f 100644 --- a/core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php +++ b/core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php @@ -35,6 +35,7 @@ public static function create(ContainerInterface $container) { /** * @return array + * A renderable array with the messages placeholder rendered first. */ public function messagesPlaceholderFirst() { return $this->build([ @@ -48,6 +49,7 @@ public function messagesPlaceholderFirst() { /** * @return array + * A renderable array with the messages placeholder rendered in the middle. */ public function messagesPlaceholderMiddle() { return $this->build([ @@ -61,6 +63,7 @@ public function messagesPlaceholderMiddle() { /** * @return array + * A renderable array with the messages placeholder rendered last. */ public function messagesPlaceholderLast() { return $this->build([ @@ -74,6 +77,7 @@ public function messagesPlaceholderLast() { /** * @return array + * A renderable array containing only messages. */ public function queuedMessages() { return ['#type' => 'status_messages']; @@ -81,16 +85,23 @@ public function queuedMessages() { /** * @return array + * A renderable array containing only placeholders. */ protected function build(array $placeholder_order) { $build = []; $build['messages'] = ['#type' => 'status_messages']; $build['p1'] = [ - '#lazy_builder' => ['\Drupal\render_placeholder_message_test\RenderPlaceholderMessageTestController::setAndLogMessage', ['P1']], + '#lazy_builder' => [ + '\Drupal\render_placeholder_message_test\RenderPlaceholderMessageTestController::setAndLogMessage', + ['P1'], + ], '#create_placeholder' => TRUE, ]; $build['p2'] = [ - '#lazy_builder' => ['\Drupal\render_placeholder_message_test\RenderPlaceholderMessageTestController::setAndLogMessage', ['P2']], + '#lazy_builder' => [ + '\Drupal\render_placeholder_message_test\RenderPlaceholderMessageTestController::setAndLogMessage', + ['P2'], + ], '#create_placeholder' => TRUE, ]; diff --git a/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php b/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php index 0bd18025888bcd355e9baa2220c1538e332ca3c1..9db12e830df371a60bbb2ca62c32f94ce5a9b24b 100644 --- a/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php +++ b/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php @@ -72,7 +72,10 @@ public function getId(Request $request) { * A notification message with session ID. */ public function getIdFromCookie(Request $request) { - return ['#markup' => 'session_id:' . $request->cookies->get(session_name()) . "\n", '#cache' => ['contexts' => ['cookies:' . session_name()]]]; + return [ + '#markup' => 'session_id:' . $request->cookies->get(session_name()) . "\n", + '#cache' => ['contexts' => ['cookies:' . session_name()]], + ]; } /** diff --git a/core/modules/system/tests/modules/system_test/src/Controller/PageCacheAcceptHeaderController.php b/core/modules/system/tests/modules/system_test/src/Controller/PageCacheAcceptHeaderController.php index 9a83cb3615dca2c38439c24f4be9ce3f7b0184e2..e6e700c9dd9b91b03ed7486aa1e87e35d56618cc 100644 --- a/core/modules/system/tests/modules/system_test/src/Controller/PageCacheAcceptHeaderController.php +++ b/core/modules/system/tests/modules/system_test/src/Controller/PageCacheAcceptHeaderController.php @@ -22,6 +22,7 @@ class PageCacheAcceptHeaderController { * The current request object. * * @return mixed + * The processed response object. */ public function content(Request $request) { if ($request->getRequestFormat() === 'json' && $request->query->get('_wrapper_format') === 'drupal_ajax') { diff --git a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php index abbe8970a43589d60141385e2a4e3907f0cbbdb4..566968fe2d03a754b9e183c1a60041fe69c5b021 100644 --- a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php +++ b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php @@ -305,7 +305,10 @@ public function setHeader(Request $request) { $response = new CacheableResponse(); $response->headers->set($query['name'], $query['value']); $response->getCacheableMetadata()->addCacheContexts(['url.query_args:name', 'url.query_args:value']); - $response->setContent((string) $this->t('The following header was set: %name: %value', ['%name' => $query['name'], '%value' => $query['value']])); + $response->setContent((string) $this->t('The following header was set: %name: %value', [ + '%name' => $query['name'], + '%value' => $query['value'], + ])); return $response; } @@ -354,6 +357,7 @@ public function shutdownFunctions($arg1, $arg2) { * Any string for the {foo} slug. * * @return string + * The value of title. */ public function configureTitle($foo) { return 'Bar.' . $foo; diff --git a/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestHooks.php b/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestHooks.php index f0669b10614e4f4f7b7bddc10dcc245c1b18a861..8e27524449f14313834669e148cc2c3c13b20f50 100644 --- a/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestHooks.php +++ b/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestHooks.php @@ -24,7 +24,12 @@ public function theme($existing, $type, $theme, $path) : array { $items['theme_test_suggestion_provided'] = ['variables' => []]; $items['theme_test_specific_suggestions'] = ['variables' => []]; $items['theme_test_suggestions'] = ['variables' => []]; - $items['theme_test_general_suggestions'] = ['variables' => ['module_hook' => 'theme_test_theme', 'theme_hook' => 'none']]; + $items['theme_test_general_suggestions'] = [ + 'variables' => [ + 'module_hook' => 'theme_test_theme', + 'theme_hook' => 'none', + ], + ]; $items['theme_test_foo'] = ['variables' => ['foo' => NULL]]; $items['theme_test_render_element'] = ['render element' => 'elements']; $items['theme_test_render_element_children'] = ['render element' => 'element']; @@ -61,7 +66,10 @@ public function theme($existing, $type, $theme, $path) : array { */ #[Hook('theme_registry_alter')] public function themeRegistryAlter(&$registry): void { - $registry['theme_test_preprocess_callback']['preprocess functions'][] = ['\Drupal\theme_test\ThemeTestPreprocess', 'preprocess']; + $registry['theme_test_preprocess_callback']['preprocess functions'][] = [ + '\Drupal\theme_test\ThemeTestPreprocess', + 'preprocess', + ]; } /** diff --git a/core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php b/core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php index 38ee0a54ce5763dcc8ca2ac8cd309b7d4da2ad2f..58bc35f7166f3e448fa0b23b8d63b04dc9d65ba7 100644 --- a/core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php +++ b/core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php @@ -27,7 +27,10 @@ class TestExtension extends AbstractExtension { */ public function getFunctions() { return [ - 'custom_function' => new TwigFunction('custom_function', ['Drupal\twig_extension_test\TwigExtension\TestExtension', 'testFunction']), + 'custom_function' => new TwigFunction('custom_function', [ + 'Drupal\twig_extension_test\TwigExtension\TestExtension', + 'testFunction', + ]), ]; } @@ -45,7 +48,10 @@ public function getFunctions() { */ public function getFilters() { return [ - 'test_filter' => new TwigFilter('test_filter', ['Drupal\twig_extension_test\TwigExtension\TestExtension', 'testFilter']), + 'test_filter' => new TwigFilter('test_filter', [ + 'Drupal\twig_extension_test\TwigExtension\TestExtension', + 'testFilter', + ]), ]; } diff --git a/core/modules/system/tests/src/Functional/Ajax/OffCanvasDialogTest.php b/core/modules/system/tests/src/Functional/Ajax/OffCanvasDialogTest.php index 6c84e168cdac136e8c32afdaa4709242e979cfa4..51ee8e9184bafec4fe880e16c92e933d88a887e7 100644 --- a/core/modules/system/tests/src/Functional/Ajax/OffCanvasDialogTest.php +++ b/core/modules/system/tests/src/Functional/Ajax/OffCanvasDialogTest.php @@ -74,6 +74,7 @@ public function testDialog($position): void { * The data provider for potential dialog positions. * * @return array + * An array of dialog positions. */ public static function dialogPosition() { return [ diff --git a/core/modules/system/tests/src/Functional/DrupalKernel/ContainerResetWebTest.php b/core/modules/system/tests/src/Functional/DrupalKernel/ContainerResetWebTest.php index 6c6bd5eb5f0b15eb3c02d75759252f8dac914fa9..9998685df3fd43cf8613e6c741dbc0814b52f7f7 100644 --- a/core/modules/system/tests/src/Functional/DrupalKernel/ContainerResetWebTest.php +++ b/core/modules/system/tests/src/Functional/DrupalKernel/ContainerResetWebTest.php @@ -26,6 +26,9 @@ class ContainerResetWebTest extends BrowserTestBase { */ protected $defaultTheme = 'stark'; + /** + * {@inheritdoc} + */ protected function setUp(): void { parent::setUp(); ConfigurableLanguage::createFromLangcode('es')->save(); diff --git a/core/modules/system/tests/src/Functional/Entity/EntityComputedFieldTest.php b/core/modules/system/tests/src/Functional/Entity/EntityComputedFieldTest.php index 66dce7a06190e8a856a9570075a85f1cfbe1a0e3..7676e1ac53947738ec5efe6bb3a91612ef2da92b 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityComputedFieldTest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityComputedFieldTest.php @@ -33,6 +33,9 @@ class EntityComputedFieldTest extends BrowserTestBase { */ protected StateInterface $state; + /** + * {@inheritdoc} + */ protected function setUp(): void { parent::setUp(); diff --git a/core/modules/system/tests/src/Functional/Extension/LegacyHookTest.php b/core/modules/system/tests/src/Functional/Extension/LegacyHookTest.php index 75045ecad4cc6b514aa23c643d4ec2747fb7a629..1d0f02188922b7b33e427486df890bd01124b12e 100644 --- a/core/modules/system/tests/src/Functional/Extension/LegacyHookTest.php +++ b/core/modules/system/tests/src/Functional/Extension/LegacyHookTest.php @@ -23,6 +23,9 @@ class LegacyHookTest extends BrowserTestBase { */ protected $defaultTheme = 'stark'; + /** + * Tests the LegacyHook attribute. + */ public function testLegacyHook(): void { // Calling legacy_hook_test1 leads to a fatal error so there's no need // for asserts to show it does not get called. diff --git a/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php b/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php index a20a387155efa8d57a5a324d1efffb96c68f5de7..adbc957348aef33f7e1b63998fa13b63f2b60afa 100644 --- a/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php +++ b/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php @@ -33,6 +33,9 @@ protected function setUp(): void { $this->testConnection = TestFileTransfer::factory($this->root, []); } + /** + * Returns a predefined list of fake module files for testing. + */ public function _getFakeModuleFiles() { $files = [ 'fake.module', @@ -47,6 +50,9 @@ public function _getFakeModuleFiles() { return $files; } + /** + * Builds a fake module directory for testing. + */ public function _buildFakeModule() { $location = 'temporary://fake'; if (is_dir($location)) { @@ -63,6 +69,9 @@ public function _buildFakeModule() { return $location; } + /** + * Writes a directory structure to the filesystem. + */ public function _writeDirectory($base, $files = []): void { mkdir($base); foreach ($files as $key => $file) { @@ -76,6 +85,9 @@ public function _writeDirectory($base, $files = []): void { } } + /** + * Tests the file transfer jail. + */ public function testJail(): void { $source = $this->_buildFakeModule(); diff --git a/core/modules/system/tests/src/Functional/FileTransfer/MockTestConnection.php b/core/modules/system/tests/src/Functional/FileTransfer/MockTestConnection.php index 3cfcdf43a6fcad9039cb450832a39c1db72b02d3..f842358b66497803336305b823bec9b82d483a8b 100644 --- a/core/modules/system/tests/src/Functional/FileTransfer/MockTestConnection.php +++ b/core/modules/system/tests/src/Functional/FileTransfer/MockTestConnection.php @@ -23,10 +23,16 @@ class MockTestConnection { */ public $connectionString; + /** + * Executes a command and stores it in the command history. + */ public function run($cmd) { $this->commandsRun[] = $cmd; } + /** + * Retrieves and clears the command history. + */ public function flushCommands() { $out = $this->commandsRun; $this->commandsRun = []; diff --git a/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php b/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php index fa82dd6a01c283c628d198971af439c590fff36c..42605c114ffab5e7869edabbef6c5549c04d6a0f 100644 --- a/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php +++ b/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php @@ -38,11 +38,17 @@ class TestFileTransfer extends FileTransfer { */ public $shouldIsDirectoryReturnTrue = FALSE; + /** + * Factory method to create a TestFileTransfer instance. + */ public static function factory($jail, $settings) { assert(is_array($settings)); return new TestFileTransfer($jail); } + /** + * Establishes a mock connection for file transfer. + */ public function connect() { $this->connection = new MockTestConnection(); // Access the connection via the property. The property used to be set via a @@ -50,30 +56,51 @@ public function connect() { $this->connection->connectionString = 'test://' . urlencode($this->username) . ':' . urlencode($this->password) . "@$this->host:$this->port/"; } + /** + * Copies a file within the jailed environment. + */ public function copyFileJailed($source, $destination) { $this->connection->run("copyFile $source $destination"); } + /** + * Removes a directory within the jailed environment. + */ protected function removeDirectoryJailed($directory) { $this->connection->run("rmdir $directory"); } + /** + * Creates a directory within the jailed environment. + */ public function createDirectoryJailed($directory) { $this->connection->run("mkdir $directory"); } + /** + * Removes a file within the jailed environment. + */ public function removeFileJailed($destination) { $this->connection->run("rm $destination"); } + /** + * Checks if a path is a directory. + */ public function isDirectory($path) { return $this->shouldIsDirectoryReturnTrue; } + /** + * Checks if a path is a file. + */ public function isFile($path) { return FALSE; } + /** + * Stub function for changing file permissions within the jailed environment. + */ public function chmodJailed($path, $mode, $recursive) {} } diff --git a/core/modules/system/tests/src/Functional/Form/CheckboxTest.php b/core/modules/system/tests/src/Functional/Form/CheckboxTest.php index 40146c654cb5db88125a29dd10645a90829e6824..9d442b27f33369bd7b4856c123fb2612ec90543f 100644 --- a/core/modules/system/tests/src/Functional/Form/CheckboxTest.php +++ b/core/modules/system/tests/src/Functional/Form/CheckboxTest.php @@ -25,6 +25,9 @@ class CheckboxTest extends BrowserTestBase { */ protected $defaultTheme = 'stark'; + /** + * Tests various checkbox configurations in the form API. + */ public function testFormCheckbox(): void { // Ensure that the checked state is determined and rendered correctly for // tricky combinations of default and return values. diff --git a/core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php b/core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php index 12b0e49342a9c2642b85572c76ab7f370831fd4e..213e4b2e5ff11bf506b13e2b1ddb1ca5af4b33c3 100644 --- a/core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php +++ b/core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php @@ -24,6 +24,9 @@ class ConfirmFormTest extends BrowserTestBase { */ protected $defaultTheme = 'stark'; + /** + * Tests the confirm form functionality, including submission and cancellation. + */ public function testConfirmForm(): void { // Test the building of the form. $this->drupalGet('form-test/confirm-form'); diff --git a/core/modules/system/tests/src/Functional/Form/ElementTest.php b/core/modules/system/tests/src/Functional/Form/ElementTest.php index 04d809d8107f18903d710545811af3fdee904d34..4a9755fac7f5fae1ab9fd2889ee203aac26ff020 100644 --- a/core/modules/system/tests/src/Functional/Form/ElementTest.php +++ b/core/modules/system/tests/src/Functional/Form/ElementTest.php @@ -32,6 +32,7 @@ public function testFormElements(): void { $this->testRadiosChecked(); $this->testWrapperIds(); $this->testButtonClasses(); + $this->testSubmitButtonAttribute(); $this->testGroupElements(); $this->testRequiredFieldsetsAndDetails(); $this->testFormAutocomplete(); @@ -148,6 +149,18 @@ protected function testButtonClasses(): void { $this->assertSession()->elementsCount('xpath', '//*[contains(concat(" ", @class, " "), " button--danger ")]', 1); } + /** + * Tests the submit_button attribute. + */ + protected function testSubmitButtonAttribute(): void { + // Set the submit_button attribute to true + $this->drupalGet('form-test/submit-button-attribute'); + $this->assertSession()->elementsCount('xpath', '//input[@type="submit"]', 1); + // Set the submit_button attribute to false + $this->drupalGet('form-test/submit-button-attribute/1'); + $this->assertSession()->elementsCount('xpath', '//input[@type="button"]', 1); + } + /** * Tests the #group property. */ diff --git a/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php b/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php index 53c49972d03de943ec9c38c04f37ae5b1f5d733b..0163c594a0689a08a3428210cf9be9f99c8be007 100644 --- a/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php +++ b/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php @@ -56,6 +56,9 @@ protected function setUp(): void { user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access user profiles']); } + /** + * Tests access denied functionality. + */ public function testAccessDenied(): void { $this->drupalGet('admin'); $this->assertSession()->pageTextContains('Access denied'); diff --git a/core/modules/system/tests/src/Functional/System/AdminTest.php b/core/modules/system/tests/src/Functional/System/AdminTest.php index 021e7bdcea2a8b3b9cd32b6921a553c41fddb0f4..ee9935b6fea584089c0d73b0875953e28786f41d 100644 --- a/core/modules/system/tests/src/Functional/System/AdminTest.php +++ b/core/modules/system/tests/src/Functional/System/AdminTest.php @@ -132,6 +132,7 @@ public function testAdminPages(): void { * Returns all top level menu links. * * @return \Drupal\Core\Menu\MenuLinkTreeElement[] + * The top level menu links. */ protected function getTopLevelMenuLinks() { $menu_tree = \Drupal::menuTree(); diff --git a/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php b/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php index 0fc85e79cceb29e241a69a9dccf7efdf8889cdbf..7fe74aafcc54af698189fa9830baae9d1fdf3192 100644 --- a/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php +++ b/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php @@ -52,6 +52,9 @@ protected function setUp(): void { user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access user profiles']); } + /** + * Tests page not found. + */ public function testPageNotFound(): void { $this->drupalLogin($this->adminUser); $this->drupalGet($this->randomMachineName(10)); diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/DependencyMissingTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/DependencyMissingTest.php index dc365d62a05086e1d7acde97109dc164a75d2233..fbe710a22783acfe1c9144f7d21d277dc04ff563 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/DependencyMissingTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/DependencyMissingTest.php @@ -33,6 +33,9 @@ protected function setUp(): void { require_once $this->root . '/core/includes/update.inc'; } + /** + * Tests updating with a missing dependency. + */ public function testMissingUpdate(): void { $starting_updates = [ 'update_test_2' => 8001, diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/InvalidUpdateHookTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/InvalidUpdateHookTest.php index 2ca80008e6b0d4c3412085473f6a25de1bee0c50..eefcdea1663c97cb3f7ed70b6515325f76d080ce 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/InvalidUpdateHookTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/InvalidUpdateHookTest.php @@ -58,6 +58,9 @@ protected function setUp(): void { ]); } + /** + * Tests updating from a module with a hook_update_8000(). + */ public function testInvalidUpdateHook(): void { // Confirm that a module with hook_update_8000() cannot be updated. $this->drupalLogin($this->updateUser); diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatesWith7xTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatesWith7xTest.php index f9ed93db0e8acee3ec9153cc721c66c0a321fa96..4463ad1f2bcaad720c552a5174fecd9e96f0e424 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatesWith7xTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatesWith7xTest.php @@ -53,6 +53,9 @@ protected function setUp(): void { ]); } + /** + * Tests updating from Drupal 7. + */ public function testWith7x(): void { /** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */ $update_registry = \Drupal::service('update.update_hook_registry'); diff --git a/core/modules/system/tests/src/FunctionalJavascript/Form/DevelopmentSettingsFormTest.php b/core/modules/system/tests/src/FunctionalJavascript/Form/DevelopmentSettingsFormTest.php index 49943d8023b789b54c7b825454512f0fa924a574..30f50b7bd0afcdd0af4c5986ff4ec11aa529563f 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/Form/DevelopmentSettingsFormTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/Form/DevelopmentSettingsFormTest.php @@ -86,6 +86,7 @@ public function testTwigDevelopmentMode(bool $twig_development_mode, ?bool $twig * Test data for Twig development mode. * * @return array[] + * An array of test data. */ public static function twigDevelopmentData(): array { return [ diff --git a/core/modules/system/tests/src/FunctionalJavascript/ModuleUninstallFilterTest.php b/core/modules/system/tests/src/FunctionalJavascript/ModuleUninstallFilterTest.php index e89ac08ec8375d37c326b3d9f6a124cf87bf422b..2652b322578399da66ac4686539eb8449e7c3472 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/ModuleUninstallFilterTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/ModuleUninstallFilterTest.php @@ -89,6 +89,7 @@ public function testModuleUninstallFilter(): void { * An array of node elements. * * @return \Behat\Mink\Element\NodeElement[] + * An array of node elements that are visible. */ protected function filterVisibleElements($elements) { $elements = array_filter($elements, function ($element) { diff --git a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php index f09aaef10eb410144e46ce945ef7a1472c9bdc20..188e1bac91880c99c880f87114805e0520f146dd 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php +++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php @@ -94,6 +94,7 @@ protected function waitForOffCanvasToClose() { * Gets the off-canvas dialog element. * * @return \Behat\Mink\Element\NodeElement|null + * The off-canvas dialog element. */ protected function getOffCanvasDialog() { $off_canvas_dialog = $this->getSession()->getPage()->find('css', '.ui-dialog[aria-describedby="drupal-off-canvas"]'); diff --git a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php index 2cb413a7e42ffaffd0e609f43d2f426dab6dbd3c..48f7df788a1ccc6a0b37cc65797b3d36de344156 100644 --- a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php +++ b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php @@ -313,6 +313,7 @@ public function testConfigExpanded($active_route, $menu_block_level, $expected_i /** * @return array + * An array of test cases for the config expanded option. */ public static function configExpandedTestCases() { return [ diff --git a/core/modules/system/tests/src/Kernel/Entity/EntityReferenceSelectionReferenceableTest.php b/core/modules/system/tests/src/Kernel/Entity/EntityReferenceSelectionReferenceableTest.php index c81bb7c0dd6ae8192b04df764a8e14742b190165..8c9d95e0ca66315718086edb10ac863eaff4d2c1 100644 --- a/core/modules/system/tests/src/Kernel/Entity/EntityReferenceSelectionReferenceableTest.php +++ b/core/modules/system/tests/src/Kernel/Entity/EntityReferenceSelectionReferenceableTest.php @@ -143,6 +143,7 @@ public function testReferenceablesWithNoLabelKey($match, $match_operator, $limit * Provides test cases for ::testReferenceablesWithNoLabelKey() test. * * @return array[] + * An array of test cases. */ public static function providerTestCases() { return [ diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php index 3d16ce748fd9073829940592efbfcfa5eb6c9b9c..aa0af090c19ff629eb86083ab47f60bbbfc1a61a 100644 --- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php @@ -365,6 +365,7 @@ public function testThemeMetaData(): void { * Returns the ModuleHandler. * * @return \Drupal\Core\Extension\ModuleHandlerInterface + * The module handler service. */ protected function moduleHandler() { return $this->container->get('module_handler'); @@ -374,6 +375,7 @@ protected function moduleHandler() { * Returns the ModuleInstaller. * * @return \Drupal\Core\Extension\ModuleInstallerInterface + * The module installer service. */ protected function moduleInstaller() { return $this->container->get('module_installer'); diff --git a/core/modules/system/tests/src/Kernel/Installer/InstallTranslationFilePatternTest.php b/core/modules/system/tests/src/Kernel/Installer/InstallTranslationFilePatternTest.php index 619f7744ec1bc77902b8242bcdaa8e42436b313b..46f9e1409d74805c7ec787eda52444efab665be3 100644 --- a/core/modules/system/tests/src/Kernel/Installer/InstallTranslationFilePatternTest.php +++ b/core/modules/system/tests/src/Kernel/Installer/InstallTranslationFilePatternTest.php @@ -49,6 +49,7 @@ public function testFilesPatternValid($langcode, $filename): void { /** * @return array + * Array of valid translation files. */ public static function providerValidTranslationFiles() { return [ @@ -68,6 +69,7 @@ public function testFilesPatternInvalid($langcode, $filename): void { /** * @return array + * Array of invalid translation files. */ public static function providerInvalidTranslationFiles() { return [ diff --git a/core/modules/taxonomy/src/Entity/Routing/VocabularyRouteProvider.php b/core/modules/taxonomy/src/Entity/Routing/VocabularyRouteProvider.php index 778da1e046c78a13b7d31f4ac546e0bc72ef342d..7b2f2ca0b325dd4cdb33693d6de3b7c619228820 100644 --- a/core/modules/taxonomy/src/Entity/Routing/VocabularyRouteProvider.php +++ b/core/modules/taxonomy/src/Entity/Routing/VocabularyRouteProvider.php @@ -6,6 +6,9 @@ use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; use Symfony\Component\Routing\Route; +/** + * Provides routes for the taxonomy vocabulary. + */ class VocabularyRouteProvider extends AdminHtmlRouteProvider { /** diff --git a/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php b/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php index 716c937f8f44744d113a40d65c23513e8355596a..7b7a57363bc548a2035facf773d177764be88cb5 100644 --- a/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php +++ b/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php @@ -45,7 +45,7 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf * @param string $plugin_id * The plugin ID for the plugin instance. * @param mixed $plugin_definition - * The plugin implementation definition. * + * The plugin implementation definition. * @param \Drupal\Core\Routing\RouteMatchInterface $route_match * The route match. * @param \Drupal\taxonomy\VocabularyStorageInterface $vocabulary_storage diff --git a/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php b/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php index d844b543d5cc2436cec275b07cc0614de9c7d1c6..f36f28c1d6067b6ac5a93a842da9a2ed2fcf98d0 100644 --- a/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php +++ b/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php @@ -372,6 +372,9 @@ public function testGetTermWithParent(array $parent_term_ids): void { $this->assertSame($expected, $actual); } + /** + * Data provider for ::testGetTermWithParent(). + */ public static function providerTestGetTermWithParent() { return [ 'root parent: [0] (= no parent)' => [ diff --git a/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php b/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php index bceadd594b121994f170519332824dcc398ec92f..4fa2b896c2532f76cd3796f43c78a7d28776a8b3 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php @@ -52,6 +52,9 @@ protected function setUp(): void { } } + /** + * Tests the language of a term. + */ public function testTermLanguage(): void { // Configure the vocabulary to not hide the language selector. $edit = [ @@ -90,6 +93,9 @@ public function testTermLanguage(): void { $this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', $edit['langcode[0][value]'])->isSelected()); } + /** + * Tests the default language selection for taxonomy terms. + */ public function testDefaultTermLanguage(): void { // Configure the vocabulary to not hide the language selector, and make the // default language of the terms fixed. diff --git a/core/modules/taxonomy/tests/src/Functional/TermParentsTest.php b/core/modules/taxonomy/tests/src/Functional/TermParentsTest.php index bce865a4a98cdf5f2ca9d993926c351a36e21c5b..59ab2ecf3c9a4bae08dfcdbca1b6645598d4d1f3 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermParentsTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermParentsTest.php @@ -302,7 +302,7 @@ public function testParentFromQuery(): void { * Creates a term, saves it and returns it. * * @param string $name - * The name of the term to create + * The name of the term to create. * @param int[] $parent_ids * (optional) A list of parent term IDs. * diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularySerializationTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularySerializationTest.php index 1aefd30e8e14f269f2d51f878455f6de3142d91f..5ad30b54ddd9923a978a58ad660dac401f706234 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularySerializationTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularySerializationTest.php @@ -39,6 +39,9 @@ protected function setUp(): void { Vocabulary::create(['vid' => 'test', 'name' => 'Test'])->save(); } + /** + * Tests that a Vocabulary entity can be serialized and cached correctly. + */ public function testSerialization(): void { $this->drupalGet('/vocabulary_serialization_test/test'); $this->assertSession()->statusCodeEquals(200); diff --git a/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php b/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php index 12600f30dde4d2cff48177833b898121deae8b9b..d34978a661843003b0858221942d62feec9a5ebc 100644 --- a/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php @@ -100,17 +100,16 @@ public function testTaxonomyVocabularyTree(): void { $term[5]->parent = [$term[4]->id()]; $term[5]->save(); - /** - * Expected tree: - * term[0] | depth: 0 - * term[1] | depth: 0 - * -- term[2] | depth: 1 - * ---- term[3] | depth: 2 - * term[4] | depth: 0 - * -- term[5] | depth: 1 - * ---- term[2] | depth: 2 - * ------ term[3] | depth: 3 - */ + // Expected tree: + // term[0] | depth: 0 + // term[1] | depth: 0 + // -- term[2] | depth: 1 + // ---- term[3] | depth: 2 + // term[4] | depth: 0 + // -- term[5] | depth: 1 + // ---- term[2] | depth: 2 + // ------ term[3] | depth: 3 + // Count $term[1] parents with $max_depth = 1. $tree = $taxonomy_storage->loadTree($vocabulary->id(), $term[1]->id(), 1); $this->assertCount(1, $tree, 'We have one parent with depth 1.'); diff --git a/core/modules/telephone/src/Plugin/migrate/field/d7/PhoneField.php b/core/modules/telephone/src/Plugin/migrate/field/d7/PhoneField.php index 1cc9b7f7ae9d9d3ccbef1b2eca267149a9696639..6f81c0044fb77bcb2588c107e984fffdb3c3e179 100644 --- a/core/modules/telephone/src/Plugin/migrate/field/d7/PhoneField.php +++ b/core/modules/telephone/src/Plugin/migrate/field/d7/PhoneField.php @@ -5,6 +5,9 @@ use Drupal\migrate_drupal\Attribute\MigrateField; use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase; +/** + * Migrate field plugin for Drupal 7 phone fields. + */ #[MigrateField( id: 'phone', core: [7], diff --git a/core/modules/telephone/src/Plugin/migrate/field/d7/TelephoneField.php b/core/modules/telephone/src/Plugin/migrate/field/d7/TelephoneField.php index 88410513f2952fefe8d133fee66e573978815ef1..32d0d1b726af3172e7eccee1bf5bd3d8400bedfa 100644 --- a/core/modules/telephone/src/Plugin/migrate/field/d7/TelephoneField.php +++ b/core/modules/telephone/src/Plugin/migrate/field/d7/TelephoneField.php @@ -5,6 +5,9 @@ use Drupal\migrate_drupal\Attribute\MigrateField; use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase; +/** + * Migrate field plugin for Drupal 7 telephone fields. + */ #[MigrateField( id: 'telephone', core: [7], diff --git a/core/modules/text/src/Plugin/migrate/field/d7/TextField.php b/core/modules/text/src/Plugin/migrate/field/d7/TextField.php index 54e9db27d0f5b72b8513cd4890334ca497f4457d..d75ed7323ecbd70a3ab9b85dac7f206704000f3e 100644 --- a/core/modules/text/src/Plugin/migrate/field/d7/TextField.php +++ b/core/modules/text/src/Plugin/migrate/field/d7/TextField.php @@ -7,6 +7,9 @@ use Drupal\migrate_drupal\Attribute\MigrateField; use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase; +/** + * Migrate field plugin for Drupal 7 text fields. + */ #[MigrateField( id: 'd7_text', core: [7], diff --git a/core/modules/update/src/UpdateManager.php b/core/modules/update/src/UpdateManager.php index 19335e128558d86ed0ba4da5af1e2b41f72def40..06372fec3f5a7e436a5e5ee94eb35ce981a71576 100644 --- a/core/modules/update/src/UpdateManager.php +++ b/core/modules/update/src/UpdateManager.php @@ -89,7 +89,7 @@ class UpdateManager implements UpdateManagerInterface { * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The Module Handler service + * The Module Handler service. * @param \Drupal\update\UpdateProcessorInterface $update_processor * The Update Processor service. * @param \Drupal\Core\StringTranslation\TranslationInterface $translation diff --git a/core/modules/update/src/UpdateProcessor.php b/core/modules/update/src/UpdateProcessor.php index 4945a478490ba2b5ed7d81965e0b73cf389aca7c..a34adb3bfd9c7c3d1dba1f3d47eaa2577fb88c19 100644 --- a/core/modules/update/src/UpdateProcessor.php +++ b/core/modules/update/src/UpdateProcessor.php @@ -90,9 +90,9 @@ class UpdateProcessor implements UpdateProcessorInterface { * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. * @param \Drupal\Core\Queue\QueueFactory $queue_factory - * The queue factory + * The queue factory. * @param \Drupal\update\UpdateFetcherInterface $update_fetcher - * The update fetcher service + * The update fetcher service. * @param \Drupal\Core\State\StateInterface $state_store * The state service. * @param \Drupal\Core\PrivateKey $private_key diff --git a/core/modules/update/tests/src/Functional/UpdateSemverTestBaselineTrait.php b/core/modules/update/tests/src/Functional/UpdateSemverTestBaselineTrait.php index 852332bd4fd020f36e2d0fde811f57942b6cb2a6..db0b33ae9971b75adf967fda3f33ccc1d2a75859 100644 --- a/core/modules/update/tests/src/Functional/UpdateSemverTestBaselineTrait.php +++ b/core/modules/update/tests/src/Functional/UpdateSemverTestBaselineTrait.php @@ -109,8 +109,6 @@ public function testNormalUpdateAvailable(): void { * * @param string $full_version * The recommended version. - * - * @return void */ protected function assertNoExtraVersion(string $full_version): void { $this->assertUpdateTableTextNotContains('Up to date'); diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserCancelMethodsConstraint.php b/core/modules/user/src/Plugin/Validation/Constraint/UserCancelMethodsConstraint.php index 483c6a8dce1a5a3f934daa89a5d6a04ef0b4d2de..44034b3d3db291947c3dafa251205ad223e2f7b0 100644 --- a/core/modules/user/src/Plugin/Validation/Constraint/UserCancelMethodsConstraint.php +++ b/core/modules/user/src/Plugin/Validation/Constraint/UserCancelMethodsConstraint.php @@ -10,6 +10,9 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Validator\Constraints\Choice; +/** + * Constraint for the user cancel method. + */ #[Constraint( id: 'UserCancelMethod', label: new TranslatableMarkup('UserCancelMethod', [], ['context' => 'Validation']), diff --git a/core/modules/user/src/Plugin/migrate/destination/EntityUser.php b/core/modules/user/src/Plugin/migrate/destination/EntityUser.php index 52c679d8a3e60ba9129097521328e288caa3a95a..29b2985ffc255dc2295513b8e9afac9282c42431 100644 --- a/core/modules/user/src/Plugin/migrate/destination/EntityUser.php +++ b/core/modules/user/src/Plugin/migrate/destination/EntityUser.php @@ -5,6 +5,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EmailItem; use Drupal\Core\Password\PasswordInterface; @@ -96,9 +97,11 @@ class EntityUser extends EntityContentBase { * The password service. * @param \Drupal\Core\Session\AccountSwitcherInterface|null $account_switcher * The account switcher service. + * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface|null $entity_type_bundle_info + * The entity type bundle info service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, PasswordInterface $password, ?AccountSwitcherInterface $account_switcher = NULL) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_field_manager, $field_type_manager, $account_switcher); + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, PasswordInterface $password, ?AccountSwitcherInterface $account_switcher = NULL, ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_field_manager, $field_type_manager, $account_switcher, $entity_type_bundle_info); $this->password = $password; } @@ -117,7 +120,8 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('entity_field.manager'), $container->get('plugin.manager.field.field_type'), $container->get('password'), - $container->get('account_switcher') + $container->get('account_switcher'), + $container->get('entity_type.bundle.info'), ); } diff --git a/core/modules/user/src/Plugin/migrate/process/ProfileFieldSettings.php b/core/modules/user/src/Plugin/migrate/process/ProfileFieldSettings.php index f25b5170d633dbe46fbdd4d054ef08a498858af2..021df6b5c876bb775c280213b3bda9b45ce664e5 100644 --- a/core/modules/user/src/Plugin/migrate/process/ProfileFieldSettings.php +++ b/core/modules/user/src/Plugin/migrate/process/ProfileFieldSettings.php @@ -7,6 +7,9 @@ use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; +/** + * Determines the settings for the profile field. + */ #[MigrateProcess('profile_field_settings')] class ProfileFieldSettings extends ProcessPluginBase { diff --git a/core/modules/user/tests/modules/user_access_test/src/Hook/UserAccessTestHooks.php b/core/modules/user/tests/modules/user_access_test/src/Hook/UserAccessTestHooks.php index 5772c30926f265f11614bcb6f708d8869600d10e..2b03e0d41576b3048aed9353190fd9368b5e7337 100644 --- a/core/modules/user/tests/modules/user_access_test/src/Hook/UserAccessTestHooks.php +++ b/core/modules/user/tests/modules/user_access_test/src/Hook/UserAccessTestHooks.php @@ -56,7 +56,8 @@ public function entityCreateAccess(AccountInterface $account, array $context, $e public function entityFieldAccess($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, ?FieldItemListInterface $items = NULL): AccessResultInterface { // Account with role sub-admin can view the status, init and mail fields for // user with no roles. - if ($field_definition->getTargetEntityTypeId() == 'user' && $operation === 'view' && in_array($field_definition->getName(), ['status', 'init', 'mail'])) { + if ($field_definition->getTargetEntityTypeId() == 'user' && $operation === 'view' + && in_array($field_definition->getName(), ['status', 'init', 'mail'])) { if ($items == NULL || count($items->getEntity()->getRoles()) == 1) { return AccessResult::allowedIfHasPermission($account, 'sub-admin'); } diff --git a/core/modules/user/tests/modules/user_hooks_test/src/Hook/UserHooksTest.php b/core/modules/user/tests/modules/user_hooks_test/src/Hook/UserHooksTest.php index ed10dcf60370e673821be1f05f5f3e9704e9911c..27aa8988395f488fc96278aa36da40d16ef1f4f5 100644 --- a/core/modules/user/tests/modules/user_hooks_test/src/Hook/UserHooksTest.php +++ b/core/modules/user/tests/modules/user_hooks_test/src/Hook/UserHooksTest.php @@ -20,8 +20,6 @@ class UserHooksTest { * The username that is displayed for a user. * @param \Drupal\Core\Session\AccountInterface $account * The object on which the operation is being performed. - * - * @return void */ #[Hook('user_format_name_alter')] public function userFormatNameAlter(&$name, AccountInterface $account): void { diff --git a/core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php b/core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php index 9ff72b182a1f07cc32d1cecd4d469bc1299baf8f..ba4a3a9362c86b9a5c4401a4f362a8cf370d047d 100644 --- a/core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php +++ b/core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php @@ -19,6 +19,9 @@ class UserEditedOwnAccountTest extends BrowserTestBase { */ protected $defaultTheme = 'stark'; + /** + * Tests that a user who edits their own account can still log in. + */ public function testUserEditedOwnAccount(): void { // Change account setting 'Who can register accounts?' to Administrators // only. diff --git a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php index 0eeee42d2c97710f6b28cc7d078008ba4588cdcc..9c61e956348cde8a932c72b72770ad7a792bcb25 100644 --- a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php +++ b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php @@ -286,6 +286,7 @@ public function testUserPasswordResetPreferredLanguage(): void { * Provides scenarios for testUserPasswordResetPreferredLanguage(). * * @return array + * An array of scenarios. */ protected function languagePrefixTestProvider() { return [ diff --git a/core/modules/user/tests/src/Functional/UserRegistrationTest.php b/core/modules/user/tests/src/Functional/UserRegistrationTest.php index fd6bfe529383c3122daec93cc8244de792c6603b..fbe262c4daa7e80773d63bbbbbac710607ff9134 100644 --- a/core/modules/user/tests/src/Functional/UserRegistrationTest.php +++ b/core/modules/user/tests/src/Functional/UserRegistrationTest.php @@ -28,6 +28,9 @@ class UserRegistrationTest extends BrowserTestBase { */ protected $defaultTheme = 'stark'; + /** + * Tests user registration with email verification enabled. + */ public function testRegistrationWithEmailVerification(): void { $config = $this->config('user.settings'); // Require email verification. @@ -70,6 +73,9 @@ public function testRegistrationWithEmailVerification(): void { $this->assertFalse($new_user->isActive(), 'New account is blocked until approved by an administrator.'); } + /** + * Tests user registration without email verification. + */ public function testRegistrationWithoutEmailVerification(): void { $config = $this->config('user.settings'); // Don't require email verification and allow registration by site visitors @@ -142,6 +148,9 @@ public function testRegistrationWithoutEmailVerification(): void { $this->assertSession()->pageTextContains('Member for'); } + /** + * Tests user registration with email duplicates. + */ public function testRegistrationEmailDuplicates(): void { // Don't require email verification and allow registration by site visitors // without administrator approval. @@ -241,6 +250,9 @@ public function testUuidFormState(): void { $this->assertNotEmpty($user_storage->loadByProperties(['name' => $edit['name']])); } + /** + * Tests user registration with default values. + */ public function testRegistrationDefaultValues(): void { // Don't require email verification and allow registration by site visitors // without administrator approval. diff --git a/core/modules/user/tests/src/Functional/UserSearchTest.php b/core/modules/user/tests/src/Functional/UserSearchTest.php index e2e700f01041857164561694a3457e1b378d9287..dd957dfe88d88c67de67d5193fadb690abbda653 100644 --- a/core/modules/user/tests/src/Functional/UserSearchTest.php +++ b/core/modules/user/tests/src/Functional/UserSearchTest.php @@ -23,6 +23,9 @@ class UserSearchTest extends BrowserTestBase { */ protected $defaultTheme = 'stark'; + /** + * Tests various user search functionalities and permission-based restrictions. + */ public function testUserSearch(): void { // Verify that a user without 'administer users' permission cannot search // for users by email address. Additionally, ensure that the username has a diff --git a/core/modules/user/tests/src/Functional/Views/HandlerFieldRoleTest.php b/core/modules/user/tests/src/Functional/Views/HandlerFieldRoleTest.php index 24de6fbf9b33316162dd00db1beb49388ac94610..73c3139cf1e33ec1655004ceb2648fbe8ac9eb32 100644 --- a/core/modules/user/tests/src/Functional/Views/HandlerFieldRoleTest.php +++ b/core/modules/user/tests/src/Functional/Views/HandlerFieldRoleTest.php @@ -27,6 +27,9 @@ class HandlerFieldRoleTest extends UserTestBase { */ protected $defaultTheme = 'stark'; + /** + * Tests the rendering of user roles in a Views field handler. + */ public function testRole(): void { // Create a couple of roles for the view. $role_name_a = 'a' . $this->randomMachineName(8); diff --git a/core/modules/user/tests/src/Functional/Views/HandlerFieldUserNameTest.php b/core/modules/user/tests/src/Functional/Views/HandlerFieldUserNameTest.php index 656ead917de1659a19d0223fe7d1c70eafabb2fe..df4eada71d82fab91f6852e1d575e638f17928a7 100644 --- a/core/modules/user/tests/src/Functional/Views/HandlerFieldUserNameTest.php +++ b/core/modules/user/tests/src/Functional/Views/HandlerFieldUserNameTest.php @@ -27,6 +27,9 @@ class HandlerFieldUserNameTest extends UserTestBase { */ protected $defaultTheme = 'stark'; + /** + * Tests the rendering of the user name field in Views. + */ public function testUserName(): void { /** @var \Drupal\Core\Render\RendererInterface $renderer */ $renderer = \Drupal::service('renderer'); diff --git a/core/modules/user/tests/src/Kernel/UserConfigValidationTest.php b/core/modules/user/tests/src/Kernel/UserConfigValidationTest.php index 991f13241302d0682d23ceb981a68c11b10850ad..4e739f7ee07eec27827ca74e39b1cb70de6df1b0 100644 --- a/core/modules/user/tests/src/Kernel/UserConfigValidationTest.php +++ b/core/modules/user/tests/src/Kernel/UserConfigValidationTest.php @@ -30,6 +30,7 @@ protected function setUp(): void { * Data provider for testUserSettings(). * * @return array + * An array of test cases for testUserSettings(). */ public static function providerTestUserSettings(): array { return [ diff --git a/core/modules/user/tests/src/Kernel/UserMailNotifyTest.php b/core/modules/user/tests/src/Kernel/UserMailNotifyTest.php index e341751ccbdbfba842cda79450b99437170c48b6..f9616dfa5308fc9275d401e57ea94782b3bb7c60 100644 --- a/core/modules/user/tests/src/Kernel/UserMailNotifyTest.php +++ b/core/modules/user/tests/src/Kernel/UserMailNotifyTest.php @@ -31,6 +31,7 @@ class UserMailNotifyTest extends EntityKernelTestBase { * Data provider for user mail testing. * * @return array + * An array of operations and the mail keys they should send. */ public static function userMailsProvider() { return [ diff --git a/core/modules/user/tests/src/Unit/Form/EntityPermissionsFormTest.php b/core/modules/user/tests/src/Unit/Form/EntityPermissionsFormTest.php index aba42464d88ac90a5df7c91e2ebd4b8047190044..bffb235006e176585ff461d9f380832ce1267471 100644 --- a/core/modules/user/tests/src/Unit/Form/EntityPermissionsFormTest.php +++ b/core/modules/user/tests/src/Unit/Form/EntityPermissionsFormTest.php @@ -101,6 +101,7 @@ public function testPermissionsByProvider(string $dependency_name, bool $found): * Provides data for the testPermissionsByProvider method. * * @return array + * An array of test data. */ public static function providerTestPermissionsByProvider() { return [ diff --git a/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php b/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php index 3660e00fe1dfea2fc85d035799400e6710aaac94..e1e80dba56c82c27e87340592bb44122a0652f1a 100644 --- a/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php +++ b/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php @@ -52,6 +52,7 @@ protected function setUp(): void { * Provides data for the testAccess method. * * @return array + * An array of test data. */ public static function providerTestAccess() { return [ diff --git a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php index 554ebda533f09a0238eb9b2be6bbc8ac0f348f36..ee2e80837f4977c2fcc02aaa606672758d1df389 100644 --- a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php +++ b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php @@ -323,7 +323,7 @@ public function testPermissionsYamlStaticAndCallback(): void { * Checks that the permissions are like expected. * * @param array $actual_permissions - * The actual permissions + * The actual permissions. * * @internal */ @@ -341,6 +341,9 @@ protected function assertPermissions(array $actual_permissions): void { } +/** + * Provider for testing permissions callbacks. + */ class TestPermissionCallbacks { public function singleDescription() { diff --git a/core/modules/user/tests/src/Unit/UserAuthTest.php b/core/modules/user/tests/src/Unit/UserAuthTest.php index b007a570fd8f97a0c795cce1b2889050514cabc9..b4a101dbf72f12cd2fac443ee1a8c616a9568419 100644 --- a/core/modules/user/tests/src/Unit/UserAuthTest.php +++ b/core/modules/user/tests/src/Unit/UserAuthTest.php @@ -107,6 +107,7 @@ public function testAuthenticateWithMissingCredentials($username, $password): vo * Data provider for testAuthenticateWithMissingCredentials(). * * @return array + * An array of test data. */ public static function providerTestAuthenticateWithMissingCredentials() { return [ diff --git a/core/modules/views/src/Annotation/ViewsAccess.php b/core/modules/views/src/Annotation/ViewsAccess.php index 9cfcb24cd125018741d20472cbeaf576ff367369..98d15375cc8979c5f906e0e556a86fc37d4afeb2 100644 --- a/core/modules/views/src/Annotation/ViewsAccess.php +++ b/core/modules/views/src/Annotation/ViewsAccess.php @@ -30,7 +30,7 @@ class ViewsAccess extends ViewsPluginAnnotationBase { public $title = ''; /** - * (optional) The short title used in the views UI. + * An optional short title used in the views UI. * * @var \Drupal\Core\Annotation\Translation * diff --git a/core/modules/views/src/Annotation/ViewsArgumentDefault.php b/core/modules/views/src/Annotation/ViewsArgumentDefault.php index 96bf8ab8799b2e9dba0cac3de0458aa3c5a86358..c29c454c8cb2d09da38a1238d7abf20bf3c50a62 100644 --- a/core/modules/views/src/Annotation/ViewsArgumentDefault.php +++ b/core/modules/views/src/Annotation/ViewsArgumentDefault.php @@ -30,7 +30,7 @@ class ViewsArgumentDefault extends ViewsPluginAnnotationBase { public $title = ''; /** - * (optional) The short title used in the views UI. + * An optional short title used in the views UI. * * @var \Drupal\Core\Annotation\Translation * diff --git a/core/modules/views/src/Annotation/ViewsArgumentValidator.php b/core/modules/views/src/Annotation/ViewsArgumentValidator.php index f8edde44aca20ed7b2eaa25002a025a6d58ce091..22deddf292b2e5fb52201f4146e3f52bda6c14b5 100644 --- a/core/modules/views/src/Annotation/ViewsArgumentValidator.php +++ b/core/modules/views/src/Annotation/ViewsArgumentValidator.php @@ -30,7 +30,7 @@ class ViewsArgumentValidator extends ViewsPluginAnnotationBase { public $title = ''; /** - * (optional) The short title used in the views UI. + * An optional short title used in the views UI. * * @var \Drupal\Core\Annotation\Translation * diff --git a/core/modules/views/src/Annotation/ViewsCache.php b/core/modules/views/src/Annotation/ViewsCache.php index a401241e59096386a87bd68009f64e7ac9918aa8..e659948f794e70f48b3ee963a2782508b23d03f7 100644 --- a/core/modules/views/src/Annotation/ViewsCache.php +++ b/core/modules/views/src/Annotation/ViewsCache.php @@ -30,7 +30,7 @@ class ViewsCache extends ViewsPluginAnnotationBase { public $title = ''; /** - * (optional) The short title used in the views UI. + * An optional short title used in the views UI. * * @var \Drupal\Core\Annotation\Translation * diff --git a/core/modules/views/src/Annotation/ViewsDisplay.php b/core/modules/views/src/Annotation/ViewsDisplay.php index f42c2f59aff53e8088112a25734c20b65ae2b45a..30a71134627cd0912e82271fcbe434dbc72e9d99 100644 --- a/core/modules/views/src/Annotation/ViewsDisplay.php +++ b/core/modules/views/src/Annotation/ViewsDisplay.php @@ -30,7 +30,7 @@ class ViewsDisplay extends ViewsPluginAnnotationBase { public $title = ''; /** - * (optional) The short title used in the views UI. + * An optional short title used in the views UI. * * @var \Drupal\Core\Annotation\Translation * diff --git a/core/modules/views/src/Annotation/ViewsDisplayExtender.php b/core/modules/views/src/Annotation/ViewsDisplayExtender.php index f28a1758388bcdcc3d77d7b46d543ce7b5d3e00b..88c9c1a7afedefa519b285365757aa15a19ecbe0 100644 --- a/core/modules/views/src/Annotation/ViewsDisplayExtender.php +++ b/core/modules/views/src/Annotation/ViewsDisplayExtender.php @@ -30,7 +30,7 @@ class ViewsDisplayExtender extends ViewsPluginAnnotationBase { public $title = ''; /** - * (optional) The short title used in the views UI. + * An optional short title used in the views UI. * * @var \Drupal\Core\Annotation\Translation * diff --git a/core/modules/views/src/Annotation/ViewsExposedForm.php b/core/modules/views/src/Annotation/ViewsExposedForm.php index a6f0fcea49afe0c30ffa3d374bfd771e4d9640a0..225e0470e61e0eb35abc7a1489e5cbffaf144ced 100644 --- a/core/modules/views/src/Annotation/ViewsExposedForm.php +++ b/core/modules/views/src/Annotation/ViewsExposedForm.php @@ -31,7 +31,7 @@ class ViewsExposedForm extends ViewsPluginAnnotationBase { public $title = ''; /** - * (optional) The short title used in the views UI. + * An optional short title used in the views UI. * * @var \Drupal\Core\Annotation\Translation * diff --git a/core/modules/views/src/Annotation/ViewsPager.php b/core/modules/views/src/Annotation/ViewsPager.php index 6591d8bddb7ae7496fc5d97bdaace21e32bedf78..265b1556344aa3cd26c5d900c74719e24d31d614 100644 --- a/core/modules/views/src/Annotation/ViewsPager.php +++ b/core/modules/views/src/Annotation/ViewsPager.php @@ -30,7 +30,7 @@ class ViewsPager extends ViewsPluginAnnotationBase { public $title = ''; /** - * (optional) The short title used in the views UI. + * An optional short title used in the views UI. * * @var \Drupal\Core\Annotation\Translation * diff --git a/core/modules/views/src/Annotation/ViewsQuery.php b/core/modules/views/src/Annotation/ViewsQuery.php index efe5230ad968197891726ace07103b85a125ede2..3d59f4648f31242f83da06a45a7062bb65eb7a6c 100644 --- a/core/modules/views/src/Annotation/ViewsQuery.php +++ b/core/modules/views/src/Annotation/ViewsQuery.php @@ -30,7 +30,7 @@ class ViewsQuery extends ViewsPluginAnnotationBase { public $title = ''; /** - * (optional) The short title used in the views UI. + * An optional short title used in the views UI. * * @var \Drupal\Core\Annotation\Translation * diff --git a/core/modules/views/src/Annotation/ViewsRow.php b/core/modules/views/src/Annotation/ViewsRow.php index c4d56622dfae3c9103afc75bff74661726137a97..5f996e23eb04e468ad0f4053d40aab73166af794 100644 --- a/core/modules/views/src/Annotation/ViewsRow.php +++ b/core/modules/views/src/Annotation/ViewsRow.php @@ -30,7 +30,7 @@ class ViewsRow extends ViewsPluginAnnotationBase { public $title = ''; /** - * (optional) The short title used in the views UI. + * An optional short title used in the views UI. * * @var \Drupal\Core\Annotation\Translation * diff --git a/core/modules/views/src/Annotation/ViewsStyle.php b/core/modules/views/src/Annotation/ViewsStyle.php index 31c05fbd50af3cc12aaf50f6335363c798aeee95..a8efc088587039b0c4a598a1e5d4eeb09b31550e 100644 --- a/core/modules/views/src/Annotation/ViewsStyle.php +++ b/core/modules/views/src/Annotation/ViewsStyle.php @@ -30,7 +30,7 @@ class ViewsStyle extends ViewsPluginAnnotationBase { public $title = ''; /** - * (optional) The short title used in the views UI. + * An optional short title used in the views UI. * * @var \Drupal\Core\Annotation\Translation * diff --git a/core/modules/views/src/Annotation/ViewsWizard.php b/core/modules/views/src/Annotation/ViewsWizard.php index b3f363f0d41be89d7fcad32cb676a916cde20a98..099ffa199505533bff9da3225e10f2bcf1e70d22 100644 --- a/core/modules/views/src/Annotation/ViewsWizard.php +++ b/core/modules/views/src/Annotation/ViewsWizard.php @@ -31,7 +31,7 @@ class ViewsWizard extends ViewsPluginAnnotationBase { public $title = ''; /** - * (optional) The short title used in the views UI. + * An optional short title used in the views UI. * * @var \Drupal\Core\Annotation\Translation * diff --git a/core/modules/views/src/Attribute/ViewsArgumentDefault.php b/core/modules/views/src/Attribute/ViewsArgumentDefault.php index 6d46f31a196ef557d931340479b5bfcd807d9dc4..c855dcd2b9f1a850e48aa3b0a299d08cd5b55bd1 100644 --- a/core/modules/views/src/Attribute/ViewsArgumentDefault.php +++ b/core/modules/views/src/Attribute/ViewsArgumentDefault.php @@ -23,7 +23,7 @@ class ViewsArgumentDefault extends Plugin { * @param string $id * The plugin ID. * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $title - * The plugin title used in the views UI + * The plugin title used in the views UI. * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $short_title * (optional) The short title used in the views UI. * @param bool $no_ui diff --git a/core/modules/views/src/EntityViewsData.php b/core/modules/views/src/EntityViewsData.php index e4aee7bfd31be5a64152d97e1762a401a61269c1..f42ff7ae0aec98017fa54c8ff3db50262e1490b8 100644 --- a/core/modules/views/src/EntityViewsData.php +++ b/core/modules/views/src/EntityViewsData.php @@ -445,7 +445,7 @@ protected function addEntityLinks(array &$data) { * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition * The field definition. * @param \Drupal\Core\Entity\Sql\TableMappingInterface $table_mapping - * The table mapping information + * The table mapping information. * @param array $table_data * A reference to a specific entity table (for example data_table) inside * the views data. diff --git a/core/modules/views/src/Form/ViewsFormMainForm.php b/core/modules/views/src/Form/ViewsFormMainForm.php index 25480f119894587b55099d8e947aca533cca4a00..e1c80dbd46d015b4b7476cf76a8862545567e3b9 100644 --- a/core/modules/views/src/Form/ViewsFormMainForm.php +++ b/core/modules/views/src/Form/ViewsFormMainForm.php @@ -13,6 +13,9 @@ use Drupal\views\ViewExecutable; use Drupal\Core\StringTranslation\StringTranslationTrait; +/** + * Provides a default main form class for Views forms. + */ class ViewsFormMainForm implements FormInterface, TrustedCallbackInterface { use StringTranslationTrait; @@ -21,6 +24,7 @@ class ViewsFormMainForm implements FormInterface, TrustedCallbackInterface { * {@inheritdoc} */ public function getFormId() { + return ''; } /** diff --git a/core/modules/views/src/Plugin/Block/ViewsBlockBase.php b/core/modules/views/src/Plugin/Block/ViewsBlockBase.php index 37e169793f34a27afd43a2dba2a19e3aea54b48e..bd0d75b62de889f880ffeceac9b91aadf5617668 100644 --- a/core/modules/views/src/Plugin/Block/ViewsBlockBase.php +++ b/core/modules/views/src/Plugin/Block/ViewsBlockBase.php @@ -2,6 +2,7 @@ namespace Drupal\views\Plugin\Block; +use Drupal\Core\Cache\Cache; use Drupal\Core\Url; use Drupal\Core\Access\AccessResult; use Drupal\Core\Block\BlockBase; @@ -86,6 +87,30 @@ public static function create(ContainerInterface $container, array $configuratio ); } + /** + * {@inheritdoc} + */ + public function getCacheContexts() { + $contexts = $this->view->display_handler->getCacheMetadata()->getCacheContexts(); + return Cache::mergeContexts(parent::getCacheContexts(), $contexts); + } + + /** + * {@inheritdoc} + */ + public function getCacheTags() { + $tags = $this->view->display_handler->getCacheMetadata()->getCacheTags(); + return Cache::mergeTags(parent::getCacheTags(), $tags); + } + + /** + * {@inheritdoc} + */ + public function getCacheMaxAge() { + $max_age = $this->view->display_handler->getCacheMetadata()->getCacheMaxAge(); + return Cache::mergeMaxAges(parent::getCacheMaxAge(), $max_age); + } + /** * {@inheritdoc} */ diff --git a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php index 76dcd5594acfed0e998361772879e1bdf47fb4f4..2b65ace33642e5703905c03a75c957685a97e117 100644 --- a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php +++ b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php @@ -61,7 +61,7 @@ class ViewsMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterf * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. * @param \Drupal\views\ViewExecutableFactory $view_executable_factory - * The view executable factory + * The view executable factory. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, ViewExecutableFactory $view_executable_factory) { parent::__construct($configuration, $plugin_id, $plugin_definition); diff --git a/core/modules/views/src/Plugin/ViewsHandlerManager.php b/core/modules/views/src/Plugin/ViewsHandlerManager.php index 463fb77b6af757010103e3ae7cce3dbfd1f3614f..99502754f49b31e13beade8c030a866492d5dc6b 100644 --- a/core/modules/views/src/Plugin/ViewsHandlerManager.php +++ b/core/modules/views/src/Plugin/ViewsHandlerManager.php @@ -41,7 +41,7 @@ class ViewsHandlerManager extends DefaultPluginManager implements FallbackPlugin * The plugin type, for example filter. * @param \Traversable $namespaces * An object that implements \Traversable which contains the root paths - * keyed by the corresponding namespace to look for plugin implementations, + * keyed by the corresponding namespace to look for plugin implementations. * @param \Drupal\views\ViewsData $views_data * The views data cache. * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend diff --git a/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php index c9bd4a60004b76f5c1e0accadc233f63f0a55b4f..d4bcc39ca4f7bac09ce3aae9f504852e06672e25 100644 --- a/core/modules/views/src/Plugin/views/HandlerBase.php +++ b/core/modules/views/src/Plugin/views/HandlerBase.php @@ -958,7 +958,7 @@ public function submitTemporaryForm($form, FormStateInterface $form_state) { * Calculates options stored on the handler. * * @param array $options - * The options stored in the handler + * The options stored in the handler. * @param array $form_state_options * The newly submitted form state options. * diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index ca589809b232a8e532e224f92464a0e3cd55b5f3..fd7d3d0262c2784e99ad6ce8e34637134e13e1cb 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -18,7 +18,7 @@ /** * Base class for any views plugin types. * - * Via the @Plugin definition the plugin may specify a theme function or + * Via the plugin definition the plugin may specify a theme function or * template to be used for the plugin. It also can auto-register the theme * implementation for that file or function. * - theme: the theme implementation to use in the plugin. This must be the diff --git a/core/modules/views/src/Plugin/views/access/AccessPluginBase.php b/core/modules/views/src/Plugin/views/access/AccessPluginBase.php index c1a39114691e0ecbe55dafeb2cbb65fcf033d0e5..ee9b3636370a793a5b66d5c707faee35ebc5a197 100644 --- a/core/modules/views/src/Plugin/views/access/AccessPluginBase.php +++ b/core/modules/views/src/Plugin/views/access/AccessPluginBase.php @@ -32,11 +32,11 @@ * plugin should have an annotation that includes the plugin's metadata, for * example: * @code - * @Plugin( - * id = "deny_all", - * title = @Translation("No Access"), - * help = @Translation("Will not be accessible.") - * ) + * #[ViewsAccess( + * id: "deny_all", + * title: new TranslatableMarkup("No Access"), + * help: new TranslatableMarkup("Will not be accessible.") + * )] * @endcode * * The definition should include the following keys: diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginInterface.php b/core/modules/views/src/Plugin/views/display/DisplayPluginInterface.php index 113a2e37c56aebb60bc358f3fc87a6e787f60476..dd14c47db489a44bd6bad0758337bb669f71d7d5 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginInterface.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginInterface.php @@ -414,7 +414,7 @@ public function render(); * #pre_render callback for view display rendering. * * @param array $element - * The element to #pre_render + * The element to #pre_render. * * @return array * The processed element. @@ -430,7 +430,7 @@ public function elementPreRender(array $element); * Identifier of the specific area to render. * @param bool $empty * (optional) Indicator whether or not the view result is empty. Defaults to - * FALSE + * FALSE. * * @return array * A render array for the given area. diff --git a/core/modules/views/src/Plugin/views/field/EntityField.php b/core/modules/views/src/Plugin/views/field/EntityField.php index 3d1db5c8b4657cd52cb38da960c9091731437348..58d7a2b771f51da3011685971c28495e6b0a2e68 100644 --- a/core/modules/views/src/Plugin/views/field/EntityField.php +++ b/core/modules/views/src/Plugin/views/field/EntityField.php @@ -754,6 +754,7 @@ public function renderItems($items) { } return $this->renderer->render($build); } + return NULL; } /** diff --git a/core/modules/views/src/Plugin/views/field/MultiItemsFieldHandlerInterface.php b/core/modules/views/src/Plugin/views/field/MultiItemsFieldHandlerInterface.php index 27f8b18e2bd2d8d66b17cf5cdf3720ed95b91ee4..bc2cdfdecaa7b17ca8c2d80f7190d9a725a880bd 100644 --- a/core/modules/views/src/Plugin/views/field/MultiItemsFieldHandlerInterface.php +++ b/core/modules/views/src/Plugin/views/field/MultiItemsFieldHandlerInterface.php @@ -39,7 +39,7 @@ public function getItems(ResultRow $values); * @param array $items * The items provided by getItems for a single row. * - * @return string + * @return string|null * The rendered items. */ public function renderItems($items); diff --git a/core/modules/views/src/Plugin/views/field/PrerenderList.php b/core/modules/views/src/Plugin/views/field/PrerenderList.php index 06f9a21356e01c11d76aa164d765d52df380ebc8..1840878ae03d70bb825f8dfddd5e773d25bcb82f 100644 --- a/core/modules/views/src/Plugin/views/field/PrerenderList.php +++ b/core/modules/views/src/Plugin/views/field/PrerenderList.php @@ -93,6 +93,7 @@ public function renderItems($items) { } return \Drupal::service('renderer')->render($render); } + return NULL; } /** diff --git a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php index 63b3dfc55e0795d1626806b3ed73f239e6c2bb82..a3dd5d95cb7d815878402e9f28f9c56f63f194b4 100644 --- a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php +++ b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php @@ -203,7 +203,7 @@ public function setWhereGroup($type = 'AND', $group = NULL, $where = 'where') { * Control how all WHERE and HAVING groups are put together. * * @param string $type - * Either 'AND' or 'OR' + * Either 'AND' or 'OR'. */ public function setGroupOperator($type = 'AND') { $this->groupOperator = strtoupper($type); diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php index 20e19439ffc227583dd6ce9b39209e5c9d3954fb..815bce2b8381224b01ea232896919d124e933448 100644 --- a/core/modules/views/src/Plugin/views/query/Sql.php +++ b/core/modules/views/src/Plugin/views/query/Sql.php @@ -5,6 +5,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\Cache; use Drupal\Core\Database\Database; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Messenger\MessengerInterface; @@ -994,7 +995,7 @@ public function addWhere($group, $field, $value = NULL, $operator = NULL) { * If the group does not yet exist it will be created as an AND group. * @param string $snippet * The snippet to check. This can be either a column or - * a complex expression like "UPPER(table.field) = 'value'" + * a complex expression like "UPPER(table.field) = 'value'". * @param array $args * An associative array of arguments. * @@ -1032,7 +1033,7 @@ public function addWhereExpression($group, $snippet, $args = []) { * If the group does not yet exist it will be created as an AND group. * @param string $snippet * The snippet to check. This can be either a column or - * a complex expression like "COUNT(table.field) > 3" + * a complex expression like "COUNT(table.field) > 3". * @param array $args * An associative array of arguments. * @@ -1571,7 +1572,7 @@ public function execute(ViewExecutable $view) { } $result = $query->execute(); - $result->setFetchMode(\PDO::FETCH_CLASS, 'Drupal\views\ResultRow'); + $result->setFetchMode(FetchAs::ClassObject, 'Drupal\views\ResultRow'); // Setup the result row objects. $view->result = iterator_to_array($result); diff --git a/core/modules/views/src/Plugin/views/sort/Date.php b/core/modules/views/src/Plugin/views/sort/Date.php index 4626175b03147f99ce7beea828a0962563284fef..002ca62eb2cb43861f53fa1955fbacca465317ab 100644 --- a/core/modules/views/src/Plugin/views/sort/Date.php +++ b/core/modules/views/src/Plugin/views/sort/Date.php @@ -39,6 +39,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { 'minute' => $this->t('Minute'), 'hour' => $this->t('Hour'), 'day' => $this->t('Day'), + 'week' => $this->t('Week'), 'month' => $this->t('Month'), 'year' => $this->t('Year'), ], @@ -70,6 +71,10 @@ public function query() { $formula = $this->getDateFormat('Ymd'); break; + case 'week': + $formula = $this->getDateFormat('W'); + break; + case 'month': $formula = $this->getDateFormat('Ym'); break; diff --git a/core/modules/views/src/Plugin/views/style/StylePluginBase.php b/core/modules/views/src/Plugin/views/style/StylePluginBase.php index a6a37013c1b4873b017b80b651620e9af80c3b1a..2ef36a09d1131b1db635d0cfa0256b611b1f7131 100644 --- a/core/modules/views/src/Plugin/views/style/StylePluginBase.php +++ b/core/modules/views/src/Plugin/views/style/StylePluginBase.php @@ -657,7 +657,7 @@ public function renderGrouping($records, $groupings = [], $group_rendered = NULL * Renders all of the fields for a given style and store them on the object. * * @param array $result - * The result array from $view->result + * The result array from $view->result. */ protected function renderFields(array $result) { if (!$this->usesFields()) { @@ -763,7 +763,7 @@ public static function trustedCallbacks() { * #pre_render callback for view row field rendering. * * @param array $data - * The element to #pre_render + * The element to #pre_render. * * @return array * The processed element. diff --git a/core/modules/views/src/Routing/ViewPageController.php b/core/modules/views/src/Routing/ViewPageController.php index d1d4770e7a42850c8ba37ea73a17b4719029c105..0e09945e8ab60fbf38554c941e7bf3ef787b95ab 100644 --- a/core/modules/views/src/Routing/ViewPageController.php +++ b/core/modules/views/src/Routing/ViewPageController.php @@ -17,7 +17,7 @@ class ViewPageController { * Handler a response for a given view and display. * * @param string $view_id - * The ID of the view + * The ID of the view. * @param string $display_id * The ID of the display. * @param \Drupal\Core\Routing\RouteMatchInterface $route_match diff --git a/core/modules/views/src/Tests/AssertViewsCacheTagsTrait.php b/core/modules/views/src/Tests/AssertViewsCacheTagsTrait.php index 3a596a8b04e56ff6e3674fa9d4f38560e0d6874b..3dd7e1e9666ba7e059999955151082589fb8755b 100644 --- a/core/modules/views/src/Tests/AssertViewsCacheTagsTrait.php +++ b/core/modules/views/src/Tests/AssertViewsCacheTagsTrait.php @@ -11,6 +11,9 @@ use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; +/** + * Provides assert methods for testing Views cache tags. + */ trait AssertViewsCacheTagsTrait { /** diff --git a/core/modules/views/src/Tests/ViewResultAssertionTrait.php b/core/modules/views/src/Tests/ViewResultAssertionTrait.php index a826742e2897dedb150e79d85f335f626b33431b..d8c8e387293e67fb409424fc23a6eeeb0a9ab15e 100644 --- a/core/modules/views/src/Tests/ViewResultAssertionTrait.php +++ b/core/modules/views/src/Tests/ViewResultAssertionTrait.php @@ -27,7 +27,7 @@ trait ViewResultAssertionTrait { * from the view (as keys) and the expected result set (as values). * @param string $message * (optional) A custom message to display with the assertion. Defaults to - * 'Identical result set.' + * 'Identical result set.'. */ protected function assertIdenticalResultset($view, $expected_result, $column_map = [], $message = NULL): void { $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, 'assertIdentical', $message); @@ -47,7 +47,7 @@ protected function assertIdenticalResultset($view, $expected_result, $column_map * from the view (as keys) and the expected result set (as values). * @param string $message * (optional) A custom message to display with the assertion. Defaults to - * 'Non-identical result set.' + * 'Non-identical result set.'. */ protected function assertNotIdenticalResultset($view, $expected_result, $column_map = [], $message = NULL): void { $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, 'assertNotIdentical', $message); diff --git a/core/modules/views/src/Views.php b/core/modules/views/src/Views.php index deab0ca46fa6e24483c69c8e136ed67b07db8897..8465e7c1cbf03cc3d9c6b2e0dde7157839c2d274 100644 --- a/core/modules/views/src/Views.php +++ b/core/modules/views/src/Views.php @@ -289,16 +289,16 @@ public static function getDisabledViews() { * If TRUE, only return views, not displays. * @param string $filter * Filters the views on status. Can either be 'all' (default), 'enabled' or - * 'disabled' + * 'disabled'. * @param \Drupal\views\ViewExecutable|string $exclude_view * View or current display to exclude. * Either a: - * - Views executable object - * - views name, for example 'my_view' - * - views name and display ID separated by ':', for example 'my_view:page' + * - Views executable object. + * - views name, for example 'my_view'. + * - views name and display ID separated by ':', for example 'my_view:page'. * @param bool $optgroup * If TRUE, returns an array with optgroups for each view (will be ignored - * for $views_only = TRUE). Can be used by select + * for $views_only = TRUE). Can be used by select. * @param bool $sort * If TRUE, the list of views is sorted ascending. * diff --git a/core/modules/views/tests/modules/views_entity_test/src/Hook/ViewsEntityTestHooks.php b/core/modules/views/tests/modules/views_entity_test/src/Hook/ViewsEntityTestHooks.php index ec0d2140446a0111ae9461bfa8ab2831ffe258a4..b75bd438f7c86ffb2384142cadad18727e7bdd7e 100644 --- a/core/modules/views/tests/modules/views_entity_test/src/Hook/ViewsEntityTestHooks.php +++ b/core/modules/views/tests/modules/views_entity_test/src/Hook/ViewsEntityTestHooks.php @@ -24,7 +24,14 @@ class ViewsEntityTestHooks { #[Hook('entity_base_field_info')] public function entityBaseFieldInfo(EntityTypeInterface $entity_type): array { if ($entity_type->id() == 'entity_test') { - $definitions['test_text_access'] = BaseFieldDefinition::create('string')->setLabel('Test access')->setTranslatable(FALSE)->setSetting('max_length', 64)->setDisplayOptions('form', ['type' => 'string_textfield', 'weight' => 10]); + $definitions['test_text_access'] = BaseFieldDefinition::create('string') + ->setLabel('Test access') + ->setTranslatable(FALSE) + ->setSetting('max_length', 64) + ->setDisplayOptions('form', [ + 'type' => 'string_textfield', + 'weight' => 10, + ]); return $definitions; } return []; diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_style_html_list_ordered.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_style_html_list_ordered.yml new file mode 100644 index 0000000000000000000000000000000000000000..2891b61cbd0b7ed67c47ca39c9f8827072a97b06 --- /dev/null +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_style_html_list_ordered.yml @@ -0,0 +1,166 @@ +langcode: en +status: true +dependencies: + module: + - node + - user +id: test_style_html_list_ordered +label: test_style_html_list_ordered +module: views +description: '' +tag: '' +base_table: node_field_data +base_field: nid +display: + default: + id: default + display_title: Default + display_plugin: default + position: 0 + display_options: + title: test_style_html_list_ordered + fields: + title: + id: title + table: node_field_data + field: title + relationship: none + group_type: group + admin_label: '' + entity_type: node + entity_field: title + plugin_id: field + label: '' + exclude: false + alter: + alter_text: false + make_link: false + absolute: false + word_boundary: false + ellipsis: false + strip_tags: false + trim: false + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: string + settings: + link_to_entity: true + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + pager: + type: full + options: + offset: 0 + pagination_heading_level: h4 + items_per_page: 2 + total_pages: null + id: 0 + tags: + next: ›› + previous: ‹‹ + first: '« First' + last: 'Last »' + expose: + items_per_page: false + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 25, 50' + items_per_page_options_all: false + items_per_page_options_all_label: '- All -' + offset: false + offset_label: Offset + quantity: 9 + exposed_form: + type: basic + options: + submit_button: Apply + reset_button: false + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: true + sort_asc_label: Asc + sort_desc_label: Desc + access: + type: perm + options: + perm: 'access content' + cache: + type: tag + options: { } + empty: { } + sorts: { } + arguments: { } + filters: { } + style: + type: html_list + options: + row_class: '' + default_row_class: true + uses_fields: false + type: ol + wrapper_class: item-list + class: '' + row: + type: fields + options: + default_field_elements: true + inline: { } + separator: '' + hide_empty: false + query: + type: views_query + options: + query_comment: '' + disable_sql_rewrite: false + distinct: false + replica: false + query_tags: { } + relationships: { } + header: { } + footer: { } + display_extenders: { } + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url.query_args + - 'user.node_grants:view' + - user.permissions + tags: { } + page_1: + id: page_1 + display_title: Page + display_plugin: page + position: 1 + display_options: + display_extenders: { } + path: test-style-html-list-ordered + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url.query_args + - 'user.node_grants:view' + - user.permissions + tags: { } diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldTest.php index db5cc0e9e8a3c17923e38b8c604a4078640cdf8e..b8d6a6d80ace74a153d14ef0ecf6d99852afe346 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldTest.php @@ -36,6 +36,7 @@ public function setTestValue($value) { * Returns the testValue property. * * @return string + * The value of the test. */ public function getTestValue() { return $this->testValue; diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php index 93bddef66640eb1cb8c58e35ea0e77b34d59651d..d35daecd1953a5049fb89f0ebd5975d8a20daa27 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php @@ -18,6 +18,7 @@ class FilterTest extends FilterPluginBase { * Overrides Drupal\views\Plugin\views\row\RowPluginBase::defineOptions(). * * @return array + * An array of options. */ protected function defineOptions() { $options = parent::defineOptions(); diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/join/JoinTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/join/JoinTest.php index 38352a5e45d3025a67545aadb93bdbbdfcd05792..6e359aefedf27a71a1aeeed8ba22af561b47f260 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/join/JoinTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/join/JoinTest.php @@ -23,6 +23,7 @@ class JoinTest extends JoinPluginBase { * Returns the joinValue property. * * @return int + * The value of the join. */ public function getJoinValue() { return $this->joinValue; diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/row/RowTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/row/RowTest.php index 280b79fe00b284b98456b0c1538a09d52418eb68..e951533bcd53ad99c1886cdd2286f3745bc866e2 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/row/RowTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/row/RowTest.php @@ -68,6 +68,7 @@ public function setOutput($output) { * Returns the output property. * * @return string + * The string to output by this plugin. */ public function getOutput() { return $this->output; diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php index 48d398c9b59001ac77bb08738a4374e8b97db05f..42f53feae9a7c3781e57cb7754acd7e0dafc9cfc 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php @@ -84,6 +84,7 @@ public function setOutput($output) { * Returns the output property. * * @return string + * The output of the plugin. */ public function getOutput() { return $this->output; diff --git a/core/modules/views/tests/modules/views_test_entity_reference/src/Hook/ViewsTestEntityReferenceHooks.php b/core/modules/views/tests/modules/views_test_entity_reference/src/Hook/ViewsTestEntityReferenceHooks.php index e700aeb57026be997c5cb00ac67060f0f4d1299b..299acdf8327d3b463f5ffe288bc60b18b5893728 100644 --- a/core/modules/views/tests/modules/views_test_entity_reference/src/Hook/ViewsTestEntityReferenceHooks.php +++ b/core/modules/views/tests/modules/views_test_entity_reference/src/Hook/ViewsTestEntityReferenceHooks.php @@ -23,7 +23,8 @@ public function viewsDataAlter(&$data): void { foreach ($field_configs as $field_config) { $table_name = $field_config->getTargetEntityTypeId() . '__' . $field_config->getName(); $column_name = $field_config->getName() . '_target_id'; - if (isset($data[$table_name][$column_name]['filter']['id']) && in_array($data[$table_name][$column_name]['filter']['id'], ['numeric', 'string'])) { + if (isset($data[$table_name][$column_name]['filter']['id']) + && in_array($data[$table_name][$column_name]['filter']['id'], ['numeric', 'string'])) { $data[$table_name][$column_name]['filter']['id'] = 'entity_reference'; } } diff --git a/core/modules/views/tests/src/Functional/Handler/AreaTest.php b/core/modules/views/tests/src/Functional/Handler/AreaTest.php index 1b1044957a2503491b57f7e465902d0e35c7eaef..6e38bd65d614ea4d9d4414d2fe96f21623f68ace 100644 --- a/core/modules/views/tests/src/Functional/Handler/AreaTest.php +++ b/core/modules/views/tests/src/Functional/Handler/AreaTest.php @@ -42,6 +42,9 @@ protected function setUp($import_test_views = TRUE, $modules = ['views_test_conf $this->enableViewsTestModule(); } + /** + * Provides additional Views data for testing. + */ protected function viewsData() { $data = parent::viewsData(); $data['views']['test_example'] = [ diff --git a/core/modules/views/tests/src/Functional/Plugin/PagerTest.php b/core/modules/views/tests/src/Functional/Plugin/PagerTest.php index cbdc4e5b99217a357b20fce71ceb3df5dfd610a9..cf381282443fce42ccbe5e9c46448a9247934b84 100644 --- a/core/modules/views/tests/src/Functional/Plugin/PagerTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/PagerTest.php @@ -253,6 +253,9 @@ public function testNoLimit(): void { $this->assertEquals(0, $view->pager->getItemsPerPage()); } + /** + * Tests the total row count in a view without a pager. + */ public function testViewTotalRowsWithoutPager(): void { $this->drupalCreateContentType(['type' => 'page']); for ($i = 0; $i < 23; $i++) { diff --git a/core/modules/views/tests/src/Functional/ViewStyleHtmlListTest.php b/core/modules/views/tests/src/Functional/ViewStyleHtmlListTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e31001acdf9b2146709ec7b640b187cb6ac1a659 --- /dev/null +++ b/core/modules/views/tests/src/Functional/ViewStyleHtmlListTest.php @@ -0,0 +1,66 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\views\Functional; + +/** + * Tests the View HTML List style. + * + * @group views + */ +class ViewStyleHtmlListTest extends ViewTestBase { + + /** + * Views used by this test. + * + * @var array + */ + public static array $testViews = ['test_style_html_list_ordered']; + + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + + /** + * {@inheritdoc} + */ + protected static $modules = ['node']; + + /** + * {@inheritdoc} + */ + protected function setUp($import_test_views = TRUE, $modules = ['views_test_config']): void { + parent::setUp($import_test_views, $modules); + + $this->enableViewsTestModule(); + + $this->drupalCreateContentType(['type' => 'page']); + for ($i = 1; $i < 10; $i++) { + $this->drupalCreateNode([ + 'title' => 'Node ' . $i, + ]); + } + } + + /** + * Tests ordered list HTML list. + */ + public function testOrderedList(): void { + $this->drupalGet('test-style-html-list-ordered'); + + // Verify we see the first 2 nodes. + $this->assertSession()->pageTextContains("Node 1"); + $this->assertSession()->pageTextContains("Node 2"); + $this->assertSession()->elementExists('css', 'ol[start=1]'); + + $this->drupalGet('test-style-html-list-ordered', ['query' => ['page' => '1']]); + + // Verify we see the next 2 nodes. + $this->assertSession()->pageTextContains("Node 3"); + $this->assertSession()->pageTextContains("Node 4"); + $this->assertSession()->elementExists('css', 'ol[start=3]'); + } + +} diff --git a/core/modules/views/tests/src/Functional/ViewTestBase.php b/core/modules/views/tests/src/Functional/ViewTestBase.php index b2946116727dccee178e0e0cd64f1a7f72297ef6..e021d179bdaec68f5712c4fff1d26c038369a769 100644 --- a/core/modules/views/tests/src/Functional/ViewTestBase.php +++ b/core/modules/views/tests/src/Functional/ViewTestBase.php @@ -100,7 +100,7 @@ protected function orderResultSet($result_set, $column, $reverse = FALSE) { * Asserts the existence of a button with a certain ID and label. * * @param string $id - * The HTML ID of the button + * The HTML ID of the button. * @param string $expected_label * The expected label for the button. * @param string $message diff --git a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php index 5187acc1e861328460a5f1bbcf4a4a7e9046abba..bb1e4a0c993a7a75bb888539539c3897d135057c 100644 --- a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php @@ -29,6 +29,9 @@ protected function setUp($import_test_views = TRUE, $modules = []): void { $this->drupalPlaceBlock('page_title_block'); } + /** + * Tests the Views wizard and listing. + */ public function testViewsWizardAndListing(): void { $this->drupalCreateContentType(['type' => 'article']); $this->drupalCreateContentType(['type' => 'page']); diff --git a/core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php b/core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php index c9b2b6063c2413b13bcdeb7eaea2b57de47cd845..77ce6e93d268d511605e3e8a8ce2b8ba982914d4 100644 --- a/core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php +++ b/core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php @@ -145,7 +145,7 @@ protected function setUp(): void { * @param \Drupal\Core\Entity\EntityTypeInterface $definition * An entity type definition to add to the entity type manager. * @param \Drupal\Core\Field\BaseFieldDefinition[] $base_fields - * An array of base field definitions + * An array of base field definitions. */ protected function setUpEntityType(EntityTypeInterface $definition, array $base_fields = []): void { // Replace the cache backend in the entity type manager so it returns diff --git a/core/modules/views/tests/src/Kernel/Handler/ArgumentSummaryTest.php b/core/modules/views/tests/src/Kernel/Handler/ArgumentSummaryTest.php index 9cbdfb9ccc4297dc60b9a98fafa5457f8feaff53..03488125064a16c78f48239f684a2462d6eef930 100644 --- a/core/modules/views/tests/src/Kernel/Handler/ArgumentSummaryTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/ArgumentSummaryTest.php @@ -102,7 +102,8 @@ protected function setUp($import_test_views = TRUE): void { /** * Creates a term in the tag vocabulary. * - * @return \Drupal\taxonomy\TermInterface $term + * @return \Drupal\taxonomy\TermInterface + * The created term. */ protected function createTag(): TermInterface { $tag = Term::create([ diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php index 55d1c4da290e0b2a595bcc22db27a76251c9218f..c162d68d677cfffea08e9cdba53b4c8411a6ef07 100644 --- a/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php @@ -81,7 +81,7 @@ public function testEntityLink(): void { * Tests whether entity links behave as expected. * * @param \Drupal\Core\Session\AccountInterface $account - * The user account to be used to run the test; + * The user account to be used to run the test. * @param bool[] $expected_results * An associative array of expected results keyed by link template name. */ diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php index f21b3f11924e5d0aca471be7bb7cd9fcf3255383..1892467a2ed302a3e8aa473fb90a1bde42df33ab 100644 --- a/core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php @@ -165,7 +165,7 @@ public function testRenderedEntityWithoutAndWithField(): void { * Ensures that the expected cacheability metadata is applied. * * @param array $build - * The render array + * The render array. * * @internal */ diff --git a/core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorTest.php b/core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorTest.php index 73c5e09d8efafc984c4e75506814a285c74e1d08..4dda6b5d5506cedc36e78200138f9b97b6cb2fad 100644 --- a/core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorTest.php @@ -247,6 +247,7 @@ public function testFilterGroupedExposed(): void { * Provides grouped exposed filter configuration. * * @return array + * An array of grouped exposed filter configuration. */ protected function getGroupedExposedFilters(): array { $filters = [ diff --git a/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php b/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php index 31a2b64e61920fa8a6270039ceea773e9577f661..c05b04ad18ce186fdc7452fbd5415cbc1674a741 100644 --- a/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php @@ -79,6 +79,7 @@ protected function dataSet() { * Build and return a Page view of the views_test_data table. * * @return \Drupal\views\ViewExecutable + * The page view object. */ protected function getBasicPageView() { $view = Views::getView('test_view'); diff --git a/core/modules/views/tests/src/Kernel/Handler/SortDateTest.php b/core/modules/views/tests/src/Kernel/Handler/SortDateTest.php index 727e6e89cf5388342359eda7fb98708e838036ae..65a4c892159974a3f134b962f1e95fcf44350ad3 100644 --- a/core/modules/views/tests/src/Kernel/Handler/SortDateTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/SortDateTest.php @@ -65,6 +65,16 @@ protected function expectedResultSet($granularity, $reverse = TRUE): array { ]; break; + case 'week': + $expected = [ + ['name' => 'John'], + ['name' => 'George'], + ['name' => 'Ringo'], + ['name' => 'Paul'], + ['name' => 'Meredith'], + ]; + break; + case 'month': $expected = [ ['name' => 'John'], @@ -128,6 +138,16 @@ protected function expectedResultSet($granularity, $reverse = TRUE): array { ]; break; + case 'week': + $expected = [ + ['name' => 'John'], + ['name' => 'George'], + ['name' => 'Ringo'], + ['name' => 'Paul'], + ['name' => 'Meredith'], + ]; + break; + case 'month': $expected = [ ['name' => 'John'], @@ -157,7 +177,7 @@ protected function expectedResultSet($granularity, $reverse = TRUE): array { * Tests numeric ordering of the result set. */ public function testDateOrdering(): void { - foreach (['second', 'minute', 'hour', 'day', 'month', 'year'] as $granularity) { + foreach (['second', 'minute', 'hour', 'day', 'week', 'month', 'year'] as $granularity) { foreach ([FALSE, TRUE] as $reverse) { $view = Views::getView('test_view'); $view->setDisplay(); diff --git a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php index d0d63479d980f67a91c4effbdeb6a694b254ecf5..6ff9fe991f17531a0453d33617f25e2efd4bc4c7 100644 --- a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php @@ -4,7 +4,11 @@ namespace Drupal\Tests\views\Unit\Plugin\Block; +use Drupal\Core\Cache\Cache; +use Drupal\Core\Cache\CacheableMetadata; +use Drupal\Core\Cache\Context\CacheContextsManager; use Drupal\Core\DependencyInjection\ContainerBuilder; +use Drupal\Core\Plugin\Context\ContextInterface; use Drupal\Tests\UnitTestCase; use Drupal\views\Plugin\Block\ViewsBlock; @@ -60,14 +64,25 @@ class ViewsBlockTest extends UnitTestCase { * {@inheritdoc} */ protected function setUp(): void { - // @todo Change the autogenerated stub. parent::setUp(); + + $container = new ContainerBuilder(); + + $cache_context_manager = $this->createMock(CacheContextsManager::class); + $cache_context_manager->expects($this->any()) + ->method('getAll') + ->willReturn([]); + $cache_context_manager->expects($this->any()) + ->method('assertValidTokens') + ->willReturn(TRUE); + $container->set('cache_contexts_manager', $cache_context_manager); + $condition_plugin_manager = $this->createMock('Drupal\Core\Executable\ExecutableManagerInterface'); $condition_plugin_manager->expects($this->any()) ->method('getDefinitions') ->willReturn([]); - $container = new ContainerBuilder(); $container->set('plugin.manager.condition', $condition_plugin_manager); + \Drupal::setContainer($container); $this->executable = $this->getMockBuilder('Drupal\views\ViewExecutable') @@ -84,7 +99,7 @@ protected function setUp(): void { $this->executable->display_handler = $this->getMockBuilder('Drupal\views\Plugin\views\display\Block') ->disableOriginalConstructor() - ->onlyMethods([]) + ->onlyMethods(['getCacheMetadata']) ->getMock(); $this->view = $this->getMockBuilder('Drupal\views\Entity\View') @@ -155,6 +170,76 @@ public function testBuild(): void { $this->assertEquals($build, $plugin->build()); } + /** + * Tests that cacheable metadata is retrieved from the view and merged with block cacheable metadata. + * + * @dataProvider providerTestCacheableMetadata + * + * @see \Drupal\views\Plugin\block\ViewsBlock::build() + */ + public function testCacheableMetadata(int $blockCacheMaxAge, int $viewCacheMaxAge, int $expectedCacheMaxAge): void { + + $blockCacheTags = ['block-cachetag-1', 'block-cachetag-2']; + $blockCacheContexts = ['block-cache-context-1', 'block-cache-context-2']; + + $viewCacheTags = ['view-cachetag-1', 'view-cachetag-2']; + $viewCacheContexts = ['view-cache-context-1', 'view-cache-context-2']; + + // Mock view cache metadata. + $viewCacheMetadata = $this->createMock(CacheableMetadata::class); + $viewCacheMetadata + ->method('getCacheTags') + ->willReturn($viewCacheTags); + $viewCacheMetadata + ->method('getCacheContexts') + ->willReturn($viewCacheContexts); + $viewCacheMetadata + ->method('getCacheMaxAge') + ->willReturn($viewCacheMaxAge); + $this->executable->display_handler + ->method('getCacheMetadata') + ->willReturn($viewCacheMetadata); + + // Mock block context. + $blockContext = $this->createMock(ContextInterface::class); + $blockContext + ->method('getCacheTags') + ->willReturn($blockCacheTags); + $blockContext + ->method('getCacheContexts') + ->willReturn($blockCacheContexts); + $blockContext + ->method('getCacheMaxAge') + ->willReturn($blockCacheMaxAge); + + // Create the views block. + $block_id = 'views_block:test_view-block_1'; + $config = []; + $definition = [ + 'provider' => 'views', + ]; + $plugin = new ViewsBlock($config, $block_id, $definition, $this->executableFactory, $this->storage, $this->account); + $plugin->setContext('context_name', $blockContext); + + // Assertions. + $this->assertEmpty(array_diff(Cache::mergeTags($viewCacheTags, $blockCacheTags), $plugin->getCacheTags())); + $this->assertEmpty(array_diff(Cache::mergeContexts($viewCacheContexts, $blockCacheContexts), $plugin->getCacheContexts())); + $this->assertEquals($expectedCacheMaxAge, $plugin->getCacheMaxAge()); + } + + /** + * Data provider for ::testCacheableMetadata() + */ + public static function providerTestCacheableMetadata(): array { + return [ + 'View expires before' => [500, 1000, 500], + 'Block expires before' => [1000, 500, 500], + 'Only block is permanent' => [Cache::PERMANENT, 500, 500], + 'Only view is permanent' => [500, Cache::PERMANENT, 500], + 'Both view and block are permanent' => [Cache::PERMANENT, Cache::PERMANENT, Cache::PERMANENT], + ]; + } + /** * Tests the build method. * diff --git a/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php b/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php index 189b3f5da96f227b8126ef247e5176101bc826a5..680047792ca09f359f3e6f658dcea6981aa17a19 100644 --- a/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php @@ -142,6 +142,7 @@ protected function setupEntityTypeManager(): void { * Data provider for testing different types of tokens. * * @return array + * An array of test data. */ public static function providerTestTokens() { return [ diff --git a/core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php b/core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php index c42eb70b7096cf6f7064fa01e0a28e3064bb818f..2dcc16334c19fac9d14c4fb9b000af397ec09558 100644 --- a/core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php @@ -93,6 +93,7 @@ public function testResultArea($content, $expected, $items_per_page = 0): void { * Data provider for testResultArea. * * @return array + * An array of test cases. */ public static function providerTestResultArea() { return [ diff --git a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php index c8795b47e6fd6b77bb5a60b638a6b08f08da6ef4..a36a9cc1a4ee67554bc126c6681598bfbb05ea28 100644 --- a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php @@ -856,6 +856,9 @@ public function testElementClassesWithTokens(): void { } +/** + * Test class for testing field plugins. + */ class FieldPluginBaseTestField extends FieldPluginBase { public function setLinkGenerator(LinkGeneratorInterface $link_generator): void { diff --git a/core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php b/core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php index 12241bc6a52ccab9de909dff16b16b2000e44cc6..128a5cefb7cf1528925595f432ba2c8351b24d56 100644 --- a/core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php @@ -667,6 +667,7 @@ public static function providerTestPrepareItemsByDelta() { * Returns a mocked base field storage object. * * @return \Drupal\Core\Field\FieldStorageDefinitionInterface|\PHPUnit\Framework\MockObject\MockObject + * The mocked field storage object. */ protected function getBaseFieldStorage() { $title_storage = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface'); @@ -686,6 +687,7 @@ protected function getBaseFieldStorage() { * Returns a mocked configurable field storage object. * * @return \Drupal\field\FieldStorageConfigInterface|\PHPUnit\Framework\MockObject\MockObject + * The mocked field storage object. */ protected function getConfigFieldStorage() { $title_storage = $this->createMock('Drupal\field\FieldStorageConfigInterface'); @@ -705,6 +707,7 @@ protected function getConfigFieldStorage() { * Provides sort orders for clickSort() test methods. * * @return array + * An array of sort orders. */ public static function providerSortOrders() { return [ @@ -754,6 +757,9 @@ protected function setupLanguageRenderer(EntityField $handler, $definition): voi } +/** + * Stub class for testing EntityField methods. + */ class FieldTestEntityField extends EntityField { public function executePrepareItemsByDelta(array $all_values) { diff --git a/core/modules/views/tests/src/Unit/Plugin/filter/FilterPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/filter/FilterPluginBaseTest.php index 0c9990c8131532512c6592d52e501ecda6cba495..f517b77bdce85ca5fe677f70e8a93def401f0ec1 100644 --- a/core/modules/views/tests/src/Unit/Plugin/filter/FilterPluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/filter/FilterPluginBaseTest.php @@ -63,4 +63,7 @@ public static function acceptExposedInputProvider() { } +/** + * Empty class to support testing filter plugins. + */ class FilterPluginBaseStub extends FilterPluginBase {} diff --git a/core/modules/views/tests/src/Unit/Plugin/filter/InOperatorTest.php b/core/modules/views/tests/src/Unit/Plugin/filter/InOperatorTest.php index dd0fea7dd8711049da44408e4d36c4d19793e4b5..1f46a6461d7771b51dacffad01e636c0d86087bd 100644 --- a/core/modules/views/tests/src/Unit/Plugin/filter/InOperatorTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/filter/InOperatorTest.php @@ -33,6 +33,7 @@ public function testValidate(): void { /** * @return array + * The options for the filter. */ public static function validate_options_callback() { return ['Yes', 'No']; diff --git a/core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php b/core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php index 031ac4e6365738405af3e2f52e35ee79dd9ffb5f..bcc6ede7dc2368703cb13794d398b2e55da40382 100644 --- a/core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php @@ -151,6 +151,7 @@ protected function setupEntityTypeManager(EntityTypeManagerInterface $entity_typ * Test entities keyed by entity type and revision ID. * * @return \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Entity\EntityTypeManagerInterface> + * The mocked entity type manager. */ protected function setupEntityTypes($entities_by_type = [], $entity_revisions_by_type = []): ObjectProphecy { $entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class); diff --git a/core/modules/views/tests/src/Unit/PluginBaseTest.php b/core/modules/views/tests/src/Unit/PluginBaseTest.php index 8e603edc09a4a6adc91166ae061540a6679b11f3..e596fc14fffad6dd93956ac6e9e3f9c6d468cc29 100644 --- a/core/modules/views/tests/src/Unit/PluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/PluginBaseTest.php @@ -39,7 +39,7 @@ protected function setUp(): void { * @param array $definition * The definition array, defining default options. * @param array $expected - * The expected array after unpacking + * The expected array after unpacking. * @param bool $all * Whether to unpack all options. * @@ -59,7 +59,7 @@ public function testUnpackOptions($storage, $options, $definition, $expected, $a * @param array $definition * The definition array, defining default options. * @param array $expected - * The expected array after unpacking + * The expected array after unpacking. * * @dataProvider providerTestSetOptionDefault * @covers ::setOptionDefaults @@ -73,6 +73,7 @@ public function testSetOptionDefault($storage, $definition, $expected): void { * Data provider for testUnpackOptions(). * * @return array + * An array of test data. */ public static function providerTestUnpackOptions() { $test_parameters = []; @@ -221,6 +222,7 @@ public static function providerTestUnpackOptions() { * Data provider for testSetOptionDefault(). * * @return array + * An array of test data. */ public static function providerTestSetOptionDefault() { $test_parameters = []; diff --git a/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php b/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php index 510a1ba953b6df8e97e69414e44eb49604fc3f86..4b3026460d613a93493f6f0366fa00e8f1ad5135 100644 --- a/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php +++ b/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php @@ -18,6 +18,7 @@ class ViewsDataHelperTest extends UnitTestCase { * Returns the views data definition. * * @return array + * The views data definition. */ protected function viewsData() { $data = ViewTestData::viewsData(); diff --git a/core/modules/views/tests/src/Unit/ViewsDataTest.php b/core/modules/views/tests/src/Unit/ViewsDataTest.php index 4018cd979604b400117c5e786a174b9b25299fc4..d88891901899873b8e6f34c234364f740fc45020 100644 --- a/core/modules/views/tests/src/Unit/ViewsDataTest.php +++ b/core/modules/views/tests/src/Unit/ViewsDataTest.php @@ -116,6 +116,7 @@ protected function viewsData() { * Returns the views data definition with the provider key. * * @return array + * The views data definition. * * @see static::viewsData() */ diff --git a/core/modules/views/tests/src/Unit/ViewsTest.php b/core/modules/views/tests/src/Unit/ViewsTest.php index 784b5a89e8dbecbe3bff934f8ef3bccb1c37a8ce..5c055b69fb73b9073ef17055d1cccc6c505fcce3 100644 --- a/core/modules/views/tests/src/Unit/ViewsTest.php +++ b/core/modules/views/tests/src/Unit/ViewsTest.php @@ -211,6 +211,7 @@ public function testGetApplicableViews($applicable_type, $expected): void { * Data provider for testGetApplicableViews. * * @return array + * An array of test data. */ public static function providerTestGetApplicableViews() { return [ diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 8336a5123c357c767cff8d394a084b96a6d31349..2a4688bbe5588ade814ef9079772c6e01896539e 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -865,12 +865,20 @@ function template_preprocess_views_view_list(&$variables): void { $handler = $variables['view']->style_plugin; // Fetch classes from handler options. + $variables['list']['attributes'] = new Attribute(); if ($handler->options['class']) { $class = explode(' ', $handler->options['class']); $class = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', $class); // Initialize a new attribute class for $class. - $variables['list']['attributes'] = new Attribute(['class' => $class]); + $variables['list']['attributes']->addClass($class); + } + + $type = $handler->options['type']; + + if ($type === 'ol') { + $pager = $variables['view']->getPager(); + $variables['list']['attributes']['start'] = $variables['view']->getCurrentPage() * $pager->options['items_per_page'] + 1; } // Fetch wrapper classes from handler options. @@ -879,7 +887,7 @@ function template_preprocess_views_view_list(&$variables): void { $variables['attributes']['class'] = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', $wrapper_class); } - $variables['list']['type'] = $handler->options['type']; + $variables['list']['type'] = $type; template_preprocess_views_view_unformatted($variables); } diff --git a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php index 3755e91dc2489692283608e4e5b3007262de559f..b0a3ad6b9420e20b0f70460ad4dd59a729ecb3b7 100644 --- a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php +++ b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php @@ -77,7 +77,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $group_options = []; - /** + /* * Filter groups is an array that contains: * [ * 'operator' => 'and' || 'or', diff --git a/core/modules/views_ui/src/Form/Ajax/ViewsFormInterface.php b/core/modules/views_ui/src/Form/Ajax/ViewsFormInterface.php index 44b2087a18ed1885952408a23b99ca23e770ac1d..aacb0bf45968519c20e790e7ec365cc5555690bc 100644 --- a/core/modules/views_ui/src/Form/Ajax/ViewsFormInterface.php +++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormInterface.php @@ -5,6 +5,9 @@ use Drupal\Core\Form\FormInterface; use Drupal\views\ViewEntityInterface; +/** + * Provides an interface for the Views UI AJAX forms. + */ interface ViewsFormInterface extends FormInterface { /** diff --git a/core/modules/views_ui/tests/src/Functional/AreaEntityUITest.php b/core/modules/views_ui/tests/src/Functional/AreaEntityUITest.php index d45fed51e813ea8ca2b4ce915b1cb2e0c471168e..89eba50ecd4a8641bdbe69bc6096b9122e2464da 100644 --- a/core/modules/views_ui/tests/src/Functional/AreaEntityUITest.php +++ b/core/modules/views_ui/tests/src/Functional/AreaEntityUITest.php @@ -26,6 +26,9 @@ class AreaEntityUITest extends UITestBase { */ protected $defaultTheme = 'stark'; + /** + * Tests the Views user interface. + */ public function testUI(): void { // Set up a block and an entity_test entity. $block = Block::create(['id' => 'test_id', 'plugin' => 'system_main_block', 'theme' => 'stark']); diff --git a/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php b/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php index 9b00ae31ec4a1f4e7133c5d338e1634185ac7771..9496abeba016667c30613accce979d903c310f68 100644 --- a/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php +++ b/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php @@ -27,7 +27,7 @@ class CustomBooleanTest extends UITestBase { protected $defaultTheme = 'stark'; /** - * \Drupal\views\Tests\ViewTestBase::viewsData(). + * {@inheritdoc} */ public function viewsData() { $data = parent::viewsData(); diff --git a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php index 9391376011826b86ff4448623d76e615e3aa16c8..11ca869f6b50b079b8e8774b1682b2015a222bee 100644 --- a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php +++ b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php @@ -268,6 +268,9 @@ public function testGroupedFilterAdminUi(): void { $this->assertNoGroupedFilterErrors(); } + /** + * Tests the error messages used in the grouped filter form. + */ public function testGroupedFilterAdminUiErrors(): void { // Select the empty operator without a title specified. $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/body_value'); diff --git a/core/modules/views_ui/tests/src/Functional/TranslatedViewTest.php b/core/modules/views_ui/tests/src/Functional/TranslatedViewTest.php index 0ffc56f245ca23fbc329879d64ec998d283672e0..01a8ae319a68c9a30238f6a661f6c0f2fa0b6619 100644 --- a/core/modules/views_ui/tests/src/Functional/TranslatedViewTest.php +++ b/core/modules/views_ui/tests/src/Functional/TranslatedViewTest.php @@ -71,6 +71,9 @@ protected function setUp($import_test_views = TRUE, $modules = []): void { $this->rebuildContainer(); } + /** + * Tests view translation. + */ public function testTranslatedStrings(): void { $translation_url = 'admin/structure/views/view/files/translate/fr/add'; $edit_url = 'admin/structure/views/view/files'; diff --git a/core/modules/views_ui/tests/src/Functional/XssTest.php b/core/modules/views_ui/tests/src/Functional/XssTest.php index 887bdfae72c77c252584fe60a169f4a25bd028a9..51823960aacb4c80c29d7d6c475c0832e3cd602a 100644 --- a/core/modules/views_ui/tests/src/Functional/XssTest.php +++ b/core/modules/views_ui/tests/src/Functional/XssTest.php @@ -21,6 +21,9 @@ class XssTest extends UITestBase { */ protected $defaultTheme = 'stark'; + /** + * Tests escaping with the test view. + */ public function testViewsUi(): void { $this->drupalGet('admin/structure/views/view/sa_contrib_2013_035'); // Verify that the field admin label is properly escaped. diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php index 418712b023dc5489595fb2fd5e817d3026ff8249..b6f442e62653e61aacd14081a15935f219551386 100644 --- a/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php @@ -138,6 +138,7 @@ public function testFilterViewsListing(): void { * The elements. * * @return array + * The filtered array. */ protected function filterVisibleElements($elements): array { $elements = array_filter($elements, function ($element) { diff --git a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php index ceae6360fc7f9f88b888e31272a08fcf27d19672..3854945a089069adfa21150442ce2e4f7483b561 100644 --- a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php +++ b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php @@ -189,6 +189,9 @@ public function testBuildRowEntityList(): void { } +/** + * Stub class for testing ViewListBuilder methods. + */ class TestViewListBuilder extends ViewListBuilder { public function buildOperations(EntityInterface $entity) { diff --git a/core/modules/workflows/src/WorkflowStateTransitionOperationsAccessCheck.php b/core/modules/workflows/src/WorkflowStateTransitionOperationsAccessCheck.php index 2310126d31b919eb916407d41bff342654cdd418..0b084c0bb6974022500f54289e0b1c02126f9d6b 100644 --- a/core/modules/workflows/src/WorkflowStateTransitionOperationsAccessCheck.php +++ b/core/modules/workflows/src/WorkflowStateTransitionOperationsAccessCheck.php @@ -40,7 +40,7 @@ class WorkflowStateTransitionOperationsAccessCheck implements AccessInterface { * @endcode * * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * The parametrized route + * The parametrized route. * @param \Drupal\Core\Session\AccountInterface $account * The currently logged in account. * @@ -72,7 +72,7 @@ public function access(RouteMatchInterface $route_match, AccountInterface $accou * Get the operation that will be used for the access check. * * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * The parametrized route + * The parametrized route. * * @return string * The access operation. diff --git a/core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php b/core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php index f24e427b2ef3bef878883e39943f356b2227d0c4..e46fbcf417bf92dcac70243a0a8eb4056917c52a 100644 --- a/core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php +++ b/core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php @@ -121,6 +121,7 @@ public function testCheckAccess($user, $operation, $result, $states_to_create = * Data provider for ::testCheckAccess. * * @return array + * An array of test data. */ public static function checkAccessProvider() { $container = new ContainerBuilder(); diff --git a/core/modules/workspaces/tests/src/Functional/WorkspaceViewsBulkFormTest.php b/core/modules/workspaces/tests/src/Functional/WorkspaceViewsBulkFormTest.php index d44d95ba86be5c458026dd4302a7cf1bec44402d..de8795b644ab287f3bd9d6bf1d41017859fe0462 100644 --- a/core/modules/workspaces/tests/src/Functional/WorkspaceViewsBulkFormTest.php +++ b/core/modules/workspaces/tests/src/Functional/WorkspaceViewsBulkFormTest.php @@ -44,6 +44,9 @@ protected function setUp(): void { $this->switchToWorkspace($stage); } + /** + * Tests the Workspaces view bulk form integration. + */ public function testBulkForm(): void { // Ignore entity types that are not being tested, in order to fully re-use // the parent test method. diff --git a/core/modules/workspaces/tests/src/Unit/ActiveWorkspaceCheckTest.php b/core/modules/workspaces/tests/src/Unit/ActiveWorkspaceCheckTest.php index c87da448fa03c5921803261cb3676ec2f4a464e2..bf2358311de63d5b4246d7962c7b356eb7323e42 100644 --- a/core/modules/workspaces/tests/src/Unit/ActiveWorkspaceCheckTest.php +++ b/core/modules/workspaces/tests/src/Unit/ActiveWorkspaceCheckTest.php @@ -45,6 +45,7 @@ protected function setUp(): void { * Provides data for the testAccess method. * * @return array + * An array of test data. */ public static function providerTestAccess() { return [ diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index 6a7b9e2934734da9198eabcb7957f567e427e844..ce479f525336acf67a7326927bd812bfcfe537a9 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -29,9 +29,9 @@ <!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.--> <!-- Drupal sniffs --> - <rule ref="Drupal.Arrays.Array"> - <!-- Sniff for these errors: ArrayClosingIndentation, ArrayIndentation, CommaLastItem --> - <exclude name="Drupal.Arrays.Array.LongLineDeclaration"/> + <rule ref="Drupal.Arrays.Array"/> + <rule ref="Drupal.Arrays.Array.LongLineDeclaration"> + <include-pattern>core/modules/*/tests/modules/*</include-pattern> </rule> <rule ref="Drupal.CSS.ClassDefinitionNameSpacing"/> <rule ref="Drupal.CSS.ColourDefinition"/> @@ -49,6 +49,7 @@ <include-pattern>*/Functional/*</include-pattern> <include-pattern>*/tests/modules/*</include-pattern> <include-pattern>./core/tests/Drupal/Tests/Core/*</include-pattern> + <include-pattern>./core/modules/*</include-pattern> </rule> <rule ref="Drupal.Commenting.DataTypeNamespace"/> <rule ref="Drupal.Commenting.Deprecated"/> @@ -65,9 +66,7 @@ <rule ref="Drupal.Commenting.DocCommentLongArraySyntax"/> <rule ref="Drupal.Commenting.DocCommentStar"/> <rule ref="Drupal.Commenting.FileComment"/> - <rule ref="Drupal.Commenting.FunctionComment"> - <exclude name="Drupal.Commenting.FunctionComment.ParamCommentFullStop"/> - </rule> + <rule ref="Drupal.Commenting.FunctionComment"/> <rule ref="Drupal.Commenting.FunctionComment.Missing"> <include-pattern>core/modules/*/Plugin/views/argument/*</include-pattern> <include-pattern>core/modules/*/Plugin/views/filter/*</include-pattern> @@ -82,24 +81,19 @@ <include-pattern>core/modules/*/Plugin/views/style/*</include-pattern> <include-pattern>*/Database/*</include-pattern> <include-pattern>*/FunctionalJavascript/*</include-pattern> + <include-pattern>*/Functional/*</include-pattern> </rule> <rule ref="Drupal.Commenting.FunctionComment.MissingParamType"/> <rule ref="Drupal.Commenting.FunctionComment.MissingReturnComment"> <include-pattern>core/lib/Drupal/Core/*</include-pattern> <include-pattern>core/lib/Drupal/Component/*</include-pattern> <include-pattern>core/tests/*</include-pattern> - </rule> - <rule ref="Drupal.Commenting.FunctionComment.MissingReturnComment"> - <exclude-pattern>core/lib/Drupal/Core/*</exclude-pattern> - <exclude-pattern>core/lib/Drupal/Component/*</exclude-pattern> - <exclude-pattern>core/tests/*</exclude-pattern> - <exclude-pattern>core/*/tests/*</exclude-pattern> + <include-pattern>core/*/tests/*</include-pattern> </rule> <rule ref="Drupal.Commenting.GenderNeutralComment"/> <rule ref="Drupal.Commenting.HookComment"/> <rule ref="Drupal.Commenting.InlineComment"> <!-- Sniff for: NoSpaceBefore, SpacingBefore, WrongStyle --> - <exclude name="Drupal.Commenting.InlineComment.DocBlock"/> <exclude name="Drupal.Commenting.InlineComment.InvalidEndChar"/> <exclude name="Drupal.Commenting.InlineComment.SpacingAfter"/> </rule> @@ -134,6 +128,7 @@ <rule ref="Drupal.NamingConventions.ValidVariableName"/> <rule ref="Drupal.NamingConventions.ValidVariableName.LowerCamelName"/> <rule ref="Drupal.Scope.MethodScope"/> + <rule ref="Drupal.Semantics.ConstantName.ConstantStart"/> <rule ref="Drupal.Semantics.EmptyInstall"/> <rule ref="Drupal.Semantics.FunctionAlias"/> <rule ref="Drupal.Semantics.FunctionT"/> @@ -264,6 +259,7 @@ <property name="forbiddenAnnotations" type="array"> <element value="@inheritDoc"/> <element value="@inheritdoc"/> + <element value="@returns"/> </property> </properties> </rule> diff --git a/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php b/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php index fa29b9544f7c3bf4a01a0bc13a268d36dd3d81c8..d999eb87323916c9e08e4b4c4666f22a79eacfad 100644 --- a/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php +++ b/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php @@ -743,7 +743,7 @@ protected function processContent($bundle_machine_name, array $content, $langcod * Imports content. * * @param string $entity_type - * Entity type to be imported + * Entity type to be imported. * @param string $bundle_machine_name * Bundle machine name to be imported. * diff --git a/core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php b/core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php index a3209287159b6bdddfcfee3525b126f19374104c..491ffcc68660f9985e26e16faf161516eca029e2 100644 --- a/core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php +++ b/core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php @@ -83,7 +83,7 @@ public function testGdToolkitRequirements(): void { // Get Status Report. $this->drupalGet('admin/reports/status'); $this->assertSession()->pageTextContains('GD2 image manipulation toolkit'); - $this->assertSession()->pageTextContains('Supported image file formats: GIF, JPEG, PNG, WEBP.'); + $this->assertSession()->pageTextContains('Supported image file formats: GIF, JPEG, PNG, WEBP, AVIF.'); } } diff --git a/core/tests/Drupal/FunctionalTests/Libraries/JqueryUiLibraryAssetsTest.php b/core/tests/Drupal/FunctionalTests/Libraries/JqueryUiLibraryAssetsTest.php index c3446635f128d3b79883ae5a05fb4f9f3e6359bd..3b1c44a70a43674135394cf7945bfc18f7fa59c2 100644 --- a/core/tests/Drupal/FunctionalTests/Libraries/JqueryUiLibraryAssetsTest.php +++ b/core/tests/Drupal/FunctionalTests/Libraries/JqueryUiLibraryAssetsTest.php @@ -32,7 +32,7 @@ class JqueryUiLibraryAssetsTest extends BrowserTestBase { protected $libraryDiscovery; /** - * jQuery UI CSS and JS assets keyed by their weight. + * The jQuery UI CSS and JS assets keyed by their weight. * * For example, the value of $weightGroupedAssets[-11] would be an array * of every jQuery UI CSS and JS file asset configured with a weight of -11. diff --git a/core/tests/Drupal/KernelTests/Core/ClassLoader/BackwardsCompatibilityClassLoaderTest.php b/core/tests/Drupal/KernelTests/Core/ClassLoader/BackwardsCompatibilityClassLoaderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f96446c42371ce1b9635cf1c9914582ccbe10ac9 --- /dev/null +++ b/core/tests/Drupal/KernelTests/Core/ClassLoader/BackwardsCompatibilityClassLoaderTest.php @@ -0,0 +1,46 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\KernelTests\Core\ClassLoader; + +use Drupal\Component\Utility\Random; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\StringTranslation\TranslationWrapper; +use Drupal\KernelTests\KernelTestBase; +use Drupal\module_autoload_test\Foo; + +/** + * @coversDefaultClass Drupal\Core\ClassLoader\BackwardsCompatibilityClassLoader + * @group ClassLoader + */ +class BackwardsCompatibilityClassLoaderTest extends KernelTestBase { + + /** + * {@inheritdoc} + */ + protected static $modules = ['module_autoload_test']; + + /** + * Tests that the bc layer for TranslationWrapper works. + */ + public function testTranslationWrapper(): void { + // @phpstan-ignore class.notFound + $object = new TranslationWrapper('Backward compatibility'); + $this->assertInstanceOf(TranslatableMarkup::class, $object); + } + + /** + * Tests that a moved class from a module works. + * + * @group legacy + */ + public function testModuleMovedClass(): void { + // @phpstan-ignore class.notFound + $this->expectDeprecation('Class ' . Foo::class . ' is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0, use Drupal\Component\Utility\Random instead. See https://www.drupal.org/project/drupal/issues/3502882'); + // @phpstan-ignore class.notFound + $object = new Foo(); + $this->assertInstanceOf(Random::class, $object); + } + +} diff --git a/core/tests/Drupal/KernelTests/Core/Database/FetchLegacyTest.php b/core/tests/Drupal/KernelTests/Core/Database/FetchLegacyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6e28787f764c2f3179ed1bd92fd80743704fa0c3 --- /dev/null +++ b/core/tests/Drupal/KernelTests/Core/Database/FetchLegacyTest.php @@ -0,0 +1,147 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\KernelTests\Core\Database; + +use PHPUnit\Framework\Attributes\IgnoreDeprecations; + +/** + * Tests the Database system's various fetch capabilities. + * + * We get timeout errors if we try to run too many tests at once. + * + * @group Database + */ +class FetchLegacyTest extends DatabaseTestBase { + + /** + * Confirms that we can fetch a record to an object explicitly. + */ + #[IgnoreDeprecations] + public function testQueryFetchObject(): void { + $this->expectDeprecation("Passing the 'fetch' key as an integer to \$options in query() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338"); + $this->expectDeprecation("Passing the 'fetch' key as an integer to \$options in prepareStatement() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338"); + $this->expectDeprecation("Passing the 'fetch' key as an integer to \$options in execute() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338"); + $records = []; + $result = $this->connection->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25], ['fetch' => \PDO::FETCH_OBJ]); + foreach ($result as $record) { + $records[] = $record; + $this->assertIsObject($record); + $this->assertSame('John', $record->name); + } + + $this->assertCount(1, $records, 'There is only one record.'); + } + + /** + * Confirms that we can fetch a record to an associative array explicitly. + */ + #[IgnoreDeprecations] + public function testQueryFetchArray(): void { + $this->expectDeprecation("Passing the 'fetch' key as an integer to \$options in query() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338"); + $this->expectDeprecation("Passing the 'fetch' key as an integer to \$options in prepareStatement() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338"); + $this->expectDeprecation("Passing the 'fetch' key as an integer to \$options in execute() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338"); + $records = []; + $result = $this->connection->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25], ['fetch' => \PDO::FETCH_ASSOC]); + foreach ($result as $record) { + $records[] = $record; + $this->assertIsArray($record); + $this->assertArrayHasKey('name', $record); + $this->assertSame('John', $record['name']); + } + + $this->assertCount(1, $records, 'There is only one record.'); + } + + /** + * Confirms that we can fetch a record into an indexed array explicitly. + */ + #[IgnoreDeprecations] + public function testQueryFetchNum(): void { + $this->expectDeprecation("Passing the 'fetch' key as an integer to \$options in query() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338"); + $this->expectDeprecation("Passing the 'fetch' key as an integer to \$options in prepareStatement() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338"); + $this->expectDeprecation("Passing the 'fetch' key as an integer to \$options in execute() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338"); + $records = []; + $result = $this->connection->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25], ['fetch' => \PDO::FETCH_NUM]); + foreach ($result as $record) { + $records[] = $record; + $this->assertIsArray($record); + $this->assertArrayHasKey(0, $record); + $this->assertSame('John', $record[0]); + } + + $this->assertCount(1, $records, 'There is only one record'); + } + + /** + * Confirms that we can fetch all records into an array explicitly. + */ + #[IgnoreDeprecations] + public function testQueryFetchAllColumn(): void { + $this->expectDeprecation("Passing the \$mode argument as an integer to fetchAll() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338"); + $query = $this->connection->select('test'); + $query->addField('test', 'name'); + $query->orderBy('name'); + $query_result = $query->execute()->fetchAll(\PDO::FETCH_COLUMN); + + $expected_result = ['George', 'John', 'Paul', 'Ringo']; + $this->assertEquals($expected_result, $query_result, 'Returned the correct result.'); + } + + /** + * Tests ::fetchAllAssoc(). + */ + #[IgnoreDeprecations] + public function testQueryFetchAllAssoc(): void { + $this->expectDeprecation("Passing the \$fetch argument as an integer to fetchAllAssoc() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338"); + $expected_result = [ + "Singer" => [ + "id" => "2", + "name" => "George", + "age" => "27", + "job" => "Singer", + ], + "Drummer" => [ + "id" => "3", + "name" => "Ringo", + "age" => "28", + "job" => "Drummer", + ], + ]; + + $statement = $this->connection->query('SELECT * FROM {test} WHERE [age] > :age', [':age' => 26]); + $result = $statement->fetchAllAssoc('job', \PDO::FETCH_ASSOC); + $this->assertSame($expected_result, $result); + + $statement = $this->connection->query('SELECT * FROM {test} WHERE [age] > :age', [':age' => 26]); + $result = $statement->fetchAllAssoc('job', \PDO::FETCH_OBJ); + $this->assertEquals((object) $expected_result['Singer'], $result['Singer']); + $this->assertEquals((object) $expected_result['Drummer'], $result['Drummer']); + } + + /** + * Confirms that we can fetch a single column value. + */ + #[IgnoreDeprecations] + public function testQueryFetchColumn(): void { + $statement = $this->connection + ->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25]); + $statement->setFetchMode(\PDO::FETCH_COLUMN, 0); + $this->assertSame('John', $statement->fetch()); + } + + /** + * Confirms that an out of range index throws an error. + */ + #[IgnoreDeprecations] + public function testQueryFetchColumnOutOfRange(): void { + $this->expectException(\ValueError::class); + $this->expectExceptionMessage('Invalid column index'); + $statement = $this->connection + ->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25]); + $statement->setFetchMode(\PDO::FETCH_COLUMN, 200); + $statement->fetch(); + } + +} diff --git a/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php b/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php index 62c87e32d130635a87dd414b9b96c56c585137ca..47fbd33f31a8735e8128383463bdd75c46a8e739 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php @@ -5,6 +5,7 @@ namespace Drupal\KernelTests\Core\Database; use Drupal\Core\Database\RowCountException; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Database\StatementInterface; use Drupal\Core\Database\StatementPrefetchIterator; use Drupal\Tests\system\Functional\Database\FakeRecord; @@ -41,7 +42,7 @@ public function testQueryFetchDefault(): void { public function testQueryFetchColumn(): void { $statement = $this->connection ->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25]); - $statement->setFetchMode(\PDO::FETCH_COLUMN, 0); + $statement->setFetchMode(FetchAs::Column, 0); $this->assertSame('John', $statement->fetch()); } @@ -53,7 +54,7 @@ public function testQueryFetchColumnOutOfRange(): void { $this->expectExceptionMessage('Invalid column index'); $statement = $this->connection ->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25]); - $statement->setFetchMode(\PDO::FETCH_COLUMN, 200); + $statement->setFetchMode(FetchAs::Column, 200); $statement->fetch(); } @@ -62,7 +63,7 @@ public function testQueryFetchColumnOutOfRange(): void { */ public function testQueryFetchObject(): void { $records = []; - $result = $this->connection->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25], ['fetch' => \PDO::FETCH_OBJ]); + $result = $this->connection->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25], ['fetch' => FetchAs::Object]); foreach ($result as $record) { $records[] = $record; $this->assertIsObject($record); @@ -77,7 +78,7 @@ public function testQueryFetchObject(): void { */ public function testQueryFetchArray(): void { $records = []; - $result = $this->connection->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25], ['fetch' => \PDO::FETCH_ASSOC]); + $result = $this->connection->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25], ['fetch' => FetchAs::Associative]); foreach ($result as $record) { $records[] = $record; $this->assertIsArray($record); @@ -146,7 +147,7 @@ public function testQueryFetchObjectClassNoConstructorArgs(): void { */ public function testQueryFetchNum(): void { $records = []; - $result = $this->connection->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25], ['fetch' => \PDO::FETCH_NUM]); + $result = $this->connection->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25], ['fetch' => FetchAs::List]); foreach ($result as $record) { $records[] = $record; $this->assertIsArray($record); @@ -164,7 +165,7 @@ public function testQueryFetchAllColumn(): void { $query = $this->connection->select('test'); $query->addField('test', 'name'); $query->orderBy('name'); - $query_result = $query->execute()->fetchAll(\PDO::FETCH_COLUMN); + $query_result = $query->execute()->fetchAll(FetchAs::Column); $expected_result = ['George', 'John', 'Paul', 'Ringo']; $this->assertEquals($expected_result, $query_result, 'Returned the correct result.'); @@ -261,11 +262,11 @@ public function testQueryFetchAllAssoc(): void { ]; $statement = $this->connection->query('SELECT * FROM {test} WHERE [age] > :age', [':age' => 26]); - $result = $statement->fetchAllAssoc('job', \PDO::FETCH_ASSOC); + $result = $statement->fetchAllAssoc('job', FetchAs::Associative); $this->assertSame($expected_result, $result); $statement = $this->connection->query('SELECT * FROM {test} WHERE [age] > :age', [':age' => 26]); - $result = $statement->fetchAllAssoc('job', \PDO::FETCH_OBJ); + $result = $statement->fetchAllAssoc('job', FetchAs::Object); $this->assertEquals((object) $expected_result['Singer'], $result['Singer']); $this->assertEquals((object) $expected_result['Drummer'], $result['Drummer']); } diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php index b20789bd9e3cd32e242d20a2bdf87d91195281ac..7b5f567cdae923192bddcb5247a5dfdea432676f 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php @@ -7,6 +7,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\Database\Query\PagerSelectExtender; use Drupal\Core\Database\RowCountException; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\user\Entity\User; /** @@ -185,7 +186,7 @@ public function testDistinct(): void { $query->addField('test_task', 'task'); $query->orderBy('task'); $query->distinct(); - $query_result = $query->execute()->fetchAll(\PDO::FETCH_COLUMN); + $query_result = $query->execute()->fetchAll(FetchAs::Column); $expected_result = ['code', 'eat', 'found new band', 'perform at superbowl', 'sing', 'sleep']; $this->assertEquals($query_result, $expected_result, 'Returned the correct result.'); diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectOrderedTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectOrderedTest.php index b3cc7c2d2ced9a464f3489f404869fc79983f710..8a319448790f9863df212382c677ee96e61ddc76 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/SelectOrderedTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/SelectOrderedTest.php @@ -4,6 +4,8 @@ namespace Drupal\KernelTests\Core\Database; +use Drupal\Core\Database\Statement\FetchAs; + /** * Tests the Select query builder. * @@ -52,7 +54,7 @@ public function testSimpleSelectMultiOrdered(): void { ['George', 27, 'Singer'], ['Paul', 26, 'Songwriter'], ]; - $results = $result->fetchAll(\PDO::FETCH_NUM); + $results = $result->fetchAll(FetchAs::List); foreach ($expected as $k => $record) { $num_records++; foreach ($record as $kk => $col) { diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php index 247a1ee82e2696ca733c093140c8decad83cb618..199d2c00a026fb7832cb93e88d62d2f961a9a565 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php @@ -417,7 +417,7 @@ protected function doEditStep($active_langcode, $default_revision, $untranslatab $violations = $entity->validate(); $messages = []; foreach ($violations as $violation) { - /** \Symfony\Component\Validator\ConstraintViolationInterface */ + /** @var \Symfony\Component\Validator\ConstraintViolationInterface */ $messages[] = $violation->getMessage(); } $this->assertEquals($valid, !$violations->count(), $this->formatMessage('Validation does not match the expected result: %s', implode(', ', $messages))); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateProviderTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateProviderTest.php index 810915aff6e93525239b3bb4d05c0b4d66a64364..f8c62110eb1b96f4d7657b2eddaa9cc5794b6937 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateProviderTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateProviderTest.php @@ -4,6 +4,7 @@ namespace Drupal\KernelTests\Core\Entity; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait; @@ -152,7 +153,7 @@ public function testBaseFieldDeleteWithExistingData($entity_type_id, $create_ent ->orderBy('revision_id', 'ASC') ->orderBy('langcode', 'ASC') ->execute() - ->fetchAll(\PDO::FETCH_ASSOC); + ->fetchAll(FetchAs::Associative); $this->assertSameSize($expected, $result); // Use assertEquals and not assertSame here to prevent that a different @@ -192,7 +193,7 @@ public function testBaseFieldDeleteWithExistingData($entity_type_id, $create_ent ->orderBy('revision_id', 'ASC') ->orderBy('langcode', 'ASC') ->execute() - ->fetchAll(\PDO::FETCH_ASSOC); + ->fetchAll(FetchAs::Associative); $this->assertSameSize($expected, $result); // Use assertEquals and not assertSame here to prevent that a different diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php index f6d174545829e9789c58431cce7cbbe465af5807..13a97a2dc8f8de16a13d0babe1ae124cd5259ada 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php @@ -41,7 +41,7 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase { public $accounts; /** - * entity_test entities. + * The entity_test entities. * * @var array */ diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php index db858e1d516763e352354b925acec065eab37489..8b6d9ed52eb693069a0b5e56b5f7629fbb02f847 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php @@ -5,6 +5,7 @@ namespace Drupal\KernelTests\Core\Entity; use Drupal\Core\Database\Database; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -201,7 +202,7 @@ public function testFieldWrite(): void { $connection = Database::getConnection(); // Read the tables and check the correct values have been stored. - $rows = $connection->select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); + $rows = $connection->select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', FetchAs::Associative); $this->assertCount($this->fieldCardinality, $rows); foreach ($rows as $delta => $row) { $expected = [ @@ -225,7 +226,7 @@ public function testFieldWrite(): void { $values_count = count($values); $entity->{$this->fieldName} = $values; $entity->save(); - $rows = $connection->select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); + $rows = $connection->select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', FetchAs::Associative); $this->assertCount($values_count, $rows); foreach ($rows as $delta => $row) { $expected = [ @@ -253,7 +254,7 @@ public function testFieldWrite(): void { // Check that data for both revisions are in the revision table. foreach ($revision_values as $revision_id => $values) { - $rows = $connection->select($this->revisionTable, 't')->fields('t')->condition('revision_id', $revision_id)->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); + $rows = $connection->select($this->revisionTable, 't')->fields('t')->condition('revision_id', $revision_id)->execute()->fetchAllAssoc('delta', FetchAs::Associative); $this->assertCount(min(count($values), $this->fieldCardinality), $rows); foreach ($rows as $delta => $row) { $expected = [ @@ -272,7 +273,7 @@ public function testFieldWrite(): void { // Test emptying the field. $entity->{$this->fieldName} = NULL; $entity->save(); - $rows = $connection->select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); + $rows = $connection->select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', FetchAs::Associative); $this->assertCount(0, $rows); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php index 090449136725d0080004be987391dbdf7282a997..6935d6e65ca75a966ce64a0c60a7abde71519cd4 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php @@ -71,7 +71,7 @@ public function testValidation(): void { * Gets the form errors for a given entity. * * @param \Drupal\Core\Entity\EntityInterface $entity - * The entity + * The entity. * @param array $hidden_fields * (optional) A list of hidden fields. * diff --git a/core/tests/Drupal/KernelTests/Core/Field/Entity/BaseFieldOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Field/Entity/BaseFieldOverrideTest.php index 1fc1c5d9ffa0850f2a94ac5eda87628c4ed62f98..0262f800bc8486ed921e306b237f65489a49d25f 100644 --- a/core/tests/Drupal/KernelTests/Core/Field/Entity/BaseFieldOverrideTest.php +++ b/core/tests/Drupal/KernelTests/Core/Field/Entity/BaseFieldOverrideTest.php @@ -95,7 +95,8 @@ public function testInheritedProperties(): void { ->setName('Test Field') ->setTargetEntityTypeId('entity_test') ->setReadOnly(TRUE) - /** Ensure that the internal property is inherited from the base field and not the parent class. @see FieldConfigBase::isInternal */ + // Ensure that the internal property is inherited from the base field and + // not the parent class. @see FieldConfigBase::isInternal ->setInternal(TRUE) ->setComputed(FALSE); diff --git a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php index e446a426f96f9147e551c906e6003eccb5807933..f4ec24206588b5c5cc9dfadd1b47a08216d2f138 100644 --- a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php +++ b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php @@ -192,6 +192,13 @@ public static function providerTestImageFiles(): array { 'arguments' => ['extension' => 'webp'], 'corners' => $default_corners, ], + 'convert_avif' => [ + 'operation' => 'convert', + 'width' => 40, + 'height' => 20, + 'arguments' => ['extension' => 'avif'], + 'corners' => $default_corners, + ], ]; // Systems using non-bundled GD2 may miss imagerotate(). Test if available. @@ -262,6 +269,7 @@ public static function providerTestImageFiles(): array { 'image-test-no-transparency.gif', 'image-test.jpg', 'img-test.webp', + 'img-test.avif', ] as $file_name) { foreach ($test_cases as $test_case => $values) { $operation = $values['operation']; @@ -340,8 +348,11 @@ public function testManipulations(string $file_name, string $test_case, string $ continue; } - // JPEG has small differences in color after processing. - $tolerance = $image_original_type === IMAGETYPE_JPEG ? 3 : 0; + // JPEG and AVIF have small differences in color after processing. + $tolerance = match($image_original_type) { + IMAGETYPE_JPEG, IMAGETYPE_AVIF => 3, + default => 0, + }; $this->assertColorsAreEqual($expected_color, $actual_color, $tolerance, "Image '$file_name' object after '$test_case' action has the correct color placement at corner '$key'"); } @@ -357,7 +368,7 @@ public function testManipulations(string $file_name, string $test_case, string $ */ public function testSupportedExtensions(): void { // Test the list of supported extensions. - $expected_extensions = ['png', 'gif', 'jpeg', 'jpg', 'jpe', 'webp']; + $expected_extensions = ['png', 'gif', 'jpeg', 'jpg', 'jpe', 'webp', 'avif']; $this->assertEqualsCanonicalizing($expected_extensions, $this->imageFactory->getSupportedExtensions()); // Test that the supported extensions map to correct internal GD image @@ -369,6 +380,7 @@ public function testSupportedExtensions(): void { 'jpg' => IMAGETYPE_JPEG, 'jpe' => IMAGETYPE_JPEG, 'webp' => IMAGETYPE_WEBP, + 'avif' => IMAGETYPE_AVIF, ]; $image = $this->imageFactory->get(); foreach ($expected_image_types as $extension => $expected_image_type) { @@ -385,6 +397,7 @@ public static function providerSupportedImageTypes(): array { [IMAGETYPE_GIF], [IMAGETYPE_JPEG], [IMAGETYPE_WEBP], + [IMAGETYPE_AVIF], ]; } @@ -517,7 +530,7 @@ public function testGetRequirements(): void { 'version' => [ 'title' => 'GD library', 'value' => gd_info()['GD Version'], - 'description' => sprintf("Supported image file formats: %s.", implode(', ', ['GIF', 'JPEG', 'PNG', 'WEBP'])), + 'description' => sprintf("Supported image file formats: %s.", implode(', ', ['GIF', 'JPEG', 'PNG', 'WEBP', 'AVIF'])), ], ], $this->imageFactory->get()->getToolkit()->getRequirements()); } diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php index baa01d730b200896261686e3ca0018ee0bb1bff7..6c8540e06a0660d6778aaf76448564ec5b80f3a6 100644 --- a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php @@ -5,6 +5,7 @@ namespace Drupal\KernelTests\Core\Menu; use Drupal\Component\Plugin\Exception\PluginException; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Menu\MenuTreeParameters; use Drupal\Core\Menu\MenuTreeStorage; use Drupal\KernelTests\KernelTestBase; @@ -409,7 +410,7 @@ protected function moveMenuLink($id, $new_parent): void { * Tests that a link's stored representation matches the expected values. * * @param string $id - * The ID of the menu link to test + * The ID of the menu link to test. * @param array $expected_properties * A keyed array of column names and values like has_children and depth. * @param array $parents @@ -426,7 +427,7 @@ protected function assertMenuLink(string $id, array $expected_properties, array foreach ($expected_properties as $field => $value) { $query->condition($field, $value); } - $all = $query->execute()->fetchAll(\PDO::FETCH_ASSOC); + $all = $query->execute()->fetchAll(FetchAs::Associative); $this->assertCount(1, $all, "Found link $id matching all the expected properties"); $raw = reset($all); diff --git a/core/tests/Drupal/KernelTests/Core/Queue/QueueSerializationTest.php b/core/tests/Drupal/KernelTests/Core/Queue/QueueSerializationTest.php index 98c5d0bf23c8b301c6673f2943fb8f8024cc970f..a2be37b8f22f51a8b060581ca6cea6a9e4816604 100644 --- a/core/tests/Drupal/KernelTests/Core/Queue/QueueSerializationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Queue/QueueSerializationTest.php @@ -42,7 +42,7 @@ public function getFormId() { * Process callback. * * @param array $element - * Form element + * Form element. * * @return array * Processed element. diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php index 28239c71cda160eceb3d5f7df9efad8e3ff6af6d..6f8880376327375bd513ff0f24425f11065e64cb 100644 --- a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php +++ b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php @@ -1256,7 +1256,7 @@ public function getSomeOtherParameter() { * Provides a factory method to get a service. * * @param string $class - * The class name of the class to instantiate + * The class name of the class to instantiate. * @param array $arguments * (optional) Arguments to pass to the new class. * diff --git a/core/tests/Drupal/Tests/Composer/Generator/MetapackageUpdateTest.php b/core/tests/Drupal/Tests/Composer/Generator/MetapackageUpdateTest.php index 5a9df6df8f7f0cf32abde8bd326b633095b6d70b..8a3320d886d1caaeed97c492ff9fdb1cd20ebe8a 100644 --- a/core/tests/Drupal/Tests/Composer/Generator/MetapackageUpdateTest.php +++ b/core/tests/Drupal/Tests/Composer/Generator/MetapackageUpdateTest.php @@ -51,7 +51,7 @@ public static function updatedTestData() { * @param string $builderClass * The metapackage builder to test. * @param string $path - * The relative path to the metapackage + * The relative path to the metapackage. * * @dataProvider updatedTestData */ diff --git a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php index 337f51c6183993d60080a56b4dbd4e51ae503daa..3d368aaf482abc3d1165994923235e6c467823e7 100644 --- a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php +++ b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php @@ -198,6 +198,9 @@ public function testProjectThatScaffoldsEmptyProject(): void { $this->assertAutoloadFileCorrect($result->docroot()); } + /** + * Provides test values for testScaffoldOverridingSettingsExcludingHtaccess. + */ public static function scaffoldOverridingSettingsExcludingHtaccessValues() { return [ [ diff --git a/core/tests/Drupal/Tests/ComposerIntegrationTest.php b/core/tests/Drupal/Tests/ComposerIntegrationTest.php index f3634f8ee38272bd10e6c416005ec1110265af6f..ff5d3faebce82052717cce7142febfc649cfa951 100644 --- a/core/tests/Drupal/Tests/ComposerIntegrationTest.php +++ b/core/tests/Drupal/Tests/ComposerIntegrationTest.php @@ -179,11 +179,11 @@ public static function providerTestExpectedScaffoldFiles() { * See https://www.drupal.org/project/drupal/issues/3075954 * * @param string $destRelPath - * Path to scaffold file destination location + * Path to scaffold file destination location. * @param string $sourceRelPath - * Path to scaffold file source location + * Path to scaffold file source location. * @param string $expectedDestination - * Named location to the destination path of the scaffold file + * Named location to the destination path of the scaffold file. * * @dataProvider providerTestExpectedScaffoldFiles */ diff --git a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php index 15e4cf28aa1a7f621b8e240d1090428f4b46ecb2..f9b25e8e70723b7dac051c6fd68526fbc23231b0 100644 --- a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php +++ b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php @@ -6,10 +6,13 @@ use Composer\Autoload\ClassLoader; use Drupal\Core\Database\Database; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Database\StatementPrefetchIterator; use Drupal\Tests\Core\Database\Stub\StubConnection; use Drupal\Tests\Core\Database\Stub\StubPDO; use Drupal\Tests\UnitTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\IgnoreDeprecations; /** * Tests the Connection class. @@ -890,7 +893,7 @@ public static function providerMockedBacktrace(): array { * elements: * - a PDO fetch mode. */ - public static function providerSupportedFetchModes(): array { + public static function providerSupportedLegacyFetchModes(): array { return [ 'FETCH_ASSOC' => [\PDO::FETCH_ASSOC], 'FETCH_CLASS' => [\PDO::FETCH_CLASS], @@ -901,12 +904,42 @@ public static function providerSupportedFetchModes(): array { ]; } + /** + * Tests supported fetch modes. + */ + #[IgnoreDeprecations] + #[DataProvider('providerSupportedLegacyFetchModes')] + public function testSupportedLegacyFetchModes(int $mode): void { + $this->expectDeprecation("Passing the \$mode argument as an integer to setFetchMode() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338"); + $mockPdo = $this->createMock(StubPDO::class); + $mockConnection = new StubConnection($mockPdo, []); + $statement = new StatementPrefetchIterator($mockPdo, $mockConnection, ''); + $this->assertInstanceOf(StatementPrefetchIterator::class, $statement); + $statement->setFetchMode($mode); + } + + /** + * Provides data for testSupportedFetchModes. + * + * @return array<string,array<\Drupal\Core\Database\FetchAs>> + * The FetchAs cases. + */ + public static function providerSupportedFetchModes(): array { + return [ + 'Associative array' => [FetchAs::Associative], + 'Classed object' => [FetchAs::ClassObject], + 'Single column' => [FetchAs::Column], + 'Simple array' => [FetchAs::List], + 'Standard object' => [FetchAs::Object], + ]; + } + /** * Tests supported fetch modes. * * @dataProvider providerSupportedFetchModes */ - public function testSupportedFetchModes(int $mode): void { + public function testSupportedFetchModes(FetchAs $mode): void { $mockPdo = $this->createMock(StubPDO::class); $mockConnection = new StubConnection($mockPdo, []); $statement = new StatementPrefetchIterator($mockPdo, $mockConnection, ''); @@ -937,12 +970,13 @@ public static function providerUnsupportedFetchModes(): array { } /** - * Tests unsupported fetch modes. - * - * @dataProvider providerUnsupportedFetchModes + * Tests unsupported legacy fetch modes. */ + #[IgnoreDeprecations] + #[DataProvider('providerUnsupportedFetchModes')] public function testUnsupportedFetchModes(int $mode): void { - $this->expectException(\AssertionError::class); + $this->expectDeprecation("Passing the \$mode argument as an integer to setFetchMode() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \Drupal\Core\Database\FetchAs enum instead. See https://www.drupal.org/node/3488338"); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessageMatches("/^Fetch mode FETCH_.* is not supported\\. Use supported modes only/"); $mockPdo = $this->createMock(StubPDO::class); $mockConnection = new StubConnection($mockPdo, []); diff --git a/core/tests/Drupal/Tests/Core/Database/SchemaIntrospectionTestTrait.php b/core/tests/Drupal/Tests/Core/Database/SchemaIntrospectionTestTrait.php index b9e4068c278961f530208b29b929edb84c38f5b5..2168fdb2a112bef977d57c772d3cc3f15c0776b0 100644 --- a/core/tests/Drupal/Tests/Core/Database/SchemaIntrospectionTestTrait.php +++ b/core/tests/Drupal/Tests/Core/Database/SchemaIntrospectionTestTrait.php @@ -15,7 +15,7 @@ trait SchemaIntrospectionTestTrait { * @param string $table_name * A non-prefixed table name. * @param array $column_names - * An array of column names + * An array of column names. * @param string $index_type * (optional) The type of the index. Can be one of 'index', 'unique' or * 'primary'. Defaults to 'index'. @@ -36,7 +36,7 @@ protected function assertIndexOnColumns($table_name, array $column_names, $index * @param string $table_name * A non-prefixed table name. * @param array $column_names - * An array of column names + * An array of column names. * @param string $index_type * (optional) The type of the index. Can be one of 'index', 'unique' or * 'primary'. Defaults to 'index'. diff --git a/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php index 7018c36463a1d30cf71cf3ed6710c36ad677ac85..7f5eeb3dd1b6134739ee523b6ca85a66654885f0 100644 --- a/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php +++ b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php @@ -160,7 +160,7 @@ class FakeAutoloader { * Registers this instance as an autoloader. * * @param bool $prepend - * Whether to prepend the autoloader or not + * Whether to prepend the autoloader or not. */ public function register($prepend = FALSE): void { spl_autoload_register([$this, 'loadClass'], TRUE, $prepend); diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php index 56af7a64cd16cf08b39ac093ed2fad11c812400d..5e62ce63c88acba70c75fd9d932831a42b0d995d 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php @@ -1451,7 +1451,7 @@ public function setUpStorageDefinition($field_name, array $schema): void { } /** - * ::onEntityTypeUpdate. + * @covers \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::onEntityTypeUpdate() */ public function testonEntityTypeUpdateWithNewIndex(): void { $this->entityType = $original_entity_type = new ContentEntityType([ diff --git a/core/tests/Drupal/Tests/Core/File/FileUploadSanitizeNameEventTest.php b/core/tests/Drupal/Tests/Core/File/FileUploadSanitizeNameEventTest.php index dd5b8f93a6523e415e2e386cb1dead3a969824ce..15a584ef39db36cac7af1c2e87c608808f7ad2c4 100644 --- a/core/tests/Drupal/Tests/Core/File/FileUploadSanitizeNameEventTest.php +++ b/core/tests/Drupal/Tests/Core/File/FileUploadSanitizeNameEventTest.php @@ -64,7 +64,7 @@ public function testAllowedExtensions(): void { * Test event construction. * * @param string $filename - * The filename to test + * The filename to test. * * @dataProvider provideFilenames * @covers ::__construct diff --git a/core/tests/Drupal/Tests/Core/Hook/HookCollectorPassTest.php b/core/tests/Drupal/Tests/Core/Hook/HookCollectorPassTest.php index 546b489cb4c5b6dda743c22dd613d401251828f9..4b92b8d6d25f4e4217e09f0dea4bb730d716f8fd 100644 --- a/core/tests/Drupal/Tests/Core/Hook/HookCollectorPassTest.php +++ b/core/tests/Drupal/Tests/Core/Hook/HookCollectorPassTest.php @@ -89,7 +89,7 @@ public function testGroupIncludes(): void { * @covers ::getHookAttributesInClass */ public function testGetHookAttributesInClass(): void { - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line $getHookAttributesInClass = fn ($class) => $this->getHookAttributesInClass($class); $p = new HookCollectorPass(); $getHookAttributesInClass = $getHookAttributesInClass->bindTo($p, $p); diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php index fd2ddc5acf4d46e3b1823477ae325811ad2218ae..db468df6f01c7d4ba43972d3c485490dba0e7a9c 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php @@ -120,7 +120,7 @@ protected function getLocalTaskManager($module_dirs, $route_name, $route_params) * @param string $route_name * Route name to base task building on. * @param array $expected_tasks - * A list of tasks groups by level expected at the given route + * A list of tasks groups by level expected at the given route. * @param array $route_params * (optional) A list of route parameters used to resolve tasks. */ diff --git a/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php b/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php index f934071037c7d40423e0697b5bdb9a120c871901..887aa67098bb9df8be8ee3666e0959883b6b2573 100644 --- a/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php @@ -140,7 +140,7 @@ public function testSaveOverride(): void { * @param array|string $ids * Either a single ID or multiple ones as array. * @param array $old_definitions - * The definitions before the deleting + * The definitions before the deleting. * @param array $new_definitions * The definitions after the deleting. * diff --git a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php index ca7a03666a7cda506c32549ea75b70e6e0b8b643..1acd9123a834314750a2b0ee92e874f30c5d660f 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php @@ -1152,6 +1152,8 @@ protected function generatePlaceholdersWithChildrenTestElement(array $args_1, ar } /** + * Sets up the theme manager for the <details>-tag. + * * @return \Drupal\Core\Theme\ThemeManagerInterface|\PHPUnit\Framework\MockObject\Builder\InvocationMocker * The mocked theme manager. */ diff --git a/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php index 3e7981c0a3cc3a13d56a2468b11d997070206eba..0cc2424b9749b845cefe3fd851d2684aa2fbf28c 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php @@ -27,7 +27,7 @@ protected function setUpRenderRecursionComplexElements(): array { } /** - * ::renderRoot() may not be called inside of another ::renderRoot() call. + * Tests that renderRoot() may not be called recursively. * * @covers ::renderRoot * @covers ::render @@ -56,7 +56,7 @@ public function testRenderRecursionWithNestedRenderRoot(): void { } /** - * ::render() may be called from anywhere. + * Tests that render() may be called from anywhere. * * Including from inside of another ::renderRoot() call. Bubbling must be * performed. diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php b/core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php index c85156e9745b2d9e5f6de0d5ee90c64feaa4e040..0c315efde11e69af8ac2fa61c601459757cb1aee 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php +++ b/core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php @@ -21,11 +21,11 @@ abstract class RouteMatchTestBase extends UnitTestCase { * @param string $name * Route name. * @param \Symfony\Component\Routing\Route $route - * Request object + * Request object. * @param array $parameters - * Parameters array + * Parameters array. * @param array $raw_parameters - * Raw parameters array + * Raw parameters array. * * @return \Drupal\Core\Routing\RouteMatchInterface * The constructed route match instance. diff --git a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php deleted file mode 100644 index e013aaed8cdb0dd31eba6f71f77678afffbfeb38..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\Tests\Core\StringTranslation; - -use Drupal\Core\StringTranslation\TranslatableMarkup; -use Drupal\Core\StringTranslation\TranslationWrapper; -use Drupal\Tests\UnitTestCase; - -/** - * Tests the TranslationWrapper backward compatibility layer. - * - * @coversDefaultClass \Drupal\Core\StringTranslation\TranslationWrapper - * @group StringTranslation - */ -class TranslationWrapperTest extends UnitTestCase { - - /** - * @covers ::__construct - */ - public function testTranslationWrapper(): void { - $object = new TranslationWrapper('Backward compatibility'); - $this->assertInstanceOf(TranslatableMarkup::class, $object); - } - -} diff --git a/core/tests/Drupal/Tests/WebAssert.php b/core/tests/Drupal/Tests/WebAssert.php index 79195aab829eb86496b921d80cdecae269904568..4719799e39924b1f1dea51786ba43586704273a3 100644 --- a/core/tests/Drupal/Tests/WebAssert.php +++ b/core/tests/Drupal/Tests/WebAssert.php @@ -35,7 +35,7 @@ class WebAssert extends MinkWebAssert { * Constructor. * * @param \Behat\Mink\Session $session - * The Behat session object; + * The Behat session object. * @param string $base_url * The base URL of the site under test. */ diff --git a/core/tests/fixtures/files/img-test.avif b/core/tests/fixtures/files/img-test.avif new file mode 100644 index 0000000000000000000000000000000000000000..86414841dec7f4cea3bb488ac07e44b0019f5805 --- /dev/null +++ b/core/tests/fixtures/files/img-test.avif @@ -0,0 +1,3 @@ +���ftypmif1����mif1avifmiaf����meta�������!hdlr��������pict����������������pitm��������iloc����@����������b���(iinf��������infe������av01Image����qiprp���Ripco���ispe�������(������pasp���������av1C� �� +8'�Hh���pixi�������ipma�������������jmdat +8'�Hh2VE������,E�Qc�T�f�q��H1��,F��O��*�����t}3rkx�%�E���0D�0���c𪀙Fx��,$_�y�� \ No newline at end of file diff --git a/core/themes/claro/claro.theme b/core/themes/claro/claro.theme index c4a95ffbc6cdab5f97323cece6dfafd971eeb4b3..92dcdc005556a7911ff98c9503bd53419758ef1c 100644 --- a/core/themes/claro/claro.theme +++ b/core/themes/claro/claro.theme @@ -1272,11 +1272,9 @@ function claro_preprocess_system_themes_page(&$variables): void { foreach ($variables['theme_groups'] as &$theme_group) { if (!empty($theme_group['themes'])) { foreach ($theme_group['themes'] as &$theme_card) { - /** - * @todo Remove dependency on attributes after - * https://www.drupal.org/project/drupal/issues/2511548 has been - * resolved. - */ + // @todo Remove dependency on attributes after + // https://www.drupal.org/project/drupal/issues/2511548 has been + // resolved. if (isset($theme_card['screenshot']['#attributes']) && $theme_card['screenshot']['#attributes'] instanceof Attribute && $theme_card['screenshot']['#attributes']->hasClass('no-screenshot')) { unset($theme_card['screenshot']); } diff --git a/core/themes/olivero/olivero.theme b/core/themes/olivero/olivero.theme index 517865ff9b2e8790786237725ffe1718204cb7d3..d10ee7d155cd78cb7f3fbf8e22252787f801e572 100644 --- a/core/themes/olivero/olivero.theme +++ b/core/themes/olivero/olivero.theme @@ -630,7 +630,7 @@ function olivero_form_views_exposed_form_alter(&$form): void { * Converts hex color strings to array of HSL values. * * @param string $hex_string - * The 6-character hexadecimal color code, optionally with a leading hash + * The 6-character hexadecimal color code, optionally with a leading hash. * * @return array * Array containing hue, saturation, and lightness values.