Loading core/phpcs.xml.dist +6 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ <!-- cspell:ignore Openercase --> <ruleset name="drupal_core"> <arg name="extensions" value="engine,inc,install,module,php,profile,test,theme,yml"/> <!-- Scan files that are explicitly listed via <file> elements as PHP. --> <arg name="filter" value="core/tests/phpcs/PhpScriptFilter.php"/> <description>Default PHP CodeSniffer configuration for Drupal core.</description> <!--Exclude folders used by common frontend tools. These folders match the file_scan_ignore_directories setting in default.settings.php--> Loading @@ -22,6 +24,7 @@ <file>.</file> <file>../composer</file> <file>scripts/drupal</file> <file>scripts/password-hash.sh</file> <file>scripts/rebuild_token_calculator.sh</file> <file>scripts/run-tests.sh</file> Loading Loading @@ -113,6 +116,9 @@ <rule ref="Drupal.NamingConventions.ValidClassName"/> <rule ref="Drupal.NamingConventions.ValidEnumCase"/> <rule ref="Drupal.NamingConventions.ValidGlobal"/> <rule ref="Drupal.NamingConventions.ValidGlobal.GlobalUnderScore"> <exclude-pattern>scripts/run-tests.sh</exclude-pattern> </rule> <rule ref="Drupal.NamingConventions.ValidVariableName"/> <rule ref="Drupal.NamingConventions.ValidVariableName.LowerCamelName"/> <rule ref="Drupal.Scope.MethodScope"/> Loading core/phpstan.neon.dist +2 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ parameters: - modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/custom_annotation/ExtendingNonInstalledClass.php - modules/system/tests/modules/router_test_directory/src/Controller/TestInvalidController.php - modules/system/tests/modules/router_test_directory/src/Controller/TestMissingDependency.php # The following class is only for PHPCS. - tests/phpcs/PhpScriptFilter.php ignoreErrors: # new static() is a best practice in Drupal, so we cannot fix that. Loading core/scripts/password-hash.sh +1 −4 Original line number Diff line number Diff line Loading @@ -3,10 +3,7 @@ /** * @file * Drupal hash script - to generate a hash from a plaintext password * * @param string[] ...$password * Plain-text passwords in quotes (or with spaces backslash escaped). * Drupal hash script - to generate a hash from a plaintext password. * * @todo Port to a console command. https://www.drupal.org/node/2289409 */ Loading core/scripts/run-tests.sh +1 −1 Original line number Diff line number Diff line Loading @@ -741,7 +741,7 @@ function simpletest_script_get_test_list() { // The '#slow' group is a special case, because it may not be selected in // the argument, but it must be present if any test class indicates it in // metadata, for the work allocator to prioritize its execution. foreach ($groupedTestClassInfoList as $groupName => $testClassInfoList) { foreach ($groupedTestClassInfoList as $testClassInfoList) { foreach ($testClassInfoList as $testClass => $testClassInfo) { if (in_array('#slow', $testClassInfo['groups'])) { $groupedTestClassInfoList['#slow'][$testClass] = $testClassInfo; Loading core/tests/phpcs/PhpScriptFilter.php 0 → 100644 +38 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace phpcs; use PHP_CodeSniffer\Filters\Filter; /** * Allows .sh files explicitly listed in phpcs.xml.dist to be scanned as PHP. * * PHPCS rejects files whose extension is not in the configured extensions list. * Some Drupal scripts use a .sh extension but contain PHP code. This filter * accepts any .sh file that appears in $config->files, i.e. was explicitly * listed via a <file> element in the active ruleset. * * The filter value in phpcs.xml.dist must be a path relative to the directory * from which phpcs is invoked (the project root for Drupal). */ class PhpScriptFilter extends Filter { /** * {@inheritdoc} */ protected function shouldProcessFile($path): bool { $path = (string) $path; $realPath = realpath($path); if ($realPath !== FALSE) { foreach ($this->config->files as $listed) { if ($listed === $realPath) { return TRUE; } } } return parent::shouldProcessFile($path); } } Loading
core/phpcs.xml.dist +6 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ <!-- cspell:ignore Openercase --> <ruleset name="drupal_core"> <arg name="extensions" value="engine,inc,install,module,php,profile,test,theme,yml"/> <!-- Scan files that are explicitly listed via <file> elements as PHP. --> <arg name="filter" value="core/tests/phpcs/PhpScriptFilter.php"/> <description>Default PHP CodeSniffer configuration for Drupal core.</description> <!--Exclude folders used by common frontend tools. These folders match the file_scan_ignore_directories setting in default.settings.php--> Loading @@ -22,6 +24,7 @@ <file>.</file> <file>../composer</file> <file>scripts/drupal</file> <file>scripts/password-hash.sh</file> <file>scripts/rebuild_token_calculator.sh</file> <file>scripts/run-tests.sh</file> Loading Loading @@ -113,6 +116,9 @@ <rule ref="Drupal.NamingConventions.ValidClassName"/> <rule ref="Drupal.NamingConventions.ValidEnumCase"/> <rule ref="Drupal.NamingConventions.ValidGlobal"/> <rule ref="Drupal.NamingConventions.ValidGlobal.GlobalUnderScore"> <exclude-pattern>scripts/run-tests.sh</exclude-pattern> </rule> <rule ref="Drupal.NamingConventions.ValidVariableName"/> <rule ref="Drupal.NamingConventions.ValidVariableName.LowerCamelName"/> <rule ref="Drupal.Scope.MethodScope"/> Loading
core/phpstan.neon.dist +2 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ parameters: - modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/custom_annotation/ExtendingNonInstalledClass.php - modules/system/tests/modules/router_test_directory/src/Controller/TestInvalidController.php - modules/system/tests/modules/router_test_directory/src/Controller/TestMissingDependency.php # The following class is only for PHPCS. - tests/phpcs/PhpScriptFilter.php ignoreErrors: # new static() is a best practice in Drupal, so we cannot fix that. Loading
core/scripts/password-hash.sh +1 −4 Original line number Diff line number Diff line Loading @@ -3,10 +3,7 @@ /** * @file * Drupal hash script - to generate a hash from a plaintext password * * @param string[] ...$password * Plain-text passwords in quotes (or with spaces backslash escaped). * Drupal hash script - to generate a hash from a plaintext password. * * @todo Port to a console command. https://www.drupal.org/node/2289409 */ Loading
core/scripts/run-tests.sh +1 −1 Original line number Diff line number Diff line Loading @@ -741,7 +741,7 @@ function simpletest_script_get_test_list() { // The '#slow' group is a special case, because it may not be selected in // the argument, but it must be present if any test class indicates it in // metadata, for the work allocator to prioritize its execution. foreach ($groupedTestClassInfoList as $groupName => $testClassInfoList) { foreach ($groupedTestClassInfoList as $testClassInfoList) { foreach ($testClassInfoList as $testClass => $testClassInfo) { if (in_array('#slow', $testClassInfo['groups'])) { $groupedTestClassInfoList['#slow'][$testClass] = $testClassInfo; Loading
core/tests/phpcs/PhpScriptFilter.php 0 → 100644 +38 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace phpcs; use PHP_CodeSniffer\Filters\Filter; /** * Allows .sh files explicitly listed in phpcs.xml.dist to be scanned as PHP. * * PHPCS rejects files whose extension is not in the configured extensions list. * Some Drupal scripts use a .sh extension but contain PHP code. This filter * accepts any .sh file that appears in $config->files, i.e. was explicitly * listed via a <file> element in the active ruleset. * * The filter value in phpcs.xml.dist must be a path relative to the directory * from which phpcs is invoked (the project root for Drupal). */ class PhpScriptFilter extends Filter { /** * {@inheritdoc} */ protected function shouldProcessFile($path): bool { $path = (string) $path; $realPath = realpath($path); if ($realPath !== FALSE) { foreach ($this->config->files as $listed) { if ($listed === $realPath) { return TRUE; } } } return parent::shouldProcessFile($path); } }