Compare commits

...

27 Commits
3.3 ... v3.4.23

Author SHA1 Message Date
Fabien Potencier
4459eef529 switched array() to [] 2019-01-16 10:39:14 +01:00
Christian Flothmann
4513348012 update year in license files 2019-01-01 14:45:19 +01:00
Nicolas Grekas
420458095c Merge branch '2.8' into 3.4
* 2.8:
  [Form] Hardened test suite for empty data
  Bump phpunit XSD version to 5.2
  Add required key attribute
2018-11-11 20:48:54 +01:00
Grégoire Paris
8194721a1e Bump phpunit XSD version to 5.2
Some attributes being used in the phpunit configuration files, namely
failOnRisky and failOnWarning were introduced in phpunit 5.2.0. The
Composer configuration shows that tests should run with old versions of
phpunit, but phpunit only validates the configuration against the XSD
since phpunit 7.2.0.
These changes can be tested as follows:

wget http://schema.phpunit.de/5.2/phpunit.xsd
xargs xmllint --schema phpunit.xsd  1>/dev/null
find src -name phpunit.xml.dist| xargs xmllint --schema phpunit.xsd  1>/dev/null

See 7e06a82806
See 46e3745a03/composer.json (L98)
2018-11-11 12:18:13 +01:00
Nicolas Grekas
5605edec7b Merge branch '2.8' into 3.4
* 2.8:
  Fixed typo
  Fix ini_get() for boolean values
2018-10-31 10:06:03 +01:00
François-Xavier de Guillebon
5694f145b1 Fix ini_get() for boolean values 2018-10-30 17:24:01 +01:00
Nicolas Grekas
f31333bdff Merge branch '2.8' into 3.4
* 2.8:
  [php_cs] disable fopen_flags
  [CS] Remove unused variables passed to closures
  [CS] Remove empty comment
  [CS] Enforces null type hint on last position in phpDocs
  [CS] Use combined assignment operators when possible
  Fix a typo in error messages
  [Console] Add missing null to input values allowed types
  [PHPUnitBridge] Fix microtime() format
  bumped Symfony version to 2.8.47
  update CONTRIBUTORS for 2.8.46
  updated VERSION for 2.8.46
  updated CHANGELOG for 2.8.46
2018-10-02 14:28:39 +02:00
Gabriel Caruso
11b1f30ef9 [CS] Use combined assignment operators when possible 2018-10-01 23:42:26 -03:00
Nicolas Grekas
31db283fc8 Merge branch '2.8' into 3.4
* 2.8:
  Enable native_constant_invocation CS fixer
2018-07-26 13:19:56 +02:00
Nicolas Grekas
f65a559906 Enable native_constant_invocation CS fixer 2018-07-26 13:13:39 +02:00
Nicolas Grekas
3716acff65 minor #28025 Use an empty string as default for assertEquals (DavidPrevot)
This PR was merged into the 3.4 branch.

Discussion
----------

Use an empty string as default for assertEquals

Make sure it isn’t interpreted as a type NULL, making the test fail with PHPUnit 7.2.

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

This shouldn’t break the existing tests, but will also make them work with recent PHPUnit.

Commits
-------

31353147a3 Use an empty string as default for assertEquals
2018-07-26 12:03:52 +02:00
Nicolas Grekas
351b74b156 Merge branch '2.8' into 3.4
* 2.8:
  Fix Clidumper tests
  Enable the fixer enforcing fully-qualified calls for compiler-optimized functions
  Apply fixers
  Disable the native_constant_invocation fixer until it can be scoped
  Update the list of excluded files for the CS fixer
2018-07-26 10:45:46 +02:00
Christophe Coevoet
dadfb73e2f Enable the fixer enforcing fully-qualified calls for compiler-optimized functions 2018-07-24 12:05:38 +02:00
David Prévot
ebdecd509e Use an empty string as default for assertEquals
Make sure it isn’t interpreted as a type NULL, making the test fail with
PHPUnit 7.2.
2018-07-22 11:14:14 +08:00
Fabien Potencier
e63c126998 Merge branch '3.3' into 3.4
* 3.3:
  fixed years in copyright
2018-01-03 08:37:34 +01:00
Nicolas Grekas
192c1b0522 Merge branch '3.3' into 3.4
* 3.3:
  Clean up
  Update return type in docblock.
  PHP CS Fixer: no need to exclude xml and yml files
  PHP CS Fixer: no need to exclude json file
  Update LICENSE year... forever
2018-01-02 16:47:46 +01:00
Fabien Potencier
a447ad59a4 Merge branch '3.3' into 3.4
* 3.3:
  fixed some deprecation messages
  fixed some deprecation messages
  fixed some deprecation messages
  fixed some deprecation messages
  [2.7][DX] Use constant message contextualisation for deprecations
2017-12-31 07:07:31 +01:00
Nicolas Grekas
e8d36a7b55 Merge branch '3.3' into 3.4
* 3.3:
  [Serializer] Fix extra attributes when no group specified
  [Intl] Make intl-data tests pass and save language aliases again
  [Console] Fix CommandTester::setInputs() docblock
  [Serializer] readd default argument value
  [VarDumper] fix trailling comma when dumping an exception
  Remove useless docblocks
  [FrameworkBundle] Fix docblocks
  [PropertyInfo] Remove useless docblocks
2017-11-05 17:10:10 +01:00
Nicolas Grekas
e327469117 Merge branch '3.3' into 3.4
* 3.3:
  [DI] minor docblock fixes
2017-10-24 16:12:06 +02:00
Nicolas Grekas
2141b7653a Merge branch '3.3' into 3.4
* 3.3: (23 commits)
  Tests and fix for issue in array model data in EntityType field with multiple=true
  [Form] Fixed PercentToLocalizedStringTransformer to accept both comma and dot as decimal separator, if possible
  removed useless PHPDoc
  [Form] Fix FormInterface::submit() annotation
  [PHPUnitBridge] don't remove when set to  empty string
  PdoSessionHandler: fix advisory lock for pgsql when session.sid_bits_per_character > 4
  HttpCache does not consider ESI resources in HEAD requests
  Fix translation for "This field was not expected"
  [Routing] Enhance Route(Collection) docblocks
  Added improvement for accuracy in MoneyToLocalizedStringTransformer.
  Removed unused private property
  Use correct verb form in the pull request template
  Use PHP_MAXPATHLEN in Filesystem.
  Added null as explicit return type (?TokenInterface)
  [FrameworkBundle] Fix Routing\DelegatingLoader
  Render all line breaks according to the exception message
  [Form] Fix phpdoc
  [DI] remove confusing code
  [Form] Fixed GroupSequence with "constraints" option
  [Validator] Clarify UUID validator behavior
  ...
