Skip to content
Snippets Groups Projects
Verified Commit 59f14c20 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3259109 by mondrake, longwave, andregp, daffie, mglaman, neclimdul,...

Issue #3259109 by mondrake, longwave, andregp, daffie, mglaman, neclimdul, alexpott: Fix 'Cannot unset offset' PHPStan L0 errors

(cherry picked from commit 0bab40ee)
parent f17bf6c5
No related branches found
No related tags found
7 merge requests!4488Issue #3376281: Random machine names no longer need to be wrapped in strtolower(),!3000Issue #793660: Check for failure of hook_install,!2940Issue #3320240: Entity count query returns a string instead of int,!2937Issue #3315245: Order of languages overrides default language fallback,!1627Issue #3082958: Add gitignore(s) to composer-ready project templates,!1014Issue #3226806: Move filter implementations from filter.module to plugin classes,!939Issue #2971209: Allow the MediaLibraryUiBuilder service to use an alternative view display
...@@ -396,7 +396,6 @@ public function providerGetUpgradeStates() { ...@@ -396,7 +396,6 @@ public function providerGetUpgradeStates() {
// Test menu migration with menu_ui uninstalled. // Test menu migration with menu_ui uninstalled.
$tests[3] = $tests[1]; $tests[3] = $tests[1];
unset($tests[3]['modules_to_enable']['menu_ui']); unset($tests[3]['modules_to_enable']['menu_ui']);
unset($tests[3]['files']['menu_ui']);
unset($tests[3]['migrations']['menu_ui']); unset($tests[3]['migrations']['menu_ui']);
$tests[3]['expected_7'] = [ $tests[3]['expected_7'] = [
MigrationState::NOT_FINISHED => [ MigrationState::NOT_FINISHED => [
......
...@@ -439,7 +439,6 @@ public function defaultableSections($section = NULL) { ...@@ -439,7 +439,6 @@ public function defaultableSections($section = NULL) {
// If the display cannot use a pager, then we cannot default it. // If the display cannot use a pager, then we cannot default it.
if (!$this->usesPager()) { if (!$this->usesPager()) {
unset($sections['pager']); unset($sections['pager']);
unset($sections['items_per_page']);
} }
foreach ($this->extenders as $extender) { foreach ($this->extenders as $extender) {
......
...@@ -57,11 +57,11 @@ public function testReadOnly() { ...@@ -57,11 +57,11 @@ public function testReadOnly() {
// Find a global that doesn't exist. // Find a global that doesn't exist.
do { do {
$random = mt_rand(10000, 100000); $random = 'test' . mt_rand(10000, 100000);
} while (isset($GLOBALS[$random])); } while (isset($GLOBALS[$random]));
// Write out a PHP file and ensure it's successfully loaded. // Write out a PHP file and ensure it's successfully loaded.
$code = "<?php\n\$GLOBALS[$random] = TRUE;"; $code = "<?php\n\$GLOBALS['$random'] = TRUE;";
$success = $php->save($name, $code); $success = $php->save($name, $code);
$this->assertTrue($success); $this->assertTrue($success);
$php_read = new FileReadOnlyStorage($this->readonlyStorage); $php_read = new FileReadOnlyStorage($this->readonlyStorage);
......
...@@ -70,11 +70,11 @@ public function testDeleteAll() { ...@@ -70,11 +70,11 @@ public function testDeleteAll() {
// Find a global that doesn't exist. // Find a global that doesn't exist.
do { do {
$random = mt_rand(10000, 100000); $random = 'test' . mt_rand(10000, 100000);
} while (isset($GLOBALS[$random])); } while (isset($GLOBALS[$random]));
// Write out a PHP file and ensure it's successfully loaded. // Write out a PHP file and ensure it's successfully loaded.
$code = "<?php\n\$GLOBALS[$random] = TRUE;"; $code = "<?php\n\$GLOBALS['$random'] = TRUE;";
$this->assertTrue($php->save($name, $code), 'Saved php file'); $this->assertTrue($php->save($name, $code), 'Saved php file');
$php->load($name); $php->load($name);
$this->assertTrue($GLOBALS[$random], 'File saved correctly with correct value'); $this->assertTrue($GLOBALS[$random], 'File saved correctly with correct value');
......
...@@ -39,11 +39,11 @@ public function assertCRUD($php) { ...@@ -39,11 +39,11 @@ public function assertCRUD($php) {
// Find a global that doesn't exist. // Find a global that doesn't exist.
do { do {
$random = mt_rand(10000, 100000); $random = 'test' . mt_rand(10000, 100000);
} while (isset($GLOBALS[$random])); } while (isset($GLOBALS[$random]));
// Write out a PHP file and ensure it's successfully loaded. // Write out a PHP file and ensure it's successfully loaded.
$code = "<?php\n\$GLOBALS[$random] = TRUE;"; $code = "<?php\n\$GLOBALS['$random'] = TRUE;";
$success = $php->save($name, $code); $success = $php->save($name, $code);
$this->assertTrue($success, 'Saved php file'); $this->assertTrue($success, 'Saved php file');
$php->load($name); $php->load($name);
......
...@@ -160,13 +160,11 @@ public function providerTestSetLinkActiveClass() { ...@@ -160,13 +160,11 @@ public function providerTestSetLinkActiveClass() {
// Matching path, plus all matching variations. // Matching path, plus all matching variations.
$attributes = [ $attributes = [
'data-drupal-link-system-path' => 'llama', 'data-drupal-link-system-path' => 'llama',
'data-drupal-link-query' => Json::encode(['foo' => 'bar']),
]; ];
$situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes]; $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
$situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'nl']]; $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
// Matching path, plus all non-matching variations. // Matching path, plus all non-matching variations.
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en']]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
unset($attributes['data-drupal-link-query']);
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => TRUE]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => TRUE]];
// Special non-matching path, plus all variations. // Special non-matching path, plus all variations.
...@@ -176,7 +174,6 @@ public function providerTestSetLinkActiveClass() { ...@@ -176,7 +174,6 @@ public function providerTestSetLinkActiveClass() {
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en']]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en']];
unset($attributes['data-drupal-link-query']);
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => TRUE]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => TRUE]];
...@@ -191,13 +188,11 @@ public function providerTestSetLinkActiveClass() { ...@@ -191,13 +188,11 @@ public function providerTestSetLinkActiveClass() {
// Matching path, plus all matching variations. // Matching path, plus all matching variations.
$attributes = [ $attributes = [
'data-drupal-link-system-path' => 'llama', 'data-drupal-link-system-path' => 'llama',
'data-drupal-link-query' => Json::encode(['foo' => 'bar']),
]; ];
$situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes]; $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
$situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'nl']]; $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
// Matching path, plus all non-matching variations. // Matching path, plus all non-matching variations.
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en']]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
unset($attributes['data-drupal-link-query']);
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]];
...@@ -209,7 +204,6 @@ public function providerTestSetLinkActiveClass() { ...@@ -209,7 +204,6 @@ public function providerTestSetLinkActiveClass() {
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en']]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en']];
unset($attributes['data-drupal-link-query']);
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]];
...@@ -226,13 +220,11 @@ public function providerTestSetLinkActiveClass() { ...@@ -226,13 +220,11 @@ public function providerTestSetLinkActiveClass() {
// Matching path, plus all matching variations. // Matching path, plus all matching variations.
$attributes = [ $attributes = [
'data-drupal-link-system-path' => 'my-front-page', 'data-drupal-link-system-path' => 'my-front-page',
'data-drupal-link-query' => Json::encode(['foo' => 'bar']),
]; ];
$situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes]; $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
$situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'en']]; $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
// Matching path, plus all non-matching variations. // Matching path, plus all non-matching variations.
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
unset($attributes['data-drupal-link-query']);
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => ""]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => ""]];
...@@ -240,13 +232,11 @@ public function providerTestSetLinkActiveClass() { ...@@ -240,13 +232,11 @@ public function providerTestSetLinkActiveClass() {
// Special matching path, plus all variations. // Special matching path, plus all variations.
$attributes = [ $attributes = [
'data-drupal-link-system-path' => '<front>', 'data-drupal-link-system-path' => '<front>',
'data-drupal-link-query' => Json::encode(['foo' => 'bar']),
]; ];
$situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes]; $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
$situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'en']]; $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
// Special matching path, plus all non-matching variations. // Special matching path, plus all non-matching variations.
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
unset($attributes['data-drupal-link-query']);
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => ""]]; $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => ""]];
......
...@@ -477,7 +477,7 @@ public function providerPlaceholders() { ...@@ -477,7 +477,7 @@ public function providerPlaceholders() {
// - uncacheable // - uncacheable
$x = $base_element_b; $x = $base_element_b;
$expected_placeholder_render_array = $x['#attached']['placeholders'][(string) $generate_placeholder_markup()]; $expected_placeholder_render_array = $x['#attached']['placeholders'][(string) $generate_placeholder_markup()];
unset($x['#attached']['placeholders'][(string) $generate_placeholder_markup()]['#cache']); $this->assertArrayNotHasKey('#cache', $expected_placeholder_render_array);
$cases[] = [ $cases[] = [
$x, $x,
$args, $args,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment