Commit 942c1cff authored by alexpott's avatar alexpott

Issue #2572307 by vprocessor, attiks, andriyun, alexpott, pfrenssen: Fix...

Issue #2572307 by vprocessor, attiks, andriyun, alexpott, pfrenssen: Fix 'Generic.PHP.UpperCaseConstant' coding standard
parent 0fcef5bd
<?php
// @codingStandardsIgnoreFile
namespace Drupal\Core\DependencyInjection;
......
<?php
// @codingStandardsIgnoreFile
namespace Drupal\Core\DependencyInjection;
......
......@@ -121,7 +121,7 @@ public function getHandler($entity_type, $handler_type) {
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
*/
public function createHandlerInstance($class, EntityTypeInterface $definition = null) {
public function createHandlerInstance($class, EntityTypeInterface $definition = NULL) {
return $this->container->get('entity_type.manager')->createHandlerInstance($class, $definition);
}
......
......@@ -57,7 +57,7 @@ public function __construct($host) {
* @return \Symfony\Component\HttpFoundation\Request
* A new request object.
**/
public function createRequest(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) {
public function createRequest(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = NULL) {
if (empty($server['HTTP_HOST']) || ($server['HTTP_HOST'] === 'localhost' && $this->host !== 'localhost')) {
$server['HTTP_HOST'] = $this->host;
}
......
......@@ -61,7 +61,7 @@ class CompiledRoute extends SymfonyCompiledRoute {
* @param array $variables
* An array of variables (variables defined in the path and in the host patterns)
*/
public function __construct($fit, $pattern_outline, $num_parts, $staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array()) {
public function __construct($fit, $pattern_outline, $num_parts, $staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = NULL, array $hostTokens = array(), array $hostVariables = array(), array $variables = array()) {
parent::__construct($staticPrefix, $regex, $tokens, $pathVariables, $hostRegex, $hostTokens, $hostVariables, $variables);
$this->fit = $fit;
......
......@@ -39,7 +39,7 @@ public function __construct(HttpKernelInterface $app) {
/**
* {@inheritdoc}
*/
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) {
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
// Register available mime types.
foreach ($this->formats as $format => $mime_type) {
$request->setFormat($format, $mime_type);
......
......@@ -52,7 +52,7 @@ public function getCacheKey($name) {
* {@inheritdoc}
*/
public function isFresh($name, $time) {
return true;
return TRUE;
}
}
......@@ -150,12 +150,12 @@ public function getFilters() {
new \Twig_SimpleFilter('placeholder', [$this, 'escapePlaceholder'], array('is_safe' => array('html'), 'needs_environment' => TRUE)),
// Replace twig's escape filter with our own.
new \Twig_SimpleFilter('drupal_escape', [$this, 'escapeFilter'], array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
new \Twig_SimpleFilter('drupal_escape', [$this, 'escapeFilter'], array('needs_environment' => TRUE, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
// Implements safe joining.
// @todo Make that the default for |join? Upstream issue:
// https://github.com/fabpot/Twig/issues/1420
new \Twig_SimpleFilter('safe_join', [$this, 'safeJoin'], ['needs_environment' => true, 'is_safe' => ['html']]),
new \Twig_SimpleFilter('safe_join', [$this, 'safeJoin'], ['needs_environment' => TRUE, 'is_safe' => ['html']]),
// Array filters.
new \Twig_SimpleFilter('without', 'twig_without'),
......@@ -547,7 +547,7 @@ public function renderVar($arg) {
*/
public function safeJoin(\Twig_Environment $env, $value, $glue = '') {
if ($value instanceof \Traversable) {
$value = iterator_to_array($value, false);
$value = iterator_to_array($value, FALSE);
}
return implode($glue, array_map(function($item) use ($env) {
......
......@@ -85,7 +85,7 @@ public function hasMetadataFor($value) {
/**
* {@inheritdoc}
*/
public function validate($value, $constraints = null, $groups = null) {
public function validate($value, $constraints = NULL, $groups = NULL) {
return $this->startContext($value)
->validate($value, $constraints, $groups)
->getViolations();
......
......@@ -63,7 +63,7 @@ public function query() {
*/
protected function initializeIterator() {
$this->defaultTheme = $this->variableGet('theme_default', 'Garland');
$this->adminTheme = $this->variableGet('admin_theme', null);
$this->adminTheme = $this->variableGet('admin_theme', NULL);
return parent::initializeIterator();
}
......
......@@ -107,7 +107,7 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) {
// Set additional flag on the button if it can occur multiple times.
if (!empty($button['multiple'])) {
$button_item['multiple'] = true;
$button_item['multiple'] = TRUE;
}
return $button_item;
......
......@@ -32,7 +32,7 @@ protected function setUp() {
*/
public function testContactSettings() {
$config = $this->config('contact.settings');
$this->assertIdentical(true, $config->get('user_default_enabled'));
$this->assertIdentical(TRUE, $config->get('user_default_enabled'));
$this->assertIdentical(3, $config->get('flood.limit'));
$this->assertIdentical('some_other_category', $config->get('default_form'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'contact.settings', $config->get());
......
......@@ -109,9 +109,9 @@ protected function setUp() {
),
'settings' =>
array (
'display_summary' => true,
'display_summary' => TRUE,
'text_processing' => 1,
'user_register_form' => false,
'user_register_form' => FALSE,
),
'display' =>
array (
......@@ -136,7 +136,7 @@ protected function setUp() {
'weight' => 0,
),
),
'required' => false,
'required' => FALSE,
'description' => '',
)),
))
......
......@@ -67,7 +67,7 @@ public function testNormalize() {
array(
'href' => '/relations',
'name' => 'site',
'templated' => true,
'templated' => TRUE,
),
),
'self' => array(
......
......@@ -33,8 +33,8 @@ protected function setUp() {
*/
public function testImageStylesMigration() {
$this->assertEntity('custom_image_style_1', "Custom image style 1", ['image_scale_and_crop', 'image_desaturate'], [['width' => 55, 'height' => 55], []]);
$this->assertEntity('custom_image_style_2', "Custom image style 2", ['image_resize', 'image_rotate'], [['width' => 55, 'height' => 100], ['degrees' => 45, 'bgcolor' => '#FFFFFF', 'random' => false]]);
$this->assertEntity('custom_image_style_3', "Custom image style 3", ['image_scale', 'image_crop'], [['width' => 150, 'height' => NULL, 'upscale' => false], ['width' => 50, 'height' => 50, 'anchor' => 'left-top']]);
$this->assertEntity('custom_image_style_2', "Custom image style 2", ['image_resize', 'image_rotate'], [['width' => 55, 'height' => 100], ['degrees' => 45, 'bgcolor' => '#FFFFFF', 'random' => FALSE]]);
$this->assertEntity('custom_image_style_3', "Custom image style 3", ['image_scale', 'image_crop'], [['width' => 150, 'height' => NULL, 'upscale' => FALSE], ['width' => 50, 'height' => 50, 'anchor' => 'left-top']]);
}
/**
......
......@@ -178,13 +178,13 @@ public function providerLanguageAlterable() {
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_bundle',
), 'language_content_settings');
$alterableConfig->setLanguageAlterable(true);
$alterableConfig->setLanguageAlterable(TRUE);
$nonAlterableConfig = new ContentLanguageSettings(array(
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_fixed_language_bundle',
), 'language_content_settings');
$nonAlterableConfig->setLanguageAlterable(false);
$nonAlterableConfig->setLanguageAlterable(FALSE);
$defaultConfig = new ContentLanguageSettings(array(
'target_entity_type_id' => 'test_entity_type',
......@@ -192,9 +192,9 @@ public function providerLanguageAlterable() {
), 'language_content_settings');
return [
[$alterableConfig, true],
[$nonAlterableConfig, false],
[$defaultConfig, false],
[$alterableConfig, TRUE],
[$nonAlterableConfig, FALSE],
[$defaultConfig, FALSE],
];
}
......@@ -212,7 +212,7 @@ public function providerIsDefaultConfiguration() {
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_bundle',
), 'language_content_settings');
$alteredLanguage->setLanguageAlterable(true);
$alteredLanguage->setLanguageAlterable(TRUE);
$alteredDefaultLangcode = new ContentLanguageSettings(array(
'target_entity_type_id' => 'test_entity_type',
......@@ -226,9 +226,9 @@ public function providerIsDefaultConfiguration() {
), 'language_content_settings');
return [
[$alteredLanguage, false],
[$alteredDefaultLangcode, false],
[$defaultConfig, true],
[$alteredLanguage, FALSE],
[$alteredDefaultLangcode, FALSE],
[$defaultConfig, TRUE],
];
}
......@@ -275,7 +275,7 @@ public function providerLoadByEntityTypeBundle() {
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_bundle',
), 'language_content_settings');
$alteredLanguage->setLanguageAlterable(true);
$alteredLanguage->setLanguageAlterable(TRUE);
$langcode = $this->randomMachineName();
$alteredDefaultLangcode = new ContentLanguageSettings(array(
......@@ -290,10 +290,10 @@ public function providerLoadByEntityTypeBundle() {
), 'language_content_settings');
return [
['test_entity_type.test_bundle', $alteredLanguage, LanguageInterface::LANGCODE_SITE_DEFAULT, true],
['test_entity_type.test_fixed_language_bundle', $alteredDefaultLangcode, $langcode, false],
['test_entity_type.test_default_language_bundle', $defaultConfig, LanguageInterface::LANGCODE_SITE_DEFAULT, false],
['test_entity_type.null_bundle', NULL, LanguageInterface::LANGCODE_SITE_DEFAULT, false],
['test_entity_type.test_bundle', $alteredLanguage, LanguageInterface::LANGCODE_SITE_DEFAULT, TRUE],
['test_entity_type.test_fixed_language_bundle', $alteredDefaultLangcode, $langcode, FALSE],
['test_entity_type.test_default_language_bundle', $defaultConfig, LanguageInterface::LANGCODE_SITE_DEFAULT, FALSE],
['test_entity_type.null_bundle', NULL, LanguageInterface::LANGCODE_SITE_DEFAULT, FALSE],
];
}
......
......@@ -649,7 +649,7 @@ function addInvalidMenuLink() {
* Tests that parent options are limited by depth when adding menu links.
*/
function checkInvalidParentMenuLinks() {
$last_link = null;
$last_link = NULL;
$created_links = array();
// Get the max depth of the tree.
......
......@@ -1172,7 +1172,7 @@ function node_access_rebuild($batch_mode = FALSE) {
// user does not have access. And unless the current user has the bypass
// node access permission, no nodes are accessible since the grants have
// just been deleted.
$entity_query->accessCheck(false);
$entity_query->accessCheck(FALSE);
$nids = $entity_query->execute();
foreach ($nids as $nid) {
$node_storage->resetCache(array($nid));
......@@ -1227,7 +1227,7 @@ function _node_access_rebuild_batch_operation(&$context) {
// user does not have access. And unless the current user has the bypass
// node access permission, no nodes are accessible since the grants have
// just been deleted.
->accessCheck(false)
->accessCheck(FALSE)
->range(0, $limit)
->execute();
$node_storage->resetCache($nids);
......
......@@ -89,7 +89,7 @@ public function tearDownCacheBackend() {
* @return \Drupal\Core\Cache\CacheBackendInterface
* Cache backend to test.
*/
protected function getCacheBackend($bin = null) {
protected function getCacheBackend($bin = NULL) {
if (!isset($bin)) {
$bin = $this->getTestBin();
}
......
......@@ -29,7 +29,7 @@ protected function setup() {
parent::setUp();
$this->fileTranslation = new FileTranslation('filename');
$method = new \ReflectionMethod('\Drupal\Core\StringTranslation\Translator\FileTranslation', 'getTranslationFilesPattern');
$method->setAccessible(true);
$method->setAccessible(TRUE);
$this->filePatternMethod = $method;
}
......
......@@ -51,7 +51,7 @@ public function testUserProfileEntityFormDisplay() {
// Test that a checkbox field has the proper display label setting.
$component = $display->getComponent('profile_love_migrations');
$this->assertIdentical('boolean_checkbox', $component['type']);
$this->assertIdentical(true, $component['settings']['display_label']);
$this->assertIdentical(TRUE, $component['settings']['display_label']);
}
}
......@@ -59,13 +59,13 @@ public function testTranslationRows() {
$node = Node::create([
'type' => 'article',
'title' => 'example EN',
'sticky' => false,
'sticky' => FALSE,
]);
$node->save();
$translation = $node->addTranslation('es');
$translation->title->value = 'example ES';
$translation->sticky->value = true;
$translation->sticky->value = TRUE;
$translation->save();
$this->drupalGet('test_entity_field_renderers/entity_translation');
......
......@@ -422,7 +422,7 @@ public function testValidate() {
$count = 0;
foreach ($view->displayHandlers as $id => $display) {
$match = function($value) use ($display) {
return strpos($value, $display->display['display_title']) !== false;
return strpos($value, $display->display['display_title']) !== FALSE;
};
$this->assertTrue(array_filter($validate[$id], $match), format_string('Error message found for @id display', array('@id' => $id)));
$count++;
......
......@@ -53,7 +53,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$form = array(
'options' => array(
'#tree' => true,
'#tree' => TRUE,
'#theme_wrappers' => array('container'),
'#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE),
),
......
......@@ -54,7 +54,7 @@ public function testFieldUI() {
$this->assertEqual((string) $result[2], '{{ name }} == Name');
$result = $this->xpath('//details[@id="edit-options-more"]');
$this->assertEqual(empty($result), true, "Container 'more' is empty and should not be displayed.");
$this->assertEqual(empty($result), TRUE, "Container 'more' is empty and should not be displayed.");
}
/**
......
......@@ -46,6 +46,7 @@
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.UpperCaseConstant"/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
</ruleset>
......@@ -1208,7 +1208,7 @@ public function __sleep() {
/**
* {@inheritdoc}
*/
public static function assertEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) {
public static function assertEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) {
$expected = static::castSafeStrings($expected);
$actual = static::castSafeStrings($actual);
parent::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase);
......
......@@ -113,11 +113,11 @@ public function testAssertNoCoreUseage($expected_pass, $file_data) {
$file_uri = vfsStream::url('root/Test.php');
try {
$pass = true;
$pass = TRUE;
$this->assertNoCoreUsage($file_uri);
}
catch (\PHPUnit_Framework_AssertionFailedError $e) {
$pass = false;
$pass = FALSE;
}
$this->assertEquals($expected_pass, $pass, $expected_pass ?
'Test caused a false positive' :
......
......@@ -37,12 +37,12 @@ public function testTrustedHosts($host, $server_name, $message, $expected = FALS
$method = new \ReflectionMethod('Drupal\Core\DrupalKernel', 'setupTrustedHosts');
$method->setAccessible(TRUE);
$valid_host = $method->invoke(null, $request, $trusted_host_patterns);
$valid_host = $method->invoke(NULL, $request, $trusted_host_patterns);
$this->assertSame($expected, $valid_host, $message);
// Reset the trusted hosts because it is statically stored on the request.
$method->invoke(null, $request, []);
$method->invoke(NULL, $request, []);
// Reset the request factory because it is statically stored on the request.
Request::setFactory(NULL);
}
......
......@@ -545,7 +545,7 @@ public function testGetSchemaTranslatable() {
'default_langcode' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => true,
'not null' => TRUE,
),
),
'primary key' => array('id', 'langcode'),
......@@ -712,7 +712,7 @@ public function testGetSchemaRevisionableTranslatable() {
'default_langcode' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => true,
'not null' => TRUE,
),
),
'primary key' => array('id', 'langcode'),
......@@ -750,7 +750,7 @@ public function testGetSchemaRevisionableTranslatable() {
'default_langcode' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => true,
'not null' => TRUE,
),
),
'primary key' => array('revision_id', 'langcode'),
......@@ -859,51 +859,51 @@ public function testDedicatedTableSchema() {
'bundle' => array(
'type' => 'varchar_ascii',
'length' => 128,
'not null' => true,
'not null' => TRUE,
'default' => '',
'description' => 'The field instance bundle to which this row belongs, used when deleting a field instance',
),
'deleted' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => true,
'not null' => TRUE,
'default' => 0,
'description' => 'A boolean indicating whether this data item has been deleted',
),
'entity_id' => array(
'type' => 'int',
'unsigned' => true,
'not null' => true,
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The entity id this data is attached to',
),
'revision_id' => array(
'type' => 'int',
'unsigned' => true,
'not null' => true,
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The entity revision id this data is attached to, which for an unversioned entity type is the same as the entity id',
),
'langcode' => array(
'type' => 'varchar_ascii',
'length' => 32,
'not null' => true,
'not null' => TRUE,
'default' => '',
'description' => 'The language code for this data item.',
),
'delta' => array(
'type' => 'int',
'unsigned' => true,
'not null' => true,
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The sequence number for this data item, used for multi-value fields',
),
$field_name . '_shape' => array(
'type' => 'varchar',
'length' => 32,
'not null' => false,
'not null' => FALSE,
),
$field_name . '_color' => array(
'type' => 'varchar',
'length' => 32,
'not null' => false,
'not null' => FALSE,
),
),
'primary key' => array('entity_id', 'deleted', 'delta', 'langcode'),
......@@ -1004,51 +1004,51 @@ public function testDedicatedTableSchemaForEntityWithStringIdentifier() {
'bundle' => array(
'type' => 'varchar_ascii',
'length' => 128,
'not null' => true,
'not null' => TRUE,
'default' => '',
'description' => 'The field instance bundle to which this row belongs, used when deleting a field instance',
),
'deleted' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => true,
'not null' => TRUE,
'default' => 0,
'description' => 'A boolean indicating whether this data item has been deleted',
),
'entity_id' => array(
'type' => 'varchar_ascii',
'length' => 128,
'not null' => true,
'not null' => TRUE,
'description' => 'The entity id this data is attached to',
),
'revision_id' => array(
'type' => 'varchar_ascii',
'length' => 128,
'not null' => true,
'not null' => TRUE,
'description' => 'The entity revision id this data is attached to, which for an unversioned entity type is the same as the entity id',
),
'langcode' => array(
'type' => 'varchar_ascii',
'length' => 32,
'not null' => true,
'not null' => TRUE,
'default' => '',
'description' => 'The language code for this data item.',
),
'delta' => array(
'type' => 'int',
'unsigned' => true,
'not null' => true,
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The sequence number for this data item, used for multi-value fields',
),
$field_name . '_shape' => array(
'type' => 'varchar',
'length' => 32,
'not null' => false,
'not null' => FALSE,
),
$field_name . '_color' => array(
'type' => 'varchar',
'length' => 32,
'not null' => false,
'not null' => FALSE,
),
),
'primary key' => array('entity_id', 'deleted', 'delta', 'langcode'),
......
......@@ -238,7 +238,7 @@ public function testModuleExists() {
* @covers ::loadAllIncludes
*/
public function testLoadAllIncludes() {
$this->assertTrue(true);
$this->assertTrue(TRUE);
$module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler')
->setConstructorArgs(array(
$this->root,
......
......@@ -738,7 +738,7 @@ public function providerTestChildAccessInheritance() {
*/
public function testValueCallableIsSafe($callback, $expected) {
$method = new \ReflectionMethod(FormBuilder::class, 'valueCallableIsSafe');
$method->setAccessible(true);
$method->setAccessible(TRUE);
$is_safe = $method->invoke($this->formBuilder, $callback);
$this->assertSame($expected, $is_safe);
}
......
......@@ -203,7 +203,7 @@ public function providerTestHandleErrorsWithLimitedValidation() {
array(
array(array('test1')),
array(
'#is_button' => true,
'#is_button' => TRUE,
'#value' => 'baz',
'#name' => 'op',
'#parents' => array('submit'),
......
......@@ -101,7 +101,7 @@ public function testHandle() {
$request->setRequestFormat('html')->shouldBeCalled();
// Some getContentType calls we don't really care about but have to mock.
$request->get('ajax_iframe_upload', false)->shouldBeCalled();
$request->get('ajax_iframe_upload', FALSE)->shouldBeCalled();
$request_mock = $request->reveal();
$request_mock->query = new ParameterBag([]);
......@@ -126,7 +126,7 @@ public function testSetFormat() {
// Some calls we don't care about.
$request->setRequestFormat('html')->shouldBeCalled();
$request->get('ajax_iframe_upload', false)->shouldBeCalled();
$request->get('ajax_iframe_upload', FALSE)->shouldBeCalled();
$request_mock = $request->reveal();
$request_mock->query = new ParameterBag([]);
......
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