Issue #2572601 by attiks, alexpott, tatarbj: Fix 'Drupal.Classes.ClassCreateInstance' coding standard

8.2.x
Alex Pott 2016-04-27 11:18:44 +01:00
parent b264dd2b81
commit e62a2c7e08
12 changed files with 13 additions and 12 deletions

View File

@ -1528,7 +1528,7 @@ function template_preprocess_field(&$variables, $hook) {
static $default_attributes;
if (!isset($default_attributes)) {
$default_attributes = new Attribute;
$default_attributes = new Attribute();
}
// Merge attributes when a single-value field has a hidden label.

View File

@ -219,7 +219,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
if (!$item) {
return;
}
$header = new PoHeader;
$header = new PoHeader();
$header->setFromString(trim($item->getTranslation()));
$this->_header = $header;
}

View File

@ -68,7 +68,7 @@ class ControllerResolver extends BaseControllerResolver implements ControllerRes
return $controller;
}
elseif (method_exists($controller, '__invoke')) {
return new $controller;
return new $controller();
}
}

View File

@ -1208,7 +1208,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
foreach ($this->serviceProviderClasses as $origin => $classes) {
foreach ($classes as $name => $class) {
if (!is_object($class)) {
$this->serviceProviders[$origin][$name] = new $class;
$this->serviceProviders[$origin][$name] = new $class();
}
else {
$this->serviceProviders[$origin][$name] = $class;

View File

@ -416,7 +416,7 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
*/
public function getDestinationPlugin($stub_being_requested = FALSE) {
if ($stub_being_requested && !empty($this->destination['no_stub'])) {
throw new MigrateSkipRowException;
throw new MigrateSkipRowException();
}
if (!isset($this->destinationPlugin)) {
$this->destinationPlugin = $this->destinationPluginManager->createInstance($this->destination['plugin'], $this->destination, $this);

View File

@ -97,7 +97,7 @@ class MenuLinkParent extends ProcessPluginBase implements ContainerFactoryPlugin
}
}
}
throw new MigrateSkipRowException;
throw new MigrateSkipRowException();
}
}

View File

@ -19,7 +19,7 @@ class SimpletestPhpunitRunCommandTest extends UnitTestCase {
include_once __DIR__ .'/../../fixtures/simpletest_phpunit_run_command_test.php';
$app_root = __DIR__ . '/../../../../../..';
include_once "$app_root/core/modules/simpletest/simpletest.module";
$container = new ContainerBuilder;
$container = new ContainerBuilder();
$container->set('app.root', $app_root);
$file_system = $this->prophesize('Drupal\Core\File\FileSystemInterface');
$file_system->realpath('public://simpletest')->willReturn(sys_get_temp_dir());

View File

@ -14,7 +14,7 @@ class MockFileTransfer {
* A new Drupal\system_test\MockFileTransfer object.
*/
public static function factory() {
return new MockFileTransfer;
return new MockFileTransfer();
}
/**

View File

@ -14,7 +14,7 @@ class MockFileTransfer {
* A new Drupal\update_test\MockFileTransfer object.
*/
public static function factory() {
return new FileTransfer;
return new FileTransfer();
}
/**

View File

@ -12,6 +12,7 @@
<!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.-->
<!-- Drupal sniffs -->
<rule ref="Drupal.Classes.ClassCreateInstance"/>
<rule ref="Drupal.Classes.UnusedUseStatement"/>
<rule ref="Drupal.CSS.ClassDefinitionNameSpacing"/>
<rule ref="Drupal.CSS.ColourDefinition"/>

View File

@ -435,7 +435,7 @@ class AttributeTest extends UnitTestCase {
* The number of results that are found.
*/
protected function getXPathResultCount($query, $html) {
$document = new \DOMDocument;
$document = new \DOMDocument();
$document->loadHTML($html);
$xpath = new \DOMXPath($document);

View File

@ -519,7 +519,7 @@ class LinkGeneratorTest extends UnitTestCase {
}
// Execute the query.
$document = new \DOMDocument;
$document = new \DOMDocument();
$document->loadHTML($html);
$xpath = new \DOMXPath($document);
@ -538,7 +538,7 @@ class LinkGeneratorTest extends UnitTestCase {
* The number of results that are found.
*/
protected function assertNoXPathResults($query, $html) {
$document = new \DOMDocument;
$document = new \DOMDocument();
$document->loadHTML($html);
$xpath = new \DOMXPath($document);