diff --git a/core/lib/Drupal/Component/Annotation/Reflection/MockFileFinder.php b/core/lib/Drupal/Component/Annotation/Reflection/MockFileFinder.php index 9f585f9119dc3aa3984008b0c25aa22454a5cdb7..ecfefc371e74d0d655ede302490020e19352f781 100644 --- a/core/lib/Drupal/Component/Annotation/Reflection/MockFileFinder.php +++ b/core/lib/Drupal/Component/Annotation/Reflection/MockFileFinder.php @@ -30,7 +30,7 @@ public function findFile($class) { /** * Creates new mock file finder objects. */ - static public function create($filename) { + public static function create($filename) { $object = new static(); $object->filename = $filename; return $object; diff --git a/core/lib/Drupal/Component/Utility/Timer.php b/core/lib/Drupal/Component/Utility/Timer.php index b8dc0269764aae96a47b7327e3bfb100d941844c..4fc36e43aea994cc9bba043f61bf9914001d95ef 100644 --- a/core/lib/Drupal/Component/Utility/Timer.php +++ b/core/lib/Drupal/Component/Utility/Timer.php @@ -20,7 +20,7 @@ class Timer { * @param $name * The name of the timer. */ - static public function start($name) { + public static function start($name) { static::$timers[$name]['start'] = microtime(TRUE); static::$timers[$name]['count'] = isset(static::$timers[$name]['count']) ? ++static::$timers[$name]['count'] : 1; } @@ -34,7 +34,7 @@ static public function start($name) { * @return int * The current timer value in ms. */ - static public function read($name) { + public static function read($name) { if (isset(static::$timers[$name]['start'])) { $stop = microtime(TRUE); $diff = round(($stop - static::$timers[$name]['start']) * 1000, 2); @@ -57,7 +57,7 @@ static public function read($name) { * A timer array. The array contains the number of times the timer has been * started and stopped (count) and the accumulated timer value in ms (time). */ - static public function stop($name) { + public static function stop($name) { if (isset(static::$timers[$name]['start'])) { $stop = microtime(TRUE); $diff = round(($stop - static::$timers[$name]['start']) * 1000, 2); diff --git a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php index b38a94b3c22a0aded5ee388735b13307e11790e1..b16cee0aeaaa560d98b5621045931c86373baf04 100644 --- a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php +++ b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php @@ -48,7 +48,7 @@ protected function parse() { * * @return \Drupal\Core\TypedData\DataDefinitionInterface */ - protected abstract function getElementDefinition($key); + abstract protected function getElementDefinition($key); /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/Field/FieldUpdateActionBase.php b/core/lib/Drupal/Core/Field/FieldUpdateActionBase.php index 6714794f1057bda7d2da7911309de12d23eb3444..03b5255b37018cda02532d7a97dadda2bbd86a0a 100644 --- a/core/lib/Drupal/Core/Field/FieldUpdateActionBase.php +++ b/core/lib/Drupal/Core/Field/FieldUpdateActionBase.php @@ -33,7 +33,7 @@ abstract class FieldUpdateActionBase extends ActionBase { * @return array * Array of values with field names as keys. */ - protected abstract function getFieldsToUpdate(); + abstract protected function getFieldsToUpdate(); /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php index 25014f1338058d927b03620e6aadb58951d24f73..af395a20bbea42acbd1a24335074bd5f59be6998 100644 --- a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php +++ b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php @@ -115,7 +115,7 @@ abstract public function connect(); * @param string $destination * The destination path. */ - public final function copyDirectory($source, $destination) { + final public function copyDirectory($source, $destination) { $source = $this->sanitizePath($source); $destination = $this->fixRemotePath($destination); $this->checkPath($destination); @@ -136,7 +136,7 @@ public final function copyDirectory($source, $destination) { * * @see http://php.net/chmod */ - public final function chmod($path, $mode, $recursive = FALSE) { + final public function chmod($path, $mode, $recursive = FALSE) { if (!($this instanceof ChmodInterface)) { throw new FileTransferException('Unable to change file permissions'); } @@ -152,7 +152,7 @@ public final function chmod($path, $mode, $recursive = FALSE) { * @param string $directory * The directory to be created. */ - public final function createDirectory($directory) { + final public function createDirectory($directory) { $directory = $this->fixRemotePath($directory); $this->checkPath($directory); $this->createDirectoryJailed($directory); @@ -164,7 +164,7 @@ public final function createDirectory($directory) { * @param string $directory * The directory to be removed. */ - public final function removeDirectory($directory) { + final public function removeDirectory($directory) { $directory = $this->fixRemotePath($directory); $this->checkPath($directory); $this->removeDirectoryJailed($directory); @@ -178,7 +178,7 @@ public final function removeDirectory($directory) { * @param string $destination * The destination file. */ - public final function copyFile($source, $destination) { + final public function copyFile($source, $destination) { $source = $this->sanitizePath($source); $destination = $this->fixRemotePath($destination); $this->checkPath($destination); @@ -191,7 +191,7 @@ public final function copyFile($source, $destination) { * @param string $destination * The destination file to be removed. */ - public final function removeFile($destination) { + final public function removeFile($destination) { $destination = $this->fixRemotePath($destination); $this->checkPath($destination); $this->removeFileJailed($destination); @@ -205,7 +205,7 @@ public final function removeFile($destination) { * * @throws \Drupal\Core\FileTransfer\FileTransferException */ - protected final function checkPath($path) { + final protected function checkPath($path) { $full_jail = $this->chroot . $this->jail; $full_path = drupal_realpath(substr($this->chroot . $path, 0, strlen($full_jail))); $full_path = $this->fixRemotePath($full_path, FALSE); @@ -229,7 +229,7 @@ protected final function checkPath($path) { * @return string * The modified path. */ - protected final function fixRemotePath($path, $strip_chroot = TRUE) { + final protected function fixRemotePath($path, $strip_chroot = TRUE) { $path = $this->sanitizePath($path); $path = preg_replace('|^([a-z]{1}):|i', '', $path); // Strip out windows driveletter if its there. if ($strip_chroot) { diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php index c9a93ffe4d3ca8f792b520025f3c438f790c6d2c..dcc3b3d12134ab43ba5f35f10c9267549b4a674e 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php @@ -166,7 +166,7 @@ protected function validateArguments(array $arguments) { /** * {@inheritdoc} */ - public final function apply(array $arguments) { + final public function apply(array $arguments) { $arguments = $this->prepareArguments($arguments); $arguments = $this->validateArguments($arguments); return $this->execute($arguments); diff --git a/core/modules/editor/src/Plugin/Filter/EditorFileReference.php b/core/modules/editor/src/Plugin/Filter/EditorFileReference.php index cf725a71371deb09b52d16a30df795f1b3f2c306..ad2ac033fad13106dc89a68a24eaf7ad6179fee7 100644 --- a/core/modules/editor/src/Plugin/Filter/EditorFileReference.php +++ b/core/modules/editor/src/Plugin/Filter/EditorFileReference.php @@ -50,7 +50,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition /** * {@inheritdoc} */ - static public function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $configuration, $plugin_id, diff --git a/core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php b/core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php index 660248494e110a1327ee08b5d5345ed18cb9021b..eaf3b54da6f94d02a8d7587b364b810208d07378 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php @@ -64,6 +64,6 @@ public function fields(MigrationInterface $migration = NULL) { * @return \Drupal\Core\Entity\Display\EntityDisplayInterface * The entity display object. */ - protected abstract function getEntity($entity_type, $bundle, $mode); + abstract protected function getEntity($entity_type, $bundle, $mode); } diff --git a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php index cef98823befa05b8195514b375b1a0d699aa9b61..503b1e3d50d04934c5df10f41c37c773fb373938 100644 --- a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php @@ -177,7 +177,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition * @return array * An array of the data for this source. */ - protected abstract function initializeIterator(); + abstract protected function initializeIterator(); /** * Gets the module handler. diff --git a/core/modules/node/src/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php index 6d7c8eb7d47e56d1a6f7079225fcfc7ce37738ef..c200f34b6107cf8e3103bdcb26d108acefef8e2e 100644 --- a/core/modules/node/src/Plugin/Search/NodeSearch.php +++ b/core/modules/node/src/Plugin/Search/NodeSearch.php @@ -117,7 +117,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter /** * {@inheritdoc} */ - static public function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $configuration, $plugin_id, diff --git a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php index d47e88a51c37fc0abda346a9dd32579a765377b3..01fef632839fb241c4a299ba707fd838d5d07622 100644 --- a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php +++ b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php @@ -69,7 +69,7 @@ protected function getTestBin() { * @return \Drupal\Core\Cache\CacheBackendInterface * Cache backend to test. */ - protected abstract function createCacheBackend($bin); + abstract protected function createCacheBackend($bin); /** * Allows specific implementation to change the environment before a test run. diff --git a/core/modules/user/src/Plugin/Search/UserSearch.php b/core/modules/user/src/Plugin/Search/UserSearch.php index 063d3ef112252afaaba68917787fdc9974aad6ef..08ea7241a1bc659c9a4d676ab2cda088ffd59906 100644 --- a/core/modules/user/src/Plugin/Search/UserSearch.php +++ b/core/modules/user/src/Plugin/Search/UserSearch.php @@ -52,7 +52,7 @@ class UserSearch extends SearchPluginBase implements AccessibleInterface { /** * {@inheritdoc} */ - static public function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $container->get('database'), $container->get('entity.manager'), diff --git a/core/modules/views/src/Plugin/views/area/AreaPluginBase.php b/core/modules/views/src/Plugin/views/area/AreaPluginBase.php index 813e4306c0987ee4a43b1547eac260b147789998..476a808cd1337852136f63bbb0b1dd26b4d61221 100644 --- a/core/modules/views/src/Plugin/views/area/AreaPluginBase.php +++ b/core/modules/views/src/Plugin/views/area/AreaPluginBase.php @@ -107,7 +107,7 @@ public function preRender(array $results) { * @return array * In any case we need a valid Drupal render array to return. */ - public abstract function render($empty = FALSE); + abstract public function render($empty = FALSE); /** * Does that area have nothing to show. diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index 1913d89f35d3099b1cdadaee69056697bb8e7fd1..5eeb7ce563dc449564faba9bc42307ba2f82895c 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -77,6 +77,11 @@ <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php"/> <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.php"/> <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php"/> + <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Methods/MethodDeclarationSniff.php"> + <!-- Silence method name underscore warning which is covered already in + Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps. --> + <exclude name="Drupal.Methods.MethodDeclaration.Underscore"/> + </rule> <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php"> <!-- Sniff for: LowerStart --> <exclude name="Drupal.NamingConventions.ValidVariableName.LowerCamelName"/> diff --git a/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php b/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php index 4e57a71f6cdf7ac3d37d0d7669487892cbf92e2d..0143f868d38e8161c9a010d1d002f6d4ed98a442 100644 --- a/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php @@ -66,7 +66,7 @@ protected function getTestBin() { * @return \Drupal\Core\Cache\CacheBackendInterface * Cache backend to test. */ - protected abstract function createCacheBackend($bin); + abstract protected function createCacheBackend($bin); /** * Allows specific implementation to change the environment before a test run.