Issue #2572601 by attiks, alexpott, tatarbj: Fix 'Drupal.Classes.ClassCreateInstance' coding standard
parent
b264dd2b81
commit
e62a2c7e08
|
@ -1528,7 +1528,7 @@ function template_preprocess_field(&$variables, $hook) {
|
||||||
|
|
||||||
static $default_attributes;
|
static $default_attributes;
|
||||||
if (!isset($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.
|
// Merge attributes when a single-value field has a hidden label.
|
||||||
|
|
|
@ -219,7 +219,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||||
if (!$item) {
|
if (!$item) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$header = new PoHeader;
|
$header = new PoHeader();
|
||||||
$header->setFromString(trim($item->getTranslation()));
|
$header->setFromString(trim($item->getTranslation()));
|
||||||
$this->_header = $header;
|
$this->_header = $header;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ class ControllerResolver extends BaseControllerResolver implements ControllerRes
|
||||||
return $controller;
|
return $controller;
|
||||||
}
|
}
|
||||||
elseif (method_exists($controller, '__invoke')) {
|
elseif (method_exists($controller, '__invoke')) {
|
||||||
return new $controller;
|
return new $controller();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1208,7 +1208,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
|
||||||
foreach ($this->serviceProviderClasses as $origin => $classes) {
|
foreach ($this->serviceProviderClasses as $origin => $classes) {
|
||||||
foreach ($classes as $name => $class) {
|
foreach ($classes as $name => $class) {
|
||||||
if (!is_object($class)) {
|
if (!is_object($class)) {
|
||||||
$this->serviceProviders[$origin][$name] = new $class;
|
$this->serviceProviders[$origin][$name] = new $class();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->serviceProviders[$origin][$name] = $class;
|
$this->serviceProviders[$origin][$name] = $class;
|
||||||
|
|
|
@ -416,7 +416,7 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
|
||||||
*/
|
*/
|
||||||
public function getDestinationPlugin($stub_being_requested = FALSE) {
|
public function getDestinationPlugin($stub_being_requested = FALSE) {
|
||||||
if ($stub_being_requested && !empty($this->destination['no_stub'])) {
|
if ($stub_being_requested && !empty($this->destination['no_stub'])) {
|
||||||
throw new MigrateSkipRowException;
|
throw new MigrateSkipRowException();
|
||||||
}
|
}
|
||||||
if (!isset($this->destinationPlugin)) {
|
if (!isset($this->destinationPlugin)) {
|
||||||
$this->destinationPlugin = $this->destinationPluginManager->createInstance($this->destination['plugin'], $this->destination, $this);
|
$this->destinationPlugin = $this->destinationPluginManager->createInstance($this->destination['plugin'], $this->destination, $this);
|
||||||
|
|
|
@ -97,7 +97,7 @@ class MenuLinkParent extends ProcessPluginBase implements ContainerFactoryPlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new MigrateSkipRowException;
|
throw new MigrateSkipRowException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ class SimpletestPhpunitRunCommandTest extends UnitTestCase {
|
||||||
include_once __DIR__ .'/../../fixtures/simpletest_phpunit_run_command_test.php';
|
include_once __DIR__ .'/../../fixtures/simpletest_phpunit_run_command_test.php';
|
||||||
$app_root = __DIR__ . '/../../../../../..';
|
$app_root = __DIR__ . '/../../../../../..';
|
||||||
include_once "$app_root/core/modules/simpletest/simpletest.module";
|
include_once "$app_root/core/modules/simpletest/simpletest.module";
|
||||||
$container = new ContainerBuilder;
|
$container = new ContainerBuilder();
|
||||||
$container->set('app.root', $app_root);
|
$container->set('app.root', $app_root);
|
||||||
$file_system = $this->prophesize('Drupal\Core\File\FileSystemInterface');
|
$file_system = $this->prophesize('Drupal\Core\File\FileSystemInterface');
|
||||||
$file_system->realpath('public://simpletest')->willReturn(sys_get_temp_dir());
|
$file_system->realpath('public://simpletest')->willReturn(sys_get_temp_dir());
|
||||||
|
|
|
@ -14,7 +14,7 @@ class MockFileTransfer {
|
||||||
* A new Drupal\system_test\MockFileTransfer object.
|
* A new Drupal\system_test\MockFileTransfer object.
|
||||||
*/
|
*/
|
||||||
public static function factory() {
|
public static function factory() {
|
||||||
return new MockFileTransfer;
|
return new MockFileTransfer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,7 +14,7 @@ class MockFileTransfer {
|
||||||
* A new Drupal\update_test\MockFileTransfer object.
|
* A new Drupal\update_test\MockFileTransfer object.
|
||||||
*/
|
*/
|
||||||
public static function factory() {
|
public static function factory() {
|
||||||
return new FileTransfer;
|
return new FileTransfer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
<!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.-->
|
<!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.-->
|
||||||
<!-- Drupal sniffs -->
|
<!-- Drupal sniffs -->
|
||||||
|
<rule ref="Drupal.Classes.ClassCreateInstance"/>
|
||||||
<rule ref="Drupal.Classes.UnusedUseStatement"/>
|
<rule ref="Drupal.Classes.UnusedUseStatement"/>
|
||||||
<rule ref="Drupal.CSS.ClassDefinitionNameSpacing"/>
|
<rule ref="Drupal.CSS.ClassDefinitionNameSpacing"/>
|
||||||
<rule ref="Drupal.CSS.ColourDefinition"/>
|
<rule ref="Drupal.CSS.ColourDefinition"/>
|
||||||
|
|
|
@ -435,7 +435,7 @@ class AttributeTest extends UnitTestCase {
|
||||||
* The number of results that are found.
|
* The number of results that are found.
|
||||||
*/
|
*/
|
||||||
protected function getXPathResultCount($query, $html) {
|
protected function getXPathResultCount($query, $html) {
|
||||||
$document = new \DOMDocument;
|
$document = new \DOMDocument();
|
||||||
$document->loadHTML($html);
|
$document->loadHTML($html);
|
||||||
$xpath = new \DOMXPath($document);
|
$xpath = new \DOMXPath($document);
|
||||||
|
|
||||||
|
|
|
@ -519,7 +519,7 @@ class LinkGeneratorTest extends UnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the query.
|
// Execute the query.
|
||||||
$document = new \DOMDocument;
|
$document = new \DOMDocument();
|
||||||
$document->loadHTML($html);
|
$document->loadHTML($html);
|
||||||
$xpath = new \DOMXPath($document);
|
$xpath = new \DOMXPath($document);
|
||||||
|
|
||||||
|
@ -538,7 +538,7 @@ class LinkGeneratorTest extends UnitTestCase {
|
||||||
* The number of results that are found.
|
* The number of results that are found.
|
||||||
*/
|
*/
|
||||||
protected function assertNoXPathResults($query, $html) {
|
protected function assertNoXPathResults($query, $html) {
|
||||||
$document = new \DOMDocument;
|
$document = new \DOMDocument();
|
||||||
$document->loadHTML($html);
|
$document->loadHTML($html);
|
||||||
$xpath = new \DOMXPath($document);
|
$xpath = new \DOMXPath($document);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue