Commit 36e0695d authored by willzyx's avatar willzyx

Coding standard

parent f7147f0d
...@@ -35,7 +35,7 @@ function devel_generate_entity_insert(EntityInterface $entity) { ...@@ -35,7 +35,7 @@ function devel_generate_entity_insert(EntityInterface $entity) {
if ($entity->getEntityTypeId() != 'node' || !isset($entity->devel_generate)) { if ($entity->getEntityTypeId() != 'node' || !isset($entity->devel_generate)) {
return; return;
} }
/** @var \Drupal\node\NodeInterface $entity */ /* @var \Drupal\node\NodeInterface $entity */
$results = $entity->devel_generate; $results = $entity->devel_generate;
if (!empty($results['max_comments'])) { if (!empty($results['max_comments'])) {
......
...@@ -165,10 +165,10 @@ function _drush_plugin_validate($params) { ...@@ -165,10 +165,10 @@ function _drush_plugin_validate($params) {
if (!isset($instance_and_values[$plugin_id])) { if (!isset($instance_and_values[$plugin_id])) {
/** @var DevelGeneratePluginManager $manager */ /* @var DevelGeneratePluginManager $manager */
$manager = \Drupal::service('plugin.manager.develgenerate'); $manager = \Drupal::service('plugin.manager.develgenerate');
/** @var DevelGenerateBaseInterface $instance */ /* @var DevelGenerateBaseInterface $instance */
$instance = $manager->createInstance($plugin_id, array()); $instance = $manager->createInstance($plugin_id, array());
//Plugin instance suit params in order to fit for generateElements //Plugin instance suit params in order to fit for generateElements
...@@ -188,7 +188,7 @@ function drush_devel_generate() { ...@@ -188,7 +188,7 @@ function drush_devel_generate() {
$plugin_id = array_shift($params); $plugin_id = array_shift($params);
$instance_and_values = drupal_static('drush_devel_generate_generate_validate'); $instance_and_values = drupal_static('drush_devel_generate_generate_validate');
/** @var DevelGenerateBaseInterface $instance */ /* @var DevelGenerateBaseInterface $instance */
$instance = $instance_and_values[$plugin_id]['instance']; $instance = $instance_and_values[$plugin_id]['instance'];
$values = $instance_and_values[$plugin_id]['values']; $values = $instance_and_values[$plugin_id]['values'];
$instance->generate($values); $instance->generate($values);
......
...@@ -177,7 +177,7 @@ class DevelGenerateCommands extends DrushCommands { ...@@ -177,7 +177,7 @@ class DevelGenerateCommands extends DrushCommands {
$manager = $this->getManager(); $manager = $this->getManager();
$args = $commandData->input()->getArguments(); $args = $commandData->input()->getArguments();
$commandName = array_shift($args); $commandName = array_shift($args);
/** @var DevelGenerateBaseInterface $instance */ /* @var DevelGenerateBaseInterface $instance */
$instance = $manager->createInstance($commandData->annotationData()->get('pluginId'), array()); $instance = $manager->createInstance($commandData->annotationData()->get('pluginId'), array());
$this->setPluginInstance($instance); $this->setPluginInstance($instance);
$parameters = $instance->validateDrushParams($args, $commandData->input()->getOptions()); $parameters = $instance->validateDrushParams($args, $commandData->input()->getOptions());
......
...@@ -92,7 +92,7 @@ abstract class DevelGenerateBase extends PluginBase implements DevelGenerateBase ...@@ -92,7 +92,7 @@ abstract class DevelGenerateBase extends PluginBase implements DevelGenerateBase
* The entity to be enriched with sample field values. * The entity to be enriched with sample field values.
*/ */
public static function populateFields(EntityInterface $entity) { public static function populateFields(EntityInterface $entity) {
/** @var \Drupal\field\FieldConfigInterface[] $instances */ /* @var \Drupal\field\FieldConfigInterface[] $instances */
$instances = entity_load_multiple_by_properties('field_config', array('entity_type' => $entity->getEntityType()->id(), 'bundle' => $entity->bundle())); $instances = entity_load_multiple_by_properties('field_config', array('entity_type' => $entity->getEntityType()->id(), 'bundle' => $entity->bundle()));
if ($skips = function_exists('drush_get_option') ? drush_get_option('skip-fields', '') : @$_REQUEST['skip-fields']) { if ($skips = function_exists('drush_get_option') ? drush_get_option('skip-fields', '') : @$_REQUEST['skip-fields']) {
......
...@@ -20,4 +20,4 @@ use Drupal\Component\Render\MarkupTrait; ...@@ -20,4 +20,4 @@ use Drupal\Component\Render\MarkupTrait;
final class FilteredMarkup implements MarkupInterface, \Countable { final class FilteredMarkup implements MarkupInterface, \Countable {
use MarkupTrait; use MarkupTrait;
} }
\ No newline at end of file
...@@ -101,7 +101,7 @@ class RouteSubscriber extends RouteSubscriberBase { ...@@ -101,7 +101,7 @@ class RouteSubscriber extends RouteSubscriberBase {
'_title' => 'Devel Render', '_title' => 'Devel Render',
]) ])
->addRequirements([ ->addRequirements([
'_permission' => 'access devel information' '_permission' => 'access devel information',
]) ])
->setOption('_admin_route', TRUE) ->setOption('_admin_route', TRUE)
->setOption('_devel_entity_type_id', $entity_type_id) ->setOption('_devel_entity_type_id', $entity_type_id)
...@@ -132,7 +132,7 @@ class RouteSubscriber extends RouteSubscriberBase { ...@@ -132,7 +132,7 @@ class RouteSubscriber extends RouteSubscriberBase {
'_title' => 'Entity type definition', '_title' => 'Entity type definition',
]) ])
->addRequirements([ ->addRequirements([
'_permission' => 'access devel information' '_permission' => 'access devel information',
]) ])
->setOption('_admin_route', TRUE) ->setOption('_admin_route', TRUE)
->setOption('_devel_entity_type_id', $entity_type_id) ->setOption('_devel_entity_type_id', $entity_type_id)
......
...@@ -181,10 +181,10 @@ class Debug extends \Twig_Extension { ...@@ -181,10 +181,10 @@ class Debug extends \Twig_Extension {
* Filters the Twig context variable. * Filters the Twig context variable.
* *
* @param array $context * @param array $context
* The Twig context. * The Twig context.
* *
* @return array * @return array
* An array Twig context variables. * An array Twig context variables.
*/ */
protected function getContextVariables(array $context) { protected function getContextVariables(array $context) {
$context_variables = []; $context_variables = [];
......
...@@ -69,7 +69,7 @@ class DevelContainerInfoTest extends BrowserTestBase { ...@@ -69,7 +69,7 @@ class DevelContainerInfoTest extends BrowserTestBase {
$this->assertNotNull($table); $this->assertNotNull($table);
// Ensures that the expected table headers are found. // Ensures that the expected table headers are found.
/** @var $headers \Behat\Mink\Element\NodeElement[] */ /* @var $headers \Behat\Mink\Element\NodeElement[] */
$headers = $table->findAll('css', 'thead th'); $headers = $table->findAll('css', 'thead th');
$this->assertEquals(4, count($headers)); $this->assertEquals(4, count($headers));
...@@ -105,7 +105,7 @@ class DevelContainerInfoTest extends BrowserTestBase { ...@@ -105,7 +105,7 @@ class DevelContainerInfoTest extends BrowserTestBase {
$row = $table->find('css', sprintf('tbody tr:contains("%s")', $service_id)); $row = $table->find('css', sprintf('tbody tr:contains("%s")', $service_id));
$this->assertNotNull($row); $this->assertNotNull($row);
/** @var $cells \Behat\Mink\Element\NodeElement[] */ /* @var $cells \Behat\Mink\Element\NodeElement[] */
$cells = $row->findAll('css', 'td'); $cells = $row->findAll('css', 'td');
$this->assertEquals(4, count($cells)); $this->assertEquals(4, count($cells));
...@@ -174,7 +174,7 @@ class DevelContainerInfoTest extends BrowserTestBase { ...@@ -174,7 +174,7 @@ class DevelContainerInfoTest extends BrowserTestBase {
$this->assertNotNull($table); $this->assertNotNull($table);
// Ensures that the expected table headers are found. // Ensures that the expected table headers are found.
/** @var $headers \Behat\Mink\Element\NodeElement[] */ /* @var $headers \Behat\Mink\Element\NodeElement[] */
$headers = $table->findAll('css', 'thead th'); $headers = $table->findAll('css', 'thead th');
$this->assertEquals(2, count($headers)); $this->assertEquals(2, count($headers));
...@@ -202,7 +202,7 @@ class DevelContainerInfoTest extends BrowserTestBase { ...@@ -202,7 +202,7 @@ class DevelContainerInfoTest extends BrowserTestBase {
$row = $table->find('css', sprintf('tbody tr:contains("%s")', $parameter_name)); $row = $table->find('css', sprintf('tbody tr:contains("%s")', $parameter_name));
$this->assertNotNull($row); $this->assertNotNull($row);
/** @var $cells \Behat\Mink\Element\NodeElement[] */ /* @var $cells \Behat\Mink\Element\NodeElement[] */
$cells = $row->findAll('css', 'td'); $cells = $row->findAll('css', 'td');
$this->assertEquals(2, count($cells)); $this->assertEquals(2, count($cells));
......
...@@ -96,7 +96,7 @@ class DevelElementInfoTest extends BrowserTestBase { ...@@ -96,7 +96,7 @@ class DevelElementInfoTest extends BrowserTestBase {
$row = $table->find('css', sprintf('tbody tr:contains("%s")', $element_name)); $row = $table->find('css', sprintf('tbody tr:contains("%s")', $element_name));
$this->assertNotNull($row); $this->assertNotNull($row);
/** @var $cells \Behat\Mink\Element\NodeElement[] */ /* @var $cells \Behat\Mink\Element\NodeElement[] */
$cells = $row->findAll('css', 'td'); $cells = $row->findAll('css', 'td');
$this->assertEquals(4, count($cells)); $this->assertEquals(4, count($cells));
......
...@@ -43,8 +43,8 @@ class DevelEntityTypeInfoTest extends BrowserTestBase { ...@@ -43,8 +43,8 @@ class DevelEntityTypeInfoTest extends BrowserTestBase {
*/ */
public function testEntityInfoMenuLink() { public function testEntityInfoMenuLink() {
$this->drupalPlaceBlock('system_menu_block:devel'); $this->drupalPlaceBlock('system_menu_block:devel');
// Ensures that the entity type info link is present on the devel menu and that // Ensures that the entity type info link is present on the devel menu and
// it points to the correct page. // that it points to the correct page.
$this->drupalGet(''); $this->drupalGet('');
$this->clickLink('Entity Info'); $this->clickLink('Entity Info');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
...@@ -76,7 +76,8 @@ class DevelEntityTypeInfoTest extends BrowserTestBase { ...@@ -76,7 +76,8 @@ class DevelEntityTypeInfoTest extends BrowserTestBase {
}, $headers); }, $headers);
$this->assertSame($expected_headers, $actual_headers); $this->assertSame($expected_headers, $actual_headers);
// Tests the presence of some (arbitrarily chosen) entity types in the table. // Tests the presence of some (arbitrarily chosen) entity types in the
// table.
$expected_types = [ $expected_types = [
'date_format' => [ 'date_format' => [
'name' => 'Date format', 'name' => 'Date format',
...@@ -99,7 +100,7 @@ class DevelEntityTypeInfoTest extends BrowserTestBase { ...@@ -99,7 +100,7 @@ class DevelEntityTypeInfoTest extends BrowserTestBase {
$row = $table->find('css', sprintf('tbody tr:contains("%s")', $entity_type_id)); $row = $table->find('css', sprintf('tbody tr:contains("%s")', $entity_type_id));
$this->assertNotNull($row); $this->assertNotNull($row);
/** @var $cells \Behat\Mink\Element\NodeElement[] */ /* @var $cells \Behat\Mink\Element\NodeElement[] */
$cells = $row->findAll('css', 'td'); $cells = $row->findAll('css', 'td');
$this->assertEquals(5, count($cells)); $this->assertEquals(5, count($cells));
......
...@@ -67,7 +67,7 @@ class DevelEventInfoTest extends BrowserTestBase { ...@@ -67,7 +67,7 @@ class DevelEventInfoTest extends BrowserTestBase {
$this->assertNotNull($table); $this->assertNotNull($table);
// Ensures that the expected table headers are found. // Ensures that the expected table headers are found.
/** @var $headers \Behat\Mink\Element\NodeElement[] */ /* @var $headers \Behat\Mink\Element\NodeElement[] */
$headers = $table->findAll('css', 'thead th'); $headers = $table->findAll('css', 'thead th');
$this->assertEquals(3, count($headers)); $this->assertEquals(3, count($headers));
...@@ -100,14 +100,14 @@ class DevelEventInfoTest extends BrowserTestBase { ...@@ -100,14 +100,14 @@ class DevelEventInfoTest extends BrowserTestBase {
$this->assertEquals(1, count($event_header_row)); $this->assertEquals(1, count($event_header_row));
// Ensures that all the event listener are listed in the table. // Ensures that all the event listener are listed in the table.
/** @var $event_rows \Behat\Mink\Element\NodeElement[] */ /* @var $event_rows \Behat\Mink\Element\NodeElement[] */
$event_rows = $table->findAll('css', sprintf('tbody tr:contains("%s")', $event_name)); $event_rows = $table->findAll('css', sprintf('tbody tr:contains("%s")', $event_name));
// Remove the header row. // Remove the header row.
array_shift($event_rows); array_shift($event_rows);
$this->assertEquals(count($listeners), count($event_rows)); $this->assertEquals(count($listeners), count($event_rows));
foreach ($listeners as $index => $listener) { foreach ($listeners as $index => $listener) {
/** @var $cells \Behat\Mink\Element\NodeElement[] */ /* @var $cells \Behat\Mink\Element\NodeElement[] */
$cells = $event_rows[$index]->findAll('css', 'td'); $cells = $event_rows[$index]->findAll('css', 'td');
$this->assertEquals(3, count($cells)); $this->assertEquals(3, count($cells));
......
...@@ -70,7 +70,7 @@ class DevelLayoutInfoTest extends BrowserTestBase { ...@@ -70,7 +70,7 @@ class DevelLayoutInfoTest extends BrowserTestBase {
$this->assertNotNull($table); $this->assertNotNull($table);
// Ensures that the expected table headers are found. // Ensures that the expected table headers are found.
/** @var $headers \Behat\Mink\Element\NodeElement[] */ /* @var $headers \Behat\Mink\Element\NodeElement[] */
$headers = $table->findAll('css', 'thead th'); $headers = $table->findAll('css', 'thead th');
$this->assertEquals(6, count($headers)); $this->assertEquals(6, count($headers));
......
...@@ -52,7 +52,7 @@ class DevelRouteInfoTest extends BrowserTestBase { ...@@ -52,7 +52,7 @@ class DevelRouteInfoTest extends BrowserTestBase {
$page = $this->getSession()->getPage(); $page = $this->getSession()->getPage();
// Ensures that the expected table headers are found. // Ensures that the expected table headers are found.
/** @var $headers \Behat\Mink\Element\NodeElement[] */ /* @var $headers \Behat\Mink\Element\NodeElement[] */
$headers = $page->findAll('css', 'table.devel-route-list thead th'); $headers = $page->findAll('css', 'table.devel-route-list thead th');
$this->assertEquals(4, count($headers)); $this->assertEquals(4, count($headers));
...@@ -94,7 +94,7 @@ class DevelRouteInfoTest extends BrowserTestBase { ...@@ -94,7 +94,7 @@ class DevelRouteInfoTest extends BrowserTestBase {
$row = $page->find('css', sprintf('table.devel-route-list tbody tr:contains("%s")', $route_name)); $row = $page->find('css', sprintf('table.devel-route-list tbody tr:contains("%s")', $route_name));
$this->assertNotNull($row); $this->assertNotNull($row);
/** @var $cells \Behat\Mink\Element\NodeElement[] */ /* @var $cells \Behat\Mink\Element\NodeElement[] */
$cells = $row->findAll('css', 'td'); $cells = $row->findAll('css', 'td');
$this->assertEquals(4, count($cells)); $this->assertEquals(4, count($cells));
......
...@@ -36,7 +36,7 @@ class DevelEnforcedDependenciesTest extends KernelTestBase { ...@@ -36,7 +36,7 @@ class DevelEnforcedDependenciesTest extends KernelTestBase {
* Tests devel menu enforced dependencies. * Tests devel menu enforced dependencies.
*/ */
public function testMenuEnforcedDependencies() { public function testMenuEnforcedDependencies() {
/** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */ /* @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
$config_manager = $this->container->get('config.manager'); $config_manager = $this->container->get('config.manager');
// Ensure that the Devel menu has explicit enforced dependencies on devel // Ensure that the Devel menu has explicit enforced dependencies on devel
......
...@@ -78,7 +78,7 @@ class DevelTwigExtensionTest extends KernelTestBase { ...@@ -78,7 +78,7 @@ class DevelTwigExtensionTest extends KernelTestBase {
* Tests that the Twig dump functions are registered properly. * Tests that the Twig dump functions are registered properly.
*/ */
public function testDumpFunctionsRegistered() { public function testDumpFunctionsRegistered() {
/** @var \Twig_SimpleFunction[] $functions */ /* @var \Twig_SimpleFunction[] $functions */
$functions = \Drupal::service('twig')->getFunctions(); $functions = \Drupal::service('twig')->getFunctions();
$dump_functions = ['devel_dump', 'kpr']; $dump_functions = ['devel_dump', 'kpr'];
...@@ -107,7 +107,7 @@ class DevelTwigExtensionTest extends KernelTestBase { ...@@ -107,7 +107,7 @@ class DevelTwigExtensionTest extends KernelTestBase {
* Tests that the Twig function for XDebug integration is registered properly. * Tests that the Twig function for XDebug integration is registered properly.
*/ */
public function testXDebugIntegrationFunctionsRegistered() { public function testXDebugIntegrationFunctionsRegistered() {
/** @var \Twig_SimpleFunction $function */ /* @var \Twig_SimpleFunction $function */
$function = \Drupal::service('twig')->getFunction('devel_breakpoint'); $function = \Drupal::service('twig')->getFunction('devel_breakpoint');
$this->assertTrue($function instanceof \Twig_SimpleFunction); $this->assertTrue($function instanceof \Twig_SimpleFunction);
$this->assertEquals($function->getName(), 'devel_breakpoint'); $this->assertEquals($function->getName(), 'devel_breakpoint');
...@@ -134,7 +134,7 @@ class DevelTwigExtensionTest extends KernelTestBase { ...@@ -134,7 +134,7 @@ class DevelTwigExtensionTest extends KernelTestBase {
'twig_object' => new \stdClass(), 'twig_object' => new \stdClass(),
]; ];
/** @var \Drupal\Core\Template\TwigEnvironment $environment */ /* @var \Drupal\Core\Template\TwigEnvironment $environment */
$environment = \Drupal::service('twig'); $environment = \Drupal::service('twig');
// Ensures that the twig extension does nothing if the current // Ensures that the twig extension does nothing if the current
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment