@@ -23,27 +23,26 @@ trait FilesystemAdapterTrait
23
23
private $ directory ;
24
24
private $ tmp ;
25
25
26
- private function init ($ namespace , $ directory )
26
+ private function init ($ namespace , $ dir )
27
27
{
28
- if (!isset ($ directory [0 ])) {
29
- $ directory = sys_get_temp_dir ().'/symfony-cache ' ;
28
+ if (!isset ($ dir [0 ])) {
29
+ $ dir = sys_get_temp_dir ().'/symfony-cache ' ;
30
+ } else {
31
+ $ dir = realpath ($ dir ) ?: $ dir ;
30
32
}
31
33
if (isset ($ namespace [0 ])) {
32
34
if (preg_match ('#[^-+_.A-Za-z0-9]# ' , $ namespace , $ match )) {
33
35
throw new InvalidArgumentException (sprintf ('Namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed. ' , $ match [0 ]));
34
36
}
35
- $ directory .= ' / ' .$ namespace ;
37
+ $ dir .= DIRECTORY_SEPARATOR .$ namespace ;
36
38
}
37
- if (!file_exists ($ dir = $ directory .'/. ' )) {
38
- @mkdir ($ directory , 0777 , true );
39
- }
40
- if (false === $ dir = realpath ($ dir ) ?: (file_exists ($ dir ) ? $ dir : false )) {
41
- throw new InvalidArgumentException (sprintf ('Cache directory does not exist (%s) ' , $ directory ));
39
+ if (!file_exists ($ dir )) {
40
+ @mkdir ($ dir , 0777 , true );
42
41
}
43
42
$ dir .= DIRECTORY_SEPARATOR ;
44
43
// On Windows the whole path is limited to 258 chars
45
44
if ('\\' === DIRECTORY_SEPARATOR && strlen ($ dir ) > 234 ) {
46
- throw new InvalidArgumentException (sprintf ('Cache directory too long (%s) ' , $ directory ));
45
+ throw new InvalidArgumentException (sprintf ('Cache directory too long (%s) ' , $ dir ));
47
46
}
48
47
49
48
$ this ->directory = $ dir ;
0 commit comments