Replace inline static with class static (#18490)
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> Co-authored-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
62a2b7fa34
commit
f8111a7a7e
@ -93,6 +93,9 @@ class Config
|
||||
/** @var int<0, max> */
|
||||
public int $server = 0;
|
||||
|
||||
/** @var array<string,string|null> $tempDir */
|
||||
private static array $tempDir = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->config = new Settings([]);
|
||||
@ -1001,15 +1004,11 @@ class Config
|
||||
* Returns temporary dir path
|
||||
*
|
||||
* @param string $name Directory name
|
||||
*
|
||||
* @staticvar array<string,string|null> $temp_dir
|
||||
*/
|
||||
public function getTempDir(string $name): string|null
|
||||
{
|
||||
static $tempDir = [];
|
||||
|
||||
if (isset($tempDir[$name]) && ! defined('TESTSUITE')) {
|
||||
return $tempDir[$name];
|
||||
if (isset(self::$tempDir[$name])) {
|
||||
return self::$tempDir[$name];
|
||||
}
|
||||
|
||||
$path = $this->get('TempDir');
|
||||
@ -1026,7 +1025,7 @@ class Config
|
||||
}
|
||||
}
|
||||
|
||||
$tempDir[$name] = $path;
|
||||
self::$tempDir[$name] = $path;
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
@ -263,7 +263,6 @@
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs_mtime']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs_type']]]></code>
|
||||
<code>$tempDir[$name]</code>
|
||||
</MixedArrayAssignment>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$GLOBALS['cfg']['LoginCookieValidity']]]></code>
|
||||
@ -280,10 +279,10 @@
|
||||
<code>$value</code>
|
||||
</MixedAssignment>
|
||||
<MixedInferredReturnType>
|
||||
<code>string|null</code>
|
||||
<code>string</code>
|
||||
</MixedInferredReturnType>
|
||||
<MixedReturnStatement>
|
||||
<code>$tempDir[$name]</code>
|
||||
<code>$cookiePath</code>
|
||||
</MixedReturnStatement>
|
||||
<PossiblyInvalidArgument>
|
||||
<code>$defaultValue</code>
|
||||
|
||||
@ -12,6 +12,7 @@ use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Depends;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use ReflectionProperty;
|
||||
|
||||
use function define;
|
||||
use function defined;
|
||||
@ -672,6 +673,7 @@ PHP;
|
||||
$this->assertDirectoryExists($dir);
|
||||
$this->assertDirectoryIsWritable($dir);
|
||||
|
||||
(new ReflectionProperty(Config::class, 'tempDir'))->setValue([]);
|
||||
$this->object->set('TempDir', $dir . DIRECTORY_SEPARATOR);
|
||||
// Check no double slash is here
|
||||
$this->assertEquals(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user