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

(cherry picked from commit 0bab40ee30)
merge-requests/2796/head
Alex Pott 2022-10-17 11:41:00 +01:00
parent f17bf6c57f
commit 59f14c20d0
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
7 changed files with 19 additions and 31 deletions

View File

@ -396,7 +396,6 @@ MENU_UI
// Test menu migration with menu_ui uninstalled.
$tests[3] = $tests[1];
unset($tests[3]['modules_to_enable']['menu_ui']);
unset($tests[3]['files']['menu_ui']);
unset($tests[3]['migrations']['menu_ui']);
$tests[3]['expected_7'] = [
MigrationState::NOT_FINISHED => [

View File

@ -439,7 +439,6 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
// If the display cannot use a pager, then we cannot default it.
if (!$this->usesPager()) {
unset($sections['pager']);
unset($sections['items_per_page']);
}
foreach ($this->extenders as $extender) {

View File

@ -57,11 +57,11 @@ class FileStorageReadOnlyTest extends PhpStorageTestBase {
// Find a global that doesn't exist.
do {
$random = mt_rand(10000, 100000);
$random = 'test' . mt_rand(10000, 100000);
} while (isset($GLOBALS[$random]));
// 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);
$this->assertTrue($success);
$php_read = new FileReadOnlyStorage($this->readonlyStorage);

View File

@ -70,11 +70,11 @@ class FileStorageTest extends PhpStorageTestBase {
// Find a global that doesn't exist.
do {
$random = mt_rand(10000, 100000);
$random = 'test' . mt_rand(10000, 100000);
} while (isset($GLOBALS[$random]));
// 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');
$php->load($name);
$this->assertTrue($GLOBALS[$random], 'File saved correctly with correct value');

View File

@ -39,11 +39,11 @@ abstract class PhpStorageTestBase extends TestCase {
// Find a global that doesn't exist.
do {
$random = mt_rand(10000, 100000);
$random = 'test' . mt_rand(10000, 100000);
} while (isset($GLOBALS[$random]));
// 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);
$this->assertTrue($success, 'Saved php file');
$php->load($name);

View File

@ -160,13 +160,11 @@ class ActiveLinkResponseFilterTest extends UnitTestCase {
// Matching path, plus all matching variations.
$attributes = [
'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 + ['hreflang' => 'nl']];
$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', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
// Matching path, plus all non-matching variations.
$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' => 'en', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
$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]];
// Special non-matching path, plus all variations.
@ -176,7 +174,6 @@ class ActiveLinkResponseFilterTest extends UnitTestCase {
$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' => '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' => TRUE]];
@ -191,13 +188,11 @@ class ActiveLinkResponseFilterTest extends UnitTestCase {
// Matching path, plus all matching variations.
$attributes = [
'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 + ['hreflang' => 'nl']];
$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', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
// Matching path, plus all non-matching variations.
$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' => 'en', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
$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 + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]];
@ -209,7 +204,6 @@ class ActiveLinkResponseFilterTest extends UnitTestCase {
$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' => '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' => TRUE]];
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]];
@ -226,13 +220,11 @@ class ActiveLinkResponseFilterTest extends UnitTestCase {
// Matching path, plus all matching variations.
$attributes = [
'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 + ['hreflang' => 'en']];
$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', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
// Matching path, plus all non-matching variations.
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']];
unset($attributes['data-drupal-link-query']);
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
$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 + ['hreflang' => 'en', 'data-drupal-link-query' => ""]];
@ -240,13 +232,11 @@ class ActiveLinkResponseFilterTest extends UnitTestCase {
// Special matching path, plus all variations.
$attributes = [
'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 + ['hreflang' => 'en']];
$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', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
// Special matching path, plus all non-matching variations.
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']];
unset($attributes['data-drupal-link-query']);
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => Json::encode(['foo' => 'bar'])]];
$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 + ['hreflang' => 'en', 'data-drupal-link-query' => ""]];

View File

@ -477,7 +477,7 @@ class RendererPlaceholdersTest extends RendererTestBase {
// - uncacheable
$x = $base_element_b;
$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[] = [
$x,
$args,