Issue #2901727 by iainp999, mfernea: Fix 'Drupal.Methods.MethodDeclaration' coding standard

8.5.x
Nathaniel Catchpole 2017-09-06 10:34:51 +01:00
parent 38ac1327a1
commit 4207b307d3
15 changed files with 28 additions and 23 deletions

View File

@ -30,7 +30,7 @@ class MockFileFinder implements ClassFinderInterface {
/** /**
* Creates new mock file finder objects. * Creates new mock file finder objects.
*/ */
static public function create($filename) { public static function create($filename) {
$object = new static(); $object = new static();
$object->filename = $filename; $object->filename = $filename;
return $object; return $object;

View File

@ -20,7 +20,7 @@ class Timer {
* @param $name * @param $name
* The name of the timer. * The name of the timer.
*/ */
static public function start($name) { public static function start($name) {
static::$timers[$name]['start'] = microtime(TRUE); static::$timers[$name]['start'] = microtime(TRUE);
static::$timers[$name]['count'] = isset(static::$timers[$name]['count']) ? ++static::$timers[$name]['count'] : 1; static::$timers[$name]['count'] = isset(static::$timers[$name]['count']) ? ++static::$timers[$name]['count'] : 1;
} }
@ -34,7 +34,7 @@ class Timer {
* @return int * @return int
* The current timer value in ms. * The current timer value in ms.
*/ */
static public function read($name) { public static function read($name) {
if (isset(static::$timers[$name]['start'])) { if (isset(static::$timers[$name]['start'])) {
$stop = microtime(TRUE); $stop = microtime(TRUE);
$diff = round(($stop - static::$timers[$name]['start']) * 1000, 2); $diff = round(($stop - static::$timers[$name]['start']) * 1000, 2);
@ -57,7 +57,7 @@ class Timer {
* A timer array. The array contains the number of times the timer has been * 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). * 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'])) { if (isset(static::$timers[$name]['start'])) {
$stop = microtime(TRUE); $stop = microtime(TRUE);
$diff = round(($stop - static::$timers[$name]['start']) * 1000, 2); $diff = round(($stop - static::$timers[$name]['start']) * 1000, 2);

View File

@ -48,7 +48,7 @@ abstract class ArrayElement extends Element implements \IteratorAggregate, Typed
* *
* @return \Drupal\Core\TypedData\DataDefinitionInterface * @return \Drupal\Core\TypedData\DataDefinitionInterface
*/ */
protected abstract function getElementDefinition($key); abstract protected function getElementDefinition($key);
/** /**
* {@inheritdoc} * {@inheritdoc}

View File

@ -33,7 +33,7 @@ abstract class FieldUpdateActionBase extends ActionBase {
* @return array * @return array
* Array of values with field names as keys. * Array of values with field names as keys.
*/ */
protected abstract function getFieldsToUpdate(); abstract protected function getFieldsToUpdate();
/** /**
* {@inheritdoc} * {@inheritdoc}

View File

@ -115,7 +115,7 @@ abstract class FileTransfer {
* @param string $destination * @param string $destination
* The destination path. * The destination path.
*/ */
public final function copyDirectory($source, $destination) { final public function copyDirectory($source, $destination) {
$source = $this->sanitizePath($source); $source = $this->sanitizePath($source);
$destination = $this->fixRemotePath($destination); $destination = $this->fixRemotePath($destination);
$this->checkPath($destination); $this->checkPath($destination);
@ -136,7 +136,7 @@ abstract class FileTransfer {
* *
* @see http://php.net/chmod * @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)) { if (!($this instanceof ChmodInterface)) {
throw new FileTransferException('Unable to change file permissions'); throw new FileTransferException('Unable to change file permissions');
} }
@ -152,7 +152,7 @@ abstract class FileTransfer {
* @param string $directory * @param string $directory
* The directory to be created. * The directory to be created.
*/ */
public final function createDirectory($directory) { final public function createDirectory($directory) {
$directory = $this->fixRemotePath($directory); $directory = $this->fixRemotePath($directory);
$this->checkPath($directory); $this->checkPath($directory);
$this->createDirectoryJailed($directory); $this->createDirectoryJailed($directory);
@ -164,7 +164,7 @@ abstract class FileTransfer {
* @param string $directory * @param string $directory
* The directory to be removed. * The directory to be removed.
*/ */
public final function removeDirectory($directory) { final public function removeDirectory($directory) {
$directory = $this->fixRemotePath($directory); $directory = $this->fixRemotePath($directory);
$this->checkPath($directory); $this->checkPath($directory);
$this->removeDirectoryJailed($directory); $this->removeDirectoryJailed($directory);
@ -178,7 +178,7 @@ abstract class FileTransfer {
* @param string $destination * @param string $destination
* The destination file. * The destination file.
*/ */
public final function copyFile($source, $destination) { final public function copyFile($source, $destination) {
$source = $this->sanitizePath($source); $source = $this->sanitizePath($source);
$destination = $this->fixRemotePath($destination); $destination = $this->fixRemotePath($destination);
$this->checkPath($destination); $this->checkPath($destination);
@ -191,7 +191,7 @@ abstract class FileTransfer {
* @param string $destination * @param string $destination
* The destination file to be removed. * The destination file to be removed.
*/ */
public final function removeFile($destination) { final public function removeFile($destination) {
$destination = $this->fixRemotePath($destination); $destination = $this->fixRemotePath($destination);
$this->checkPath($destination); $this->checkPath($destination);
$this->removeFileJailed($destination); $this->removeFileJailed($destination);
@ -205,7 +205,7 @@ abstract class FileTransfer {
* *
* @throws \Drupal\Core\FileTransfer\FileTransferException * @throws \Drupal\Core\FileTransfer\FileTransferException
*/ */
protected final function checkPath($path) { final protected function checkPath($path) {
$full_jail = $this->chroot . $this->jail; $full_jail = $this->chroot . $this->jail;
$full_path = drupal_realpath(substr($this->chroot . $path, 0, strlen($full_jail))); $full_path = drupal_realpath(substr($this->chroot . $path, 0, strlen($full_jail)));
$full_path = $this->fixRemotePath($full_path, FALSE); $full_path = $this->fixRemotePath($full_path, FALSE);
@ -229,7 +229,7 @@ abstract class FileTransfer {
* @return string * @return string
* The modified path. * The modified path.
*/ */
protected final function fixRemotePath($path, $strip_chroot = TRUE) { final protected function fixRemotePath($path, $strip_chroot = TRUE) {
$path = $this->sanitizePath($path); $path = $this->sanitizePath($path);
$path = preg_replace('|^([a-z]{1}):|i', '', $path); // Strip out windows driveletter if its there. $path = preg_replace('|^([a-z]{1}):|i', '', $path); // Strip out windows driveletter if its there.
if ($strip_chroot) { if ($strip_chroot) {

View File

@ -166,7 +166,7 @@ abstract class ImageToolkitOperationBase extends PluginBase implements ImageTool
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public final function apply(array $arguments) { final public function apply(array $arguments) {
$arguments = $this->prepareArguments($arguments); $arguments = $this->prepareArguments($arguments);
$arguments = $this->validateArguments($arguments); $arguments = $this->validateArguments($arguments);
return $this->execute($arguments); return $this->execute($arguments);

View File

@ -50,7 +50,7 @@ class EditorFileReference extends FilterBase implements ContainerFactoryPluginIn
/** /**
* {@inheritdoc} * {@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( return new static(
$configuration, $configuration,
$plugin_id, $plugin_id,

View File

@ -64,6 +64,6 @@ abstract class ComponentEntityDisplayBase extends DestinationBase {
* @return \Drupal\Core\Entity\Display\EntityDisplayInterface * @return \Drupal\Core\Entity\Display\EntityDisplayInterface
* The entity display object. * The entity display object.
*/ */
protected abstract function getEntity($entity_type, $bundle, $mode); abstract protected function getEntity($entity_type, $bundle, $mode);
} }

View File

@ -177,7 +177,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
* @return array * @return array
* An array of the data for this source. * An array of the data for this source.
*/ */
protected abstract function initializeIterator(); abstract protected function initializeIterator();
/** /**
* Gets the module handler. * Gets the module handler.

View File

@ -117,7 +117,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
/** /**
* {@inheritdoc} * {@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( return new static(
$configuration, $configuration,
$plugin_id, $plugin_id,

View File

@ -69,7 +69,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
* @return \Drupal\Core\Cache\CacheBackendInterface * @return \Drupal\Core\Cache\CacheBackendInterface
* Cache backend to test. * 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. * Allows specific implementation to change the environment before a test run.

View File

@ -52,7 +52,7 @@ class UserSearch extends SearchPluginBase implements AccessibleInterface {
/** /**
* {@inheritdoc} * {@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( return new static(
$container->get('database'), $container->get('database'),
$container->get('entity.manager'), $container->get('entity.manager'),

View File

@ -107,7 +107,7 @@ abstract class AreaPluginBase extends HandlerBase {
* @return array * @return array
* In any case we need a valid Drupal render array to return. * 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. * Does that area have nothing to show.

View File

@ -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/ClassFilesSniff.php"/>
<rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.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/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"> <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php">
<!-- Sniff for: LowerStart --> <!-- Sniff for: LowerStart -->
<exclude name="Drupal.NamingConventions.ValidVariableName.LowerCamelName"/> <exclude name="Drupal.NamingConventions.ValidVariableName.LowerCamelName"/>

View File

@ -66,7 +66,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
* @return \Drupal\Core\Cache\CacheBackendInterface * @return \Drupal\Core\Cache\CacheBackendInterface
* Cache backend to test. * 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. * Allows specific implementation to change the environment before a test run.