File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,6 +93,9 @@ class Config
9393 /** @var int<0, max> */
9494 public int $ server = 0 ;
9595
96+ /** @var array<string,string|null> $tempDir */
97+ private static array $ tempDir = [];
98+
9699 public function __construct ()
97100 {
98101 $ this ->config = new Settings ([]);
@@ -1001,15 +1004,11 @@ public static function renderHeader(): string
10011004 * Returns temporary dir path
10021005 *
10031006 * @param string $name Directory name
1004- *
1005- * @staticvar array<string,string|null> $temp_dir
10061007 */
10071008 public function getTempDir (string $ name ): string |null
10081009 {
1009- static $ tempDir = [];
1010-
1011- if (isset ($ tempDir [$ name ]) && ! defined ('TESTSUITE ' )) {
1012- return $ tempDir [$ name ];
1010+ if (isset (self ::$ tempDir [$ name ])) {
1011+ return self ::$ tempDir [$ name ];
10131012 }
10141013
10151014 $ path = $ this ->get ('TempDir ' );
@@ -1026,7 +1025,7 @@ public function getTempDir(string $name): string|null
10261025 }
10271026 }
10281027
1029- $ tempDir [$ name ] = $ path ;
1028+ self :: $ tempDir [$ name ] = $ path ;
10301029
10311030 return $ path ;
10321031 }
Original file line number Diff line number Diff line change 263263 <code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs']]]></code>
264264 <code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs_mtime']]]></code>
265265 <code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs_type']]]></code>
266- <code>$tempDir[$name]</code>
267266 </MixedArrayAssignment>
268267 <MixedAssignment>
269268 <code><![CDATA[$GLOBALS['cfg']['LoginCookieValidity']]]></code>
280279 <code>$value</code>
281280 </MixedAssignment>
282281 <MixedInferredReturnType>
283- <code>string|null </code>
282+ <code>string</code>
284283 </MixedInferredReturnType>
285284 <MixedReturnStatement>
286- <code>$tempDir[$name] </code>
285+ <code>$cookiePath </code>
287286 </MixedReturnStatement>
288287 <PossiblyInvalidArgument>
289288 <code>$defaultValue</code>
Original file line number Diff line number Diff line change 1212use PHPUnit \Framework \Attributes \DataProvider ;
1313use PHPUnit \Framework \Attributes \Depends ;
1414use PHPUnit \Framework \Attributes \Group ;
15+ use ReflectionProperty ;
1516
1617use function define ;
1718use function defined ;
@@ -672,6 +673,7 @@ public function testGetTempDir(): void
672673 $ this ->assertDirectoryExists ($ dir );
673674 $ this ->assertDirectoryIsWritable ($ dir );
674675
676+ (new ReflectionProperty (Config::class, 'tempDir ' ))->setValue ([]);
675677 $ this ->object ->set ('TempDir ' , $ dir . DIRECTORY_SEPARATOR );
676678 // Check no double slash is here
677679 $ this ->assertEquals (
You can’t perform that action at this time.
0 commit comments