Skip to content

Commit

Permalink
Suggestions for #4618 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed May 9, 2022
1 parent 32306fa commit 4405ac8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
12 changes: 6 additions & 6 deletions core-bundle/src/Resources/contao/library/Contao/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ class Input
/**
* Parameters set via setGet() are stored by request
*
* @var \WeakMap<Request,array<string,array|string>>|null
* @var \WeakMap<Request,array<string,array|string>>
*/
private static \WeakMap|null $setGet = null;
private static \WeakMap $setGet;

/**
* Parameters set via setPost() are stored by request
*
* @var \WeakMap<Request,array<string,array|string>>|null
* @var \WeakMap<Request,array<string,array|string>>
*/
private static \WeakMap|null $setPost = null;
private static \WeakMap $setPost;

/**
* Parameters set via setCookie() are stored by request
*
* @var \WeakMap<Request,array<string,array|string>>|null
* @var \WeakMap<Request,array<string,array|string>>
*/
private static \WeakMap|null $setCookie = null;
private static \WeakMap $setCookie;

/**
* Clean the global GPC arrays
Expand Down
1 change: 1 addition & 0 deletions core-bundle/tests/Contao/InputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ protected function tearDown(): void
{
unset($GLOBALS['TL_CONFIG']);

$_COOKIE = [];
$this->restoreServerEnvGetPost();
$this->resetStaticProperties([System::class, Input::class]);

Expand Down
4 changes: 4 additions & 0 deletions core-bundle/tests/PhpunitExtension/GlobalStateWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ private function buildStaticMembers(): string
continue;
}

if ($value instanceof \WeakMap && $value->count() === 0 && $property->hasType() && !$property->getType()->allowsNull()) {
continue;
}

if (\is_array($value)) {
$value = 'array('.\count($value).')';
}
Expand Down
4 changes: 1 addition & 3 deletions test-case/src/ContaoTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ protected function backupServerEnvGetPost(): void
'_ENV' => $_ENV,
'_GET' => $_GET,
'_POST' => $_POST,
'_COOKIE' => $_COOKIE,
];
}

Expand All @@ -285,7 +284,6 @@ protected function restoreServerEnvGetPost(): void
$_ENV = $this->backupServerEnvGetPost['_ENV'] ?? $_ENV;
$_GET = $this->backupServerEnvGetPost['_GET'] ?? [];
$_POST = $this->backupServerEnvGetPost['_POST'] ?? [];
$_COOKIE = $this->backupServerEnvGetPost['_COOKIE'] ?? [];
}

/**
Expand All @@ -312,7 +310,7 @@ protected function resetStaticProperties(array $classNames): void
&& \is_callable([$class, 'reset'])
&& method_exists($class, 'reset')
&& $reflectionClass->getMethod('reset')->isStatic()
&& $reflectionClass->getMethod('reset')->getDeclaringClass() === $class
&& $reflectionClass->getMethod('reset')->getDeclaringClass()->getName() === $class
&& 0 === \count($reflectionClass->getMethod('reset')->getParameters())
) {
$class::reset();
Expand Down

0 comments on commit 4405ac8

Please sign in to comment.