Compare commits

...

8 Commits

Author SHA1 Message Date
Alexander M. Turek 04a7e4c1bf [ClassLoader][Routing] Fix namespace parsing on php 8. 2020-08-09 13:28:08 +02:00
Fabien Potencier e4636a4f23 Add missing dots at the end of exception messages 2020-03-15 10:38:08 +01:00
Shaharia Azam bcdf6ff46e Update links to documentation 2020-01-04 13:05:51 +01:00
Jan Rosier a016c360a5 Update year in license files 2020-01-01 12:03:25 +01:00
Alexander M. Turek e212b06996 Fix inconsistent return points. 2019-08-20 15:31:17 +02:00
Jérémy Derussé 5a37725821 Remove use of ForwardCompatTrait 2019-08-03 23:15:25 +02:00
Jérémy Derussé bfe1178328 Fix deprecated phpunit annotation 2019-08-02 00:48:42 +02:00
Nicolas Grekas 4860dcded1 Make tests support phpunit 8 2019-07-31 23:55:24 +02:00
11 changed files with 31 additions and 13 deletions
+2
View File
@@ -113,6 +113,8 @@ class ApcClassLoader
return true;
}
return null;
}
/**
+9 -4
View File
@@ -63,7 +63,7 @@ class ClassCollectionLoader
// cache the core classes
if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir));
throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s".', $cacheDir));
}
$cacheDir = rtrim(realpath($cacheDir) ?: $cacheDir, '/'.\DIRECTORY_SEPARATOR);
$cache = $cacheDir.'/'.$name.$extension;
@@ -133,7 +133,7 @@ class ClassCollectionLoader
// cache the core classes
$cacheDir = \dirname($cache);
if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir));
throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s".', $cacheDir));
}
$spacesRegex = '(?:\s*+(?:(?:\#|//)[^\n]*+\n|/\*(?:(?<!\*/).)++)?+)*+';
@@ -216,6 +216,11 @@ REGEX;
$inNamespace = false;
$tokens = token_get_all($source);
$nsTokens = [T_WHITESPACE => true, T_NS_SEPARATOR => true, T_STRING => true];
if (\defined('T_NAME_QUALIFIED')) {
$nsTokens[T_NAME_QUALIFIED] = true;
}
for ($i = 0; isset($tokens[$i]); ++$i) {
$token = $tokens[$i];
if (!isset($token[1]) || 'b"' === $token) {
@@ -230,7 +235,7 @@ REGEX;
$rawChunk .= $token[1];
// namespace name and whitespaces
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], [T_WHITESPACE, T_NS_SEPARATOR, T_STRING])) {
while (isset($tokens[++$i][1], $nsTokens[$tokens[$i][0]])) {
$rawChunk .= $tokens[$i][1];
}
if ('{' === $tokens[$i]) {
@@ -336,7 +341,7 @@ REGEX;
try {
$reflectionClass = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
throw new \InvalidArgumentException(sprintf('Unable to load class "%s".', $class));
}
$map = array_merge($map, self::getClassHierarchy($reflectionClass));
+4
View File
@@ -161,6 +161,8 @@ class ClassLoader
return true;
}
return null;
}
/**
@@ -203,5 +205,7 @@ class ClassLoader
if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) {
return $file;
}
return null;
}
}
+6 -1
View File
@@ -93,6 +93,11 @@ class ClassMapGenerator
$contents = file_get_contents($path);
$tokens = token_get_all($contents);
$nsTokens = [T_STRING => true, T_NS_SEPARATOR => true];
if (\defined('T_NAME_QUALIFIED')) {
$nsTokens[T_NAME_QUALIFIED] = true;
}
$classes = [];
$namespace = '';
@@ -110,7 +115,7 @@ class ClassMapGenerator
$namespace = '';
// If there is a namespace, extract it
while (isset($tokens[++$i][1])) {
if (\in_array($tokens[$i][0], [T_STRING, T_NS_SEPARATOR])) {
if (isset($nsTokens[$tokens[$i][0]])) {
$namespace .= $tokens[$i][1];
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2019 Fabien Potencier
Copyright (c) 2004-2020 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+1 -3
View File
@@ -63,8 +63,6 @@ class MapClassLoader
*/
public function findFile($class)
{
if (isset($this->map[$class])) {
return $this->map[$class];
}
return isset($this->map[$class]) ? $this->map[$class] : null;
}
}
+2
View File
@@ -55,6 +55,8 @@ class Psr4ClassLoader
}
}
}
return null;
}
/**
+1 -1
View File
@@ -7,7 +7,7 @@ their locations for performance.
Resources
---------
* [Documentation](https://symfony.com/doc/current/components/class_loader/index.html)
* [Documentation](https://symfony.com/doc/current/components/class_loader.html)
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
* [Report issues](https://github.com/symfony/symfony/issues) and
[send Pull Requests](https://github.com/symfony/symfony/pulls)
+1 -3
View File
@@ -208,11 +208,9 @@ class ClassCollectionLoaderTest extends TestCase
];
}
/**
* @expectedException \InvalidArgumentException
*/
public function testUnableToLoadClassException()
{
$this->expectException('InvalidArgumentException');
if (is_file($file = sys_get_temp_dir().'/foo.php')) {
unlink($file);
}
+2
View File
@@ -112,6 +112,8 @@ class WinCacheClassLoader
return true;
}
return null;
}
/**
+2
View File
@@ -106,6 +106,8 @@ class XcacheClassLoader
return true;
}
return null;
}
/**