2017-10-02 08:49:52 +02:00
Nicolas Grekas
295a2897de Merge branch '3.3' into 3.4
* 3.3:
  [CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction
  [Filesystem] mirror - fix copying content with same name as source/target.
  Removed unnecessary getDefinition() call.
  .php_cs.dist - simplify config
  [WebProfilerBundle] fixed TemplateManager when using Twig 2 without compat interfaces
2017-09-15 12:12:22 +02:00
Nicolas Grekas
1635a4c8fe Merge branch '3.3' into 3.4
* 3.3:
  Removed useless argument $definition
  Fix comment
  [Config] Fix checking class existence freshness
  bumped Symfony version to 3.3.7
  updated VERSION for 3.3.6
  updated CHANGELOG for 3.3.6
  Bump minimal PHP version to ^5.5.9|>=7.0.8
2017-08-03 11:34:20 +02:00
Nicolas Grekas
379123b6b8 Merge branch '3.3' into 3.4
* 3.3:
  Fix optional cache warmers are always instantiated whereas they should be lazy-loaded
  add some \ on PHP_VERSION_ID for 2.8
  [Di] Remove closure-proxy arguments
  [PropertyInfo][DoctrineBridge] The bigint Doctrine's type must be converted to string
2017-06-02 11:54:06 +02:00
Fabien Potencier
9ff12bbe71 Merge branch '3.3' into 3.4
* 3.3: (31 commits)
  Using FQ name for PHP_VERSION_ID
  [EventDispatcher] Handle laziness internally instead of relying on ClosureProxyArgument
  Fix CacheCollectorPass priority
  [Form] Fix \IntlDateFormatter timezone parameter usage to bypass PHP bug #66323
  [Routing] Allow GET requests to be redirected. Fixes #23004
  [DI] Deal with inlined non-shared services
  [Cache] Ignore missing annotations.php
  [DI] Autowiring exception thrown when inlined service is removed
  Improving deprecation message when hitting the "deprecated type" lookup, but an alias is available
  Harden the debugging of Twig filters and functions
  Fixing a bug where an autowiring exception was thrown even when that service was removed
  Remove extra arg in call to TraceableAdapter::start()
  Support unknown compiler log format
  [Config] Allow empty globs
  Fix decorating TagAware adapters in dev
  [Profiler] Fix clicking on links inside toggle
  [Profiler] Fix text selection on exception pages
  bumped Symfony version to 3.3.1
  updated VERSION for 3.3.0
  updated CHANGELOG for 3.3.0
  ...
2017-06-01 14:02:15 -07:00
Nicolas Grekas
6bf941dc4e [3.4] Allow 4.* deps 2017-05-24 11:02:43 +02:00
Kévin Dunglas
cf3e7ac373 Allow individual bridges, bundles and components to be used with 4.0 2017-05-18 14:56:12 +02:00
Fabien Potencier
8c7ae3c4e3 updated version to 3.4 2017-05-17 18:21:40 +02:00
16 changed files with 297 additions and 297 deletions

View File

@@ -69,7 +69,7 @@ class ApcClassLoader
*/
public function __construct($prefix, $decorated)
{
if (!function_exists('apcu_fetch')) {
if (!\function_exists('apcu_fetch')) {
throw new \RuntimeException('Unable to use ApcClassLoader as APC is not installed.');
}
@@ -88,7 +88,7 @@ class ApcClassLoader
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
spl_autoload_register([$this, 'loadClass'], true, $prepend);
}
/**
@@ -96,7 +96,7 @@ class ApcClassLoader
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
spl_autoload_unregister([$this, 'loadClass']);
}
/**
@@ -138,6 +138,6 @@ class ApcClassLoader
*/
public function __call($method, $args)
{
return call_user_func_array(array($this->decorated, $method), $args);
return \call_user_func_array([$this->decorated, $method], $args);
}
}

View File

@@ -56,7 +56,7 @@ class ClassCollectionLoader
$classes = array_diff($classes, $declared);
// the cache is different depending on which classes are already declared
$name = $name.'-'.substr(hash('sha256', implode('|', $classes)), 0, 5);
$name .= '-'.substr(hash('sha256', implode('|', $classes)), 0, 5);
}
$classes = array_unique($classes);
@@ -65,7 +65,7 @@ class ClassCollectionLoader
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));
}
$cacheDir = rtrim(realpath($cacheDir) ?: $cacheDir, '/'.DIRECTORY_SEPARATOR);
$cacheDir = rtrim(realpath($cacheDir) ?: $cacheDir, '/'.\DIRECTORY_SEPARATOR);
$cache = $cacheDir.'/'.$name.$extension;
// auto-reload
@@ -108,7 +108,7 @@ class ClassCollectionLoader
if ($autoReload) {
// save the resources
self::writeCacheFile($metadata, serialize(array(array_values($files), $classes)));
self::writeCacheFile($metadata, serialize([array_values($files), $classes]));
}
}
@@ -125,13 +125,13 @@ class ClassCollectionLoader
*/
public static function inline($classes, $cache, array $excluded)
{
$declared = array();
$declared = [];
foreach (self::getOrderedClasses($excluded) as $class) {
$declared[$class->getName()] = true;
}
// cache the core classes
$cacheDir = dirname($cache);
$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));
}
@@ -146,8 +146,8 @@ class ClassCollectionLoader
REGEX;
$dontInlineRegex = str_replace('.', $spacesRegex, $dontInlineRegex);
$cacheDir = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $cacheDir));
$files = array();
$cacheDir = explode('/', str_replace(\DIRECTORY_SEPARATOR, '/', $cacheDir));
$files = [];
$content = '';
foreach (self::getOrderedClasses($classes) as $class) {
if (isset($declared[$class->getName()])) {
@@ -159,7 +159,7 @@ REGEX;
$c = file_get_contents($file);
if (preg_match($dontInlineRegex, $c)) {
$file = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $file));
$file = explode('/', str_replace(\DIRECTORY_SEPARATOR, '/', $file));
for ($i = 0; isset($file[$i], $cacheDir[$i]); ++$i) {
if ($file[$i] !== $cacheDir[$i]) {
@@ -169,14 +169,14 @@ REGEX;
if (1 >= $i) {
$file = var_export(implode('/', $file), true);
} else {
$file = array_slice($file, $i);
$file = str_repeat('../', count($cacheDir) - $i).implode('/', $file);
$file = \array_slice($file, $i);
$file = str_repeat('../', \count($cacheDir) - $i).implode('/', $file);
$file = '__DIR__.'.var_export('/'.$file, true);
}
$c = "\nnamespace {require $file;}";
} else {
$c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', $c);
$c = preg_replace(['/^\s*<\?php/', '/\?>\s*$/'], '', $c);
// fakes namespace declaration for global code
if (!$class->inNamespace()) {
@@ -203,7 +203,7 @@ REGEX;
*/
public static function fixNamespaceDeclarations($source)
{
if (!function_exists('token_get_all') || !self::$useTokenizer) {
if (!\function_exists('token_get_all') || !self::$useTokenizer) {
if (preg_match('/(^|\s)namespace(.*?)\s*;/', $source)) {
$source = preg_replace('/(^|\s)namespace(.*?)\s*;/', "$1namespace$2\n{", $source)."}\n";
}
@@ -220,7 +220,7 @@ REGEX;
$token = $tokens[$i];
if (!isset($token[1]) || 'b"' === $token) {
$rawChunk .= $token;
} elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
} elseif (\in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) {
// strip comments
continue;
} elseif (T_NAMESPACE === $token[0]) {
@@ -230,7 +230,7 @@ REGEX;
$rawChunk .= $token[1];
// namespace name and whitespaces
while (isset($tokens[++$i][1]) && in_array($tokens[$i][0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], [T_WHITESPACE, T_NS_SEPARATOR, T_STRING])) {
$rawChunk .= $tokens[$i][1];
}
if ('{' === $tokens[$i]) {
@@ -289,8 +289,8 @@ REGEX;
private static function compressCode($code)
{
return preg_replace(
array('/^\s+/m', '/\s+$/m', '/([\n\r]+ *[\n\r]+)+/', '/[ \t]+/'),
array('', '', "\n", ' '),
['/^\s+/m', '/\s+$/m', '/([\n\r]+ *[\n\r]+)+/', '/[ \t]+/'],
['', '', "\n", ' '],
$code
);
}
@@ -305,7 +305,7 @@ REGEX;
*/
private static function writeCacheFile($file, $content)
{
$dir = dirname($file);
$dir = \dirname($file);
if (!is_writable($dir)) {
throw new \RuntimeException(sprintf('Cache directory "%s" is not writable.', $dir));
}
@@ -330,8 +330,8 @@ REGEX;
*/
private static function getOrderedClasses(array $classes)
{
$map = array();
self::$seen = array();
$map = [];
self::$seen = [];
foreach ($classes as $class) {
try {
$reflectionClass = new \ReflectionClass($class);
@@ -348,12 +348,12 @@ REGEX;
private static function getClassHierarchy(\ReflectionClass $class)
{
if (isset(self::$seen[$class->getName()])) {
return array();
return [];
}
self::$seen[$class->getName()] = true;
$classes = array($class);
$classes = [$class];
$parent = $class;
while (($parent = $parent->getParentClass()) && $parent->isUserDefined() && !isset(self::$seen[$parent->getName()])) {
self::$seen[$parent->getName()] = true;
@@ -361,7 +361,7 @@ REGEX;
array_unshift($classes, $parent);
}
$traits = array();
$traits = [];
foreach ($classes as $c) {
foreach (self::resolveDependencies(self::computeTraitDeps($c), $c) as $trait) {
@@ -376,7 +376,7 @@ REGEX;
private static function getInterfaces(\ReflectionClass $class)
{
$classes = array();
$classes = [];
foreach ($class->getInterfaces() as $interface) {
$classes = array_merge($classes, self::getInterfaces($interface));
@@ -394,7 +394,7 @@ REGEX;
private static function computeTraitDeps(\ReflectionClass $class)
{
$traits = $class->getTraits();
$deps = array($class->getName() => $traits);
$deps = [$class->getName() => $traits];
while ($trait = array_pop($traits)) {
if ($trait->isUserDefined() && !isset(self::$seen[$trait->getName()])) {
self::$seen[$trait->getName()] = true;

View File

@@ -43,8 +43,8 @@ namespace Symfony\Component\ClassLoader;
*/
class ClassLoader
{
private $prefixes = array();
private $fallbackDirs = array();
private $prefixes = [];
private $fallbackDirs = [];
private $useIncludePath = false;
/**
@@ -95,12 +95,12 @@ class ClassLoader
return;
}
if (isset($this->prefixes[$prefix])) {
if (is_array($paths)) {
if (\is_array($paths)) {
$this->prefixes[$prefix] = array_unique(array_merge(
$this->prefixes[$prefix],
$paths
));
} elseif (!in_array($paths, $this->prefixes[$prefix])) {
} elseif (!\in_array($paths, $this->prefixes[$prefix])) {
$this->prefixes[$prefix][] = $paths;
}
} else {
@@ -136,7 +136,7 @@ class ClassLoader
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
spl_autoload_register([$this, 'loadClass'], true, $prepend);
}
/**
@@ -144,7 +144,7 @@ class ClassLoader
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
spl_autoload_unregister([$this, 'loadClass']);
}
/**
@@ -174,7 +174,7 @@ class ClassLoader
{
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)).DIRECTORY_SEPARATOR;
$classPath = str_replace('\\', \DIRECTORY_SEPARATOR, substr($class, 0, $pos)).\DIRECTORY_SEPARATOR;
$className = substr($class, $pos + 1);
} else {
// PEAR-like class name
@@ -182,21 +182,21 @@ class ClassLoader
$className = $class;
}
$classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
$classPath .= str_replace('_', \DIRECTORY_SEPARATOR, $className).'.php';
foreach ($this->prefixes as $prefix => $dirs) {
if ($class === strstr($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
return $dir.DIRECTORY_SEPARATOR.$classPath;
if (file_exists($dir.\DIRECTORY_SEPARATOR.$classPath)) {
return $dir.\DIRECTORY_SEPARATOR.$classPath;
}
}
}
}
foreach ($this->fallbackDirs as $dir) {
if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
return $dir.DIRECTORY_SEPARATOR.$classPath;
if (file_exists($dir.\DIRECTORY_SEPARATOR.$classPath)) {
return $dir.\DIRECTORY_SEPARATOR.$classPath;
}
}

View File

@@ -31,7 +31,7 @@ class ClassMapGenerator
public static function dump($dirs, $file)
{
$dirs = (array) $dirs;
$maps = array();
$maps = [];
foreach ($dirs as $dir) {
$maps = array_merge($maps, static::createMap($dir));
@@ -49,11 +49,11 @@ class ClassMapGenerator
*/
public static function createMap($dir)
{
if (is_string($dir)) {
if (\is_string($dir)) {
$dir = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
}
$map = array();
$map = [];
foreach ($dir as $file) {
if (!$file->isFile()) {
@@ -93,7 +93,7 @@ class ClassMapGenerator
$contents = file_get_contents($path);
$tokens = token_get_all($contents);
$classes = array();
$classes = [];
$namespace = '';
for ($i = 0; isset($tokens[$i]); ++$i) {
@@ -110,7 +110,7 @@ class ClassMapGenerator
$namespace = '';
// If there is a namespace, extract it
while (isset($tokens[++$i][1])) {
if (in_array($tokens[$i][0], array(T_STRING, T_NS_SEPARATOR))) {
if (\in_array($tokens[$i][0], [T_STRING, T_NS_SEPARATOR])) {
$namespace .= $tokens[$i][1];
}
}
@@ -129,7 +129,7 @@ class ClassMapGenerator
if (T_DOUBLE_COLON === $tokens[$j][0]) {
$isClassConstant = true;
break;
} elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
} elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) {
break;
}
}

View File

@@ -1,4 +1,4 @@
Copyright (c) 2004-2018 Fabien Potencier
Copyright (c) 2004-2019 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

View File

@@ -22,7 +22,7 @@ namespace Symfony\Component\ClassLoader;
*/
class MapClassLoader
{
private $map = array();
private $map = [];
/**
* @param array $map A map where keys are classes and values the absolute file path
@@ -39,7 +39,7 @@ class MapClassLoader
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
spl_autoload_register([$this, 'loadClass'], true, $prepend);
}
/**

View File

@@ -24,7 +24,7 @@ namespace Symfony\Component\ClassLoader;
*/
class Psr4ClassLoader
{
private $prefixes = array();
private $prefixes = [];
/**
* @param string $prefix
@@ -33,8 +33,8 @@ class Psr4ClassLoader
public function addPrefix($prefix, $baseDir)
{
$prefix = trim($prefix, '\\').'\\';
$baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
$this->prefixes[] = array($prefix, $baseDir);
$baseDir = rtrim($baseDir, \DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR;
$this->prefixes[] = [$prefix, $baseDir];
}
/**
@@ -48,8 +48,8 @@ class Psr4ClassLoader
foreach ($this->prefixes as list($currentPrefix, $currentBaseDir)) {
if (0 === strpos($class, $currentPrefix)) {
$classWithoutPrefix = substr($class, strlen($currentPrefix));
$file = $currentBaseDir.str_replace('\\', DIRECTORY_SEPARATOR, $classWithoutPrefix).'.php';
$classWithoutPrefix = substr($class, \strlen($currentPrefix));
$file = $currentBaseDir.str_replace('\\', \DIRECTORY_SEPARATOR, $classWithoutPrefix).'.php';
if (file_exists($file)) {
return $file;
}
@@ -81,7 +81,7 @@ class Psr4ClassLoader
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
spl_autoload_register([$this, 'loadClass'], true, $prepend);
}
/**
@@ -89,6 +89,6 @@ class Psr4ClassLoader
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
spl_autoload_unregister([$this, 'loadClass']);
}
}

View File

@@ -22,7 +22,7 @@ class ApcClassLoaderTest extends TestCase
{
protected function setUp()
{
if (!(ini_get('apc.enabled') && ini_get('apc.enable_cli'))) {
if (!(filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))) {
$this->markTestSkipped('The apc extension is not enabled.');
} else {
apcu_clear_cache();
@@ -31,7 +31,7 @@ class ApcClassLoaderTest extends TestCase
protected function tearDown()
{
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
if (filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
apcu_clear_cache();
}
}
@@ -39,7 +39,7 @@ class ApcClassLoaderTest extends TestCase
public function testConstructor()
{
$loader = new ClassLoader();
$loader->addPrefix('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Apc\Namespaced', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader = new ApcClassLoader('test.prefix.', $loader);
@@ -52,8 +52,8 @@ class ApcClassLoaderTest extends TestCase
public function testLoadClass($className, $testClassName, $message)
{
$loader = new ClassLoader();
$loader->addPrefix('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Apc_Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Apc\Namespaced', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Apc_Pearlike_', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader = new ApcClassLoader('test.prefix.', $loader);
$loader->loadClass($testClassName);
@@ -62,10 +62,10 @@ class ApcClassLoaderTest extends TestCase
public function getLoadClassTests()
{
return array(
array('\\Apc\\Namespaced\\Foo', 'Apc\\Namespaced\\Foo', '->loadClass() loads Apc\Namespaced\Foo class'),
array('Apc_Pearlike_Foo', 'Apc_Pearlike_Foo', '->loadClass() loads Apc_Pearlike_Foo class'),
);
return [
['\\Apc\\Namespaced\\Foo', 'Apc\\Namespaced\\Foo', '->loadClass() loads Apc\Namespaced\Foo class'],
['Apc_Pearlike_Foo', 'Apc_Pearlike_Foo', '->loadClass() loads Apc_Pearlike_Foo class'],
];
}
/**
@@ -74,9 +74,9 @@ class ApcClassLoaderTest extends TestCase
public function testLoadClassFromFallback($className, $testClassName, $message)
{
$loader = new ClassLoader();
$loader->addPrefix('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Apc_Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('', array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/fallback'));
$loader->addPrefix('Apc\Namespaced', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Apc_Pearlike_', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('', [__DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/fallback']);
$loader = new ApcClassLoader('test.prefix.fallback', $loader);
$loader->loadClass($testClassName);
@@ -86,12 +86,12 @@ class ApcClassLoaderTest extends TestCase
public function getLoadClassFromFallbackTests()
{
return array(
array('\\Apc\\Namespaced\\Baz', 'Apc\\Namespaced\\Baz', '->loadClass() loads Apc\Namespaced\Baz class'),
array('Apc_Pearlike_Baz', 'Apc_Pearlike_Baz', '->loadClass() loads Apc_Pearlike_Baz class'),
array('\\Apc\\Namespaced\\FooBar', 'Apc\\Namespaced\\FooBar', '->loadClass() loads Apc\Namespaced\Baz class from fallback dir'),
array('Apc_Pearlike_FooBar', 'Apc_Pearlike_FooBar', '->loadClass() loads Apc_Pearlike_Baz class from fallback dir'),
);
return [
['\\Apc\\Namespaced\\Baz', 'Apc\\Namespaced\\Baz', '->loadClass() loads Apc\Namespaced\Baz class'],
['Apc_Pearlike_Baz', 'Apc_Pearlike_Baz', '->loadClass() loads Apc_Pearlike_Baz class'],
['\\Apc\\Namespaced\\FooBar', 'Apc\\Namespaced\\FooBar', '->loadClass() loads Apc\Namespaced\Baz class from fallback dir'],
['Apc_Pearlike_FooBar', 'Apc_Pearlike_FooBar', '->loadClass() loads Apc_Pearlike_Baz class from fallback dir'],
];
}
/**
@@ -110,40 +110,40 @@ class ApcClassLoaderTest extends TestCase
public function getLoadClassNamespaceCollisionTests()
{
return array(
array(
array(
'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
),
return [
[
[
'Apc\\NamespaceCollision\\A' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
'Apc\\NamespaceCollision\\A\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
],
'Apc\NamespaceCollision\A\Foo',
'->loadClass() loads NamespaceCollision\A\Foo from alpha.',
),
array(
array(
'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
),
],
[
[
'Apc\\NamespaceCollision\\A\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
'Apc\\NamespaceCollision\\A' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
],
'Apc\NamespaceCollision\A\Bar',
'->loadClass() loads NamespaceCollision\A\Bar from alpha.',
),
array(
array(
'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
),
],
[
[
'Apc\\NamespaceCollision\\A' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
'Apc\\NamespaceCollision\\A\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
],
'Apc\NamespaceCollision\A\B\Foo',
'->loadClass() loads NamespaceCollision\A\B\Foo from beta.',
),
array(
array(
'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
),
],
[
[
'Apc\\NamespaceCollision\\A\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
'Apc\\NamespaceCollision\\A' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
],
'Apc\NamespaceCollision\A\B\Bar',
'->loadClass() loads NamespaceCollision\A\B\Bar from beta.',
),
);
],
];
}
/**
@@ -162,39 +162,39 @@ class ApcClassLoaderTest extends TestCase
public function getLoadClassPrefixCollisionTests()
{
return array(
array(
array(
'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
'ApcPrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
),
return [
[
[
'ApcPrefixCollision_A_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
'ApcPrefixCollision_A_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
],
'ApcPrefixCollision_A_Foo',
'->loadClass() loads ApcPrefixCollision_A_Foo from alpha.',
),
array(
array(
'ApcPrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
),
],
[
[
'ApcPrefixCollision_A_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
'ApcPrefixCollision_A_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
],
'ApcPrefixCollision_A_Bar',
'->loadClass() loads ApcPrefixCollision_A_Bar from alpha.',
),
array(
array(
'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
'ApcPrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
),
],
[
[
'ApcPrefixCollision_A_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
'ApcPrefixCollision_A_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
],
'ApcPrefixCollision_A_B_Foo',
'->loadClass() loads ApcPrefixCollision_A_B_Foo from beta.',
),
array(
array(
'ApcPrefixCollision_A_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
),
],
[
[
'ApcPrefixCollision_A_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
'ApcPrefixCollision_A_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
],
'ApcPrefixCollision_A_B_Bar',
'->loadClass() loads ApcPrefixCollision_A_B_Bar from beta.',
),
);
],
];
}
}

View File

@@ -34,17 +34,17 @@ class ClassCollectionLoaderTest extends TestCase
$m = $r->getMethod('getOrderedClasses');
$m->setAccessible(true);
$ordered = $m->invoke(null, array('CTFoo'));
$ordered = $m->invoke(null, ['CTFoo']);
$this->assertEquals(
array('TD', 'TC', 'TB', 'TA', 'TZ', 'CTFoo'),
['TD', 'TC', 'TB', 'TA', 'TZ', 'CTFoo'],
array_map(function ($class) { return $class->getName(); }, $ordered)
);
$ordered = $m->invoke(null, array('CTBar'));
$ordered = $m->invoke(null, ['CTBar']);
$this->assertEquals(
array('TD', 'TZ', 'TC', 'TB', 'TA', 'CTBar'),
['TD', 'TZ', 'TC', 'TB', 'TA', 'CTBar'],
array_map(function ($class) { return $class->getName(); }, $ordered)
);
}
@@ -54,12 +54,12 @@ class ClassCollectionLoaderTest extends TestCase
*/
public function testClassReordering(array $classes)
{
$expected = array(
$expected = [
'ClassesWithParents\\GInterface',
'ClassesWithParents\\CInterface',
'ClassesWithParents\\B',
'ClassesWithParents\\A',
);
];
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
$m = $r->getMethod('getOrderedClasses');
@@ -72,27 +72,27 @@ class ClassCollectionLoaderTest extends TestCase
public function getDifferentOrders()
{
return array(
array(array(
return [
[[
'ClassesWithParents\\A',
'ClassesWithParents\\CInterface',
'ClassesWithParents\\GInterface',
'ClassesWithParents\\B',
)),
array(array(
]],
[[
'ClassesWithParents\\B',
'ClassesWithParents\\A',
'ClassesWithParents\\CInterface',
)),
array(array(
]],
[[
'ClassesWithParents\\CInterface',
'ClassesWithParents\\B',
'ClassesWithParents\\A',
)),
array(array(
]],
[[
'ClassesWithParents\\A',
)),
);
]],
];
}
/**
@@ -106,7 +106,7 @@ class ClassCollectionLoaderTest extends TestCase
require_once __DIR__.'/Fixtures/ClassesWithParents/D.php';
require_once __DIR__.'/Fixtures/ClassesWithParents/E.php';
$expected = array(
$expected = [
'ClassesWithParents\\GInterface',
'ClassesWithParents\\CInterface',
'ClassesWithParents\\ATrait',
@@ -116,7 +116,7 @@ class ClassCollectionLoaderTest extends TestCase
'ClassesWithParents\\A',
'ClassesWithParents\\D',
'ClassesWithParents\\E',
);
];
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
$m = $r->getMethod('getOrderedClasses');
@@ -129,15 +129,15 @@ class ClassCollectionLoaderTest extends TestCase
public function getDifferentOrdersForTraits()
{
return array(
array(array(
return [
[[
'ClassesWithParents\\E',
'ClassesWithParents\\ATrait',
)),
array(array(
]],
[[
'ClassesWithParents\\E',
)),
);
]],
];
}
public function testFixClassWithTraitsOrdering()
@@ -146,16 +146,16 @@ class ClassCollectionLoaderTest extends TestCase
require_once __DIR__.'/Fixtures/ClassesWithParents/F.php';
require_once __DIR__.'/Fixtures/ClassesWithParents/G.php';
$classes = array(
$classes = [
'ClassesWithParents\\F',
'ClassesWithParents\\G',
);
];
$expected = array(
$expected = [
'ClassesWithParents\\CTrait',
'ClassesWithParents\\F',
'ClassesWithParents\\G',
);
];
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
$m = $r->getMethod('getOrderedClasses');
@@ -176,14 +176,14 @@ class ClassCollectionLoaderTest extends TestCase
public function getFixNamespaceDeclarationsData()
{
return array(
array("namespace;\nclass Foo {}\n", "namespace\n{\nclass Foo {}\n}"),
array("namespace Foo;\nclass Foo {}\n", "namespace Foo\n{\nclass Foo {}\n}"),
array("namespace Bar ;\nclass Foo {}\n", "namespace Bar\n{\nclass Foo {}\n}"),
array("namespace Foo\Bar;\nclass Foo {}\n", "namespace Foo\Bar\n{\nclass Foo {}\n}"),
array("namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n", "namespace Foo\Bar\Bar\n{\nclass Foo {}\n}"),
array("namespace\n{\nclass Foo {}\n}\n", "namespace\n{\nclass Foo {}\n}"),
);
return [
["namespace;\nclass Foo {}\n", "namespace\n{\nclass Foo {}\n}"],
["namespace Foo;\nclass Foo {}\n", "namespace Foo\n{\nclass Foo {}\n}"],
["namespace Bar ;\nclass Foo {}\n", "namespace Bar\n{\nclass Foo {}\n}"],
["namespace Foo\Bar;\nclass Foo {}\n", "namespace Foo\Bar\n{\nclass Foo {}\n}"],
["namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n", "namespace Foo\Bar\Bar\n{\nclass Foo {}\n}"],
["namespace\n{\nclass Foo {}\n}\n", "namespace\n{\nclass Foo {}\n}"],
];
}
/**
@@ -198,14 +198,14 @@ class ClassCollectionLoaderTest extends TestCase
public function getFixNamespaceDeclarationsDataWithoutTokenizer()
{
return array(
array("namespace;\nclass Foo {}\n", "namespace\n{\nclass Foo {}\n}\n"),
array("namespace Foo;\nclass Foo {}\n", "namespace Foo\n{\nclass Foo {}\n}\n"),
array("namespace Bar ;\nclass Foo {}\n", "namespace Bar\n{\nclass Foo {}\n}\n"),
array("namespace Foo\Bar;\nclass Foo {}\n", "namespace Foo\Bar\n{\nclass Foo {}\n}\n"),
array("namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n", "namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n"),
array("\nnamespace\n{\nclass Foo {}\n\$namespace=123;}\n", "\nnamespace\n{\nclass Foo {}\n\$namespace=123;}\n"),
);
return [
["namespace;\nclass Foo {}\n", "namespace\n{\nclass Foo {}\n}\n"],
["namespace Foo;\nclass Foo {}\n", "namespace Foo\n{\nclass Foo {}\n}\n"],
["namespace Bar ;\nclass Foo {}\n", "namespace Bar\n{\nclass Foo {}\n}\n"],
["namespace Foo\Bar;\nclass Foo {}\n", "namespace Foo\Bar\n{\nclass Foo {}\n}\n"],
["namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n", "namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n"],
["\nnamespace\n{\nclass Foo {}\n\$namespace=123;}\n", "\nnamespace\n{\nclass Foo {}\n\$namespace=123;}\n"],
];
}
/**
@@ -217,7 +217,7 @@ class ClassCollectionLoaderTest extends TestCase
unlink($file);
}
ClassCollectionLoader::load(array('SomeNotExistingClass'), sys_get_temp_dir(), 'foo', false);
ClassCollectionLoader::load(['SomeNotExistingClass'], sys_get_temp_dir(), 'foo', false);
}
public function testCommentStripping()
@@ -227,14 +227,14 @@ class ClassCollectionLoaderTest extends TestCase
}
spl_autoload_register($r = function ($class) {
if (0 === strpos($class, 'Namespaced') || 0 === strpos($class, 'Pearlike_')) {
@require_once __DIR__.'/Fixtures/'.str_replace(array('\\', '_'), '/', $class).'.php';
@require_once __DIR__.'/Fixtures/'.str_replace(['\\', '_'], '/', $class).'.php';
}
});
$strictTypes = defined('HHVM_VERSION') ? '' : "\nnamespace {require __DIR__.'/Fixtures/Namespaced/WithStrictTypes.php';}";
$strictTypes = \defined('HHVM_VERSION') ? '' : "\nnamespace {require __DIR__.'/Fixtures/Namespaced/WithStrictTypes.php';}";
ClassCollectionLoader::load(
array('Namespaced\\WithComments', 'Pearlike_WithComments', 'Namespaced\\WithDirMagic', 'Namespaced\\WithFileMagic', 'Namespaced\\WithHaltCompiler', $strictTypes ? 'Namespaced\\WithStrictTypes' : 'Namespaced\\WithComments'),
['Namespaced\\WithComments', 'Pearlike_WithComments', 'Namespaced\\WithDirMagic', 'Namespaced\\WithFileMagic', 'Namespaced\\WithHaltCompiler', $strictTypes ? 'Namespaced\\WithStrictTypes' : 'Namespaced\\WithComments'],
__DIR__,
'bar',
false
@@ -279,7 +279,7 @@ namespace {require __DIR__.'/Fixtures/Namespaced/WithFileMagic.php';}
namespace {require __DIR__.'/Fixtures/Namespaced/WithHaltCompiler.php';}
EOF
.$strictTypes,
str_replace(array("<?php \n", '\\\\'), array('', '/'), file_get_contents($file))
str_replace(["<?php \n", '\\\\'], ['', '/'], file_get_contents($file))
);
unlink($file);
@@ -291,8 +291,8 @@ EOF
@unlink($cache = sys_get_temp_dir().'/inline.php');
$classes = array(WarmedClass::class);
$excluded = array(DeclaredClass::class);
$classes = [WarmedClass::class];
$excluded = [DeclaredClass::class];
ClassCollectionLoader::inline($classes, $cache, $excluded);

View File

@@ -22,9 +22,9 @@ class ClassLoaderTest extends TestCase
public function testGetPrefixes()
{
$loader = new ClassLoader();
$loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Bar', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Bas', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Foo', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Bar', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Bas', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$prefixes = $loader->getPrefixes();
$this->assertArrayHasKey('Foo', $prefixes);
$this->assertArrayNotHasKey('Foo1', $prefixes);
@@ -35,8 +35,8 @@ class ClassLoaderTest extends TestCase
public function testGetFallbackDirs()
{
$loader = new ClassLoader();
$loader->addPrefix(null, __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix(null, __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix(null, __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix(null, __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$fallback_dirs = $loader->getFallbackDirs();
$this->assertCount(2, $fallback_dirs);
}
@@ -47,18 +47,18 @@ class ClassLoaderTest extends TestCase
public function testLoadClass($className, $testClassName, $message)
{
$loader = new ClassLoader();
$loader->addPrefix('Namespaced2\\', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Pearlike2_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Namespaced2\\', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Pearlike2_', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->loadClass($testClassName);
$this->assertTrue(class_exists($className), $message);
}
public function getLoadClassTests()
{
return array(
array('\\Namespaced2\\Foo', 'Namespaced2\\Foo', '->loadClass() loads Namespaced2\Foo class'),
array('\\Pearlike2_Foo', 'Pearlike2_Foo', '->loadClass() loads Pearlike2_Foo class'),
);
return [
['\\Namespaced2\\Foo', 'Namespaced2\\Foo', '->loadClass() loads Namespaced2\Foo class'],
['\\Pearlike2_Foo', 'Pearlike2_Foo', '->loadClass() loads Pearlike2_Foo class'],
];
}
/**
@@ -67,24 +67,24 @@ class ClassLoaderTest extends TestCase
public function testLoadNonexistentClass($className, $testClassName, $message)
{
$loader = new ClassLoader();
$loader->addPrefix('Namespaced2\\', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Pearlike2_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Namespaced2\\', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Pearlike2_', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->loadClass($testClassName);
$this->assertFalse(class_exists($className), $message);
}
public function getLoadNonexistentClassTests()
{
return array(
array('\\Pearlike3_Bar', '\\Pearlike3_Bar', '->loadClass() loads non existing Pearlike3_Bar class with a leading slash'),
);
return [
['\\Pearlike3_Bar', '\\Pearlike3_Bar', '->loadClass() loads non existing Pearlike3_Bar class with a leading slash'],
];
}
public function testAddPrefixSingle()
{
$loader = new ClassLoader();
$loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Foo', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Foo', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$prefixes = $loader->getPrefixes();
$this->assertArrayHasKey('Foo', $prefixes);
$this->assertCount(1, $prefixes['Foo']);
@@ -93,8 +93,8 @@ class ClassLoaderTest extends TestCase
public function testAddPrefixesSingle()
{
$loader = new ClassLoader();
$loader->addPrefixes(array('Foo' => array('foo', 'foo')));
$loader->addPrefixes(array('Foo' => array('foo')));
$loader->addPrefixes(['Foo' => ['foo', 'foo']]);
$loader->addPrefixes(['Foo' => ['foo']]);
$prefixes = $loader->getPrefixes();
$this->assertArrayHasKey('Foo', $prefixes);
$this->assertCount(1, $prefixes['Foo'], print_r($prefixes, true));
@@ -126,7 +126,7 @@ class ClassLoaderTest extends TestCase
set_include_path(__DIR__.'/Fixtures/includepath'.PATH_SEPARATOR.$includePath);
$this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'includepath'.DIRECTORY_SEPARATOR.'Foo.php', $loader->findFile('Foo'));
$this->assertEquals(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'includepath'.\DIRECTORY_SEPARATOR.'Foo.php', $loader->findFile('Foo'));
set_include_path($includePath);
}
@@ -137,21 +137,21 @@ class ClassLoaderTest extends TestCase
public function testLoadClassFromFallback($className, $testClassName, $message)
{
$loader = new ClassLoader();
$loader->addPrefix('Namespaced2\\', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Pearlike2_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('', array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/fallback'));
$loader->addPrefix('Namespaced2\\', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Pearlike2_', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('', [__DIR__.\DIRECTORY_SEPARATOR.'Fixtures/fallback']);
$loader->loadClass($testClassName);
$this->assertTrue(class_exists($className), $message);
}
public function getLoadClassFromFallbackTests()
{
return array(
array('\\Namespaced2\\Baz', 'Namespaced2\\Baz', '->loadClass() loads Namespaced2\Baz class'),
array('\\Pearlike2_Baz', 'Pearlike2_Baz', '->loadClass() loads Pearlike2_Baz class'),
array('\\Namespaced2\\FooBar', 'Namespaced2\\FooBar', '->loadClass() loads Namespaced2\Baz class from fallback dir'),
array('\\Pearlike2_FooBar', 'Pearlike2_FooBar', '->loadClass() loads Pearlike2_Baz class from fallback dir'),
);
return [
['\\Namespaced2\\Baz', 'Namespaced2\\Baz', '->loadClass() loads Namespaced2\Baz class'],
['\\Pearlike2_Baz', 'Pearlike2_Baz', '->loadClass() loads Pearlike2_Baz class'],
['\\Namespaced2\\FooBar', 'Namespaced2\\FooBar', '->loadClass() loads Namespaced2\Baz class from fallback dir'],
['\\Pearlike2_FooBar', 'Pearlike2_FooBar', '->loadClass() loads Pearlike2_Baz class from fallback dir'],
];
}
/**
@@ -168,71 +168,71 @@ class ClassLoaderTest extends TestCase
public function getLoadClassNamespaceCollisionTests()
{
return array(
array(
array(
'NamespaceCollision\\C' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
'NamespaceCollision\\C\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
),
return [
[
[
'NamespaceCollision\\C' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha',
'NamespaceCollision\\C\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta',
],
'NamespaceCollision\C\Foo',
'->loadClass() loads NamespaceCollision\C\Foo from alpha.',
),
array(
array(
'NamespaceCollision\\C\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
'NamespaceCollision\\C' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
),
],
[
[
'NamespaceCollision\\C\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta',
'NamespaceCollision\\C' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha',
],
'NamespaceCollision\C\Bar',
'->loadClass() loads NamespaceCollision\C\Bar from alpha.',
),
array(
array(
'NamespaceCollision\\C' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
'NamespaceCollision\\C\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
),
],
[
[
'NamespaceCollision\\C' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha',
'NamespaceCollision\\C\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta',
],
'NamespaceCollision\C\B\Foo',
'->loadClass() loads NamespaceCollision\C\B\Foo from beta.',
),
array(
array(
'NamespaceCollision\\C\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
'NamespaceCollision\\C' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
),
],
[
[
'NamespaceCollision\\C\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta',
'NamespaceCollision\\C' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha',
],
'NamespaceCollision\C\B\Bar',
'->loadClass() loads NamespaceCollision\C\B\Bar from beta.',
),
array(
array(
'PrefixCollision_C_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
'PrefixCollision_C_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
),
],
[
[
'PrefixCollision_C_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha',
'PrefixCollision_C_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta',
],
'PrefixCollision_C_Foo',
'->loadClass() loads PrefixCollision_C_Foo from alpha.',
),
array(
array(
'PrefixCollision_C_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
'PrefixCollision_C_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
),
],
[
[
'PrefixCollision_C_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta',
'PrefixCollision_C_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha',
],
'PrefixCollision_C_Bar',
'->loadClass() loads PrefixCollision_C_Bar from alpha.',
),
array(
array(
'PrefixCollision_C_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
'PrefixCollision_C_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
),
],
[
[
'PrefixCollision_C_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha',
'PrefixCollision_C_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta',
],
'PrefixCollision_C_B_Foo',
'->loadClass() loads PrefixCollision_C_B_Foo from beta.',
),
array(
array(
'PrefixCollision_C_B_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/beta',
'PrefixCollision_C_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/alpha',
),
],
[
[
'PrefixCollision_C_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta',
'PrefixCollision_C_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha',
],
'PrefixCollision_C_B_Bar',
'->loadClass() loads PrefixCollision_C_B_Bar from beta.',
),
);
],
];
}
}

View File

@@ -74,8 +74,8 @@ class ClassMapGeneratorTest extends TestCase
public function getTestCreateMapTests()
{
$data = array(
array(__DIR__.'/Fixtures/Namespaced', array(
$data = [
[__DIR__.'/Fixtures/Namespaced', [
'Namespaced\\Bar' => realpath(__DIR__).'/Fixtures/Namespaced/Bar.php',
'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php',
'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php',
@@ -84,20 +84,20 @@ class ClassMapGeneratorTest extends TestCase
'Namespaced\\WithHaltCompiler' => realpath(__DIR__).'/Fixtures/Namespaced/WithHaltCompiler.php',
'Namespaced\\WithDirMagic' => realpath(__DIR__).'/Fixtures/Namespaced/WithDirMagic.php',
'Namespaced\\WithFileMagic' => realpath(__DIR__).'/Fixtures/Namespaced/WithFileMagic.php',
)),
array(__DIR__.'/Fixtures/beta/NamespaceCollision', array(
]],
[__DIR__.'/Fixtures/beta/NamespaceCollision', [
'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php',
'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Foo.php',
'NamespaceCollision\\C\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Bar.php',
'NamespaceCollision\\C\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Foo.php',
)),
array(__DIR__.'/Fixtures/Pearlike', array(
]],
[__DIR__.'/Fixtures/Pearlike', [
'Pearlike_Foo' => realpath(__DIR__).'/Fixtures/Pearlike/Foo.php',
'Pearlike_Bar' => realpath(__DIR__).'/Fixtures/Pearlike/Bar.php',
'Pearlike_Baz' => realpath(__DIR__).'/Fixtures/Pearlike/Baz.php',
'Pearlike_WithComments' => realpath(__DIR__).'/Fixtures/Pearlike/WithComments.php',
)),
array(__DIR__.'/Fixtures/classmap', array(
]],
[__DIR__.'/Fixtures/classmap', [
'Foo\\Bar\\A' => realpath(__DIR__).'/Fixtures/classmap/sameNsMultipleClasses.php',
'Foo\\Bar\\B' => realpath(__DIR__).'/Fixtures/classmap/sameNsMultipleClasses.php',
'A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
@@ -108,19 +108,19 @@ class ClassMapGeneratorTest extends TestCase
'ClassMap\\SomeInterface' => realpath(__DIR__).'/Fixtures/classmap/SomeInterface.php',
'ClassMap\\SomeParent' => realpath(__DIR__).'/Fixtures/classmap/SomeParent.php',
'ClassMap\\SomeClass' => realpath(__DIR__).'/Fixtures/classmap/SomeClass.php',
)),
array(__DIR__.'/Fixtures/php5.4', array(
]],
[__DIR__.'/Fixtures/php5.4', [
'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
'Foo\\TBar' => __DIR__.'/Fixtures/php5.4/traits.php',
'Foo\\IBar' => __DIR__.'/Fixtures/php5.4/traits.php',
'Foo\\TFooBar' => __DIR__.'/Fixtures/php5.4/traits.php',
'Foo\\CBar' => __DIR__.'/Fixtures/php5.4/traits.php',
)),
array(__DIR__.'/Fixtures/php5.5', array(
]],
[__DIR__.'/Fixtures/php5.5', [
'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php',
)),
);
]],
];
return $data;
}
@@ -130,15 +130,15 @@ class ClassMapGeneratorTest extends TestCase
$finder = new \Symfony\Component\Finder\Finder();
$finder->files()->in(__DIR__.'/Fixtures/beta/NamespaceCollision');
$this->assertEqualsNormalized(array(
$this->assertEqualsNormalized([
'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php',
'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Foo.php',
'NamespaceCollision\\C\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Bar.php',
'NamespaceCollision\\C\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Foo.php',
), ClassMapGenerator::createMap($finder));
], ClassMapGenerator::createMap($finder));
}
protected function assertEqualsNormalized($expected, $actual, $message = null)
protected function assertEqualsNormalized($expected, $actual, $message = '')
{
foreach ($expected as $ns => $path) {
$expected[$ns] = str_replace('\\', '/', $path);

View File

@@ -28,7 +28,7 @@ class Psr4ClassLoaderTest extends TestCase
$loader = new Psr4ClassLoader();
$loader->addPrefix(
'Acme\\DemoLib',
__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4'
__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'psr-4'
);
$loader->loadClass($className);
$this->assertTrue(class_exists($className), sprintf('loadClass() should load %s', $className));
@@ -39,12 +39,12 @@ class Psr4ClassLoaderTest extends TestCase
*/
public function getLoadClassTests()
{
return array(
array('Acme\\DemoLib\\Foo'),
array('Acme\\DemoLib\\Class_With_Underscores'),
array('Acme\\DemoLib\\Lets\\Go\\Deeper\\Foo'),
array('Acme\\DemoLib\\Lets\\Go\\Deeper\\Class_With_Underscores'),
);
return [
['Acme\\DemoLib\\Foo'],
['Acme\\DemoLib\\Class_With_Underscores'],
['Acme\\DemoLib\\Lets\\Go\\Deeper\\Foo'],
['Acme\\DemoLib\\Lets\\Go\\Deeper\\Class_With_Underscores'],
];
}
/**
@@ -56,7 +56,7 @@ class Psr4ClassLoaderTest extends TestCase
$loader = new Psr4ClassLoader();
$loader->addPrefix(
'Acme\\DemoLib',
__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4'
__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'psr-4'
);
$loader->loadClass($className);
$this->assertFalse(class_exists($className), sprintf('loadClass() should not load %s', $className));
@@ -67,9 +67,9 @@ class Psr4ClassLoaderTest extends TestCase
*/
public function getLoadNonexistentClassTests()
{
return array(
array('Acme\\DemoLib\\I_Do_Not_Exist'),
array('UnknownVendor\\SomeLib\\I_Do_Not_Exist'),
);
return [
['Acme\\DemoLib\\I_Do_Not_Exist'],
['UnknownVendor\\SomeLib\\I_Do_Not_Exist'],
];
}
}

View File

@@ -68,7 +68,7 @@ class WinCacheClassLoader
*/
public function __construct($prefix, $decorated)
{
if (!extension_loaded('wincache')) {
if (!\extension_loaded('wincache')) {
throw new \RuntimeException('Unable to use WinCacheClassLoader as WinCache is not enabled.');
}
@@ -87,7 +87,7 @@ class WinCacheClassLoader
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
spl_autoload_register([$this, 'loadClass'], true, $prepend);
}
/**
@@ -95,7 +95,7 @@ class WinCacheClassLoader
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
spl_autoload_unregister([$this, 'loadClass']);
}
/**
@@ -137,6 +137,6 @@ class WinCacheClassLoader
*/
public function __call($method, $args)
{
return call_user_func_array(array($this->decorated, $method), $args);
return \call_user_func_array([$this->decorated, $method], $args);
}
}

View File

@@ -62,7 +62,7 @@ class XcacheClassLoader
*/
public function __construct($prefix, $decorated)
{
if (!extension_loaded('xcache')) {
if (!\extension_loaded('xcache')) {
throw new \RuntimeException('Unable to use XcacheClassLoader as XCache is not enabled.');
}
@@ -81,7 +81,7 @@ class XcacheClassLoader
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
spl_autoload_register([$this, 'loadClass'], true, $prepend);
}
/**
@@ -89,7 +89,7 @@ class XcacheClassLoader
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
spl_autoload_unregister([$this, 'loadClass']);
}
/**
@@ -132,6 +132,6 @@ class XcacheClassLoader
*/
public function __call($method, $args)
{
return call_user_func_array(array($this->decorated, $method), $args);
return \call_user_func_array([$this->decorated, $method], $args);
}
}

View File

@@ -20,7 +20,7 @@
"php": "^5.5.9|>=7.0.8"
},
"require-dev": {
"symfony/finder": "~2.8|~3.0",
"symfony/finder": "~2.8|~3.0|~4.0",
"symfony/polyfill-apcu": "~1.1"
},
"suggest": {
@@ -34,7 +34,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
"dev-master": "3.4-dev"
}
}
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"