feature #22786 [ClassLoader][HttpKernel] Remove ClassLoader component & Kernel::loadClassCache (ogizanagi, xabbuh)
This PR was merged into the 4.0-dev branch. Discussion ---------- [ClassLoader][HttpKernel] Remove ClassLoader component & Kernel::loadClassCache | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? |no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | https://github.com/symfony/symfony/pull/20735 | License | MIT | Doc PR | N/A As deprecated in https://github.com/symfony/symfony/pull/20735 Commits -------551aaef
[ClassLoader] remove the component4f8916c
[ClassLoader][HttpKernel] Remove ClassCollectionLoader & Kernel::loadClassCache BC layer
This commit is contained in:
commit
4d9d8cbbef
@ -32,7 +32,6 @@
|
||||
"symfony/asset": "self.version",
|
||||
"symfony/browser-kit": "self.version",
|
||||
"symfony/cache": "self.version",
|
||||
"symfony/class-loader": "self.version",
|
||||
"symfony/config": "self.version",
|
||||
"symfony/console": "self.version",
|
||||
"symfony/css-selector": "self.version",
|
||||
|
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
|
||||
|
||||
use Symfony\Component\ClassLoader\ClassCollectionLoader;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
|
||||
|
||||
/**
|
||||
* Generates the Class Cache (classes.php) file.
|
||||
*
|
||||
* @author Tugdual Saunier <tucksaun@gmail.com>
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0.
|
||||
*/
|
||||
class ClassCacheCacheWarmer implements CacheWarmerInterface
|
||||
{
|
||||
private $declaredClasses;
|
||||
|
||||
public function __construct(array $declaredClasses = null)
|
||||
{
|
||||
if (PHP_VERSION_ID >= 70000) {
|
||||
@trigger_error('The '.__CLASS__.' class is deprecated since version 3.3 and will be removed in 4.0.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->declaredClasses = $declaredClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Warms up the cache.
|
||||
*
|
||||
* @param string $cacheDir The cache directory
|
||||
*/
|
||||
public function warmUp($cacheDir)
|
||||
{
|
||||
$classmap = $cacheDir.'/classes.map';
|
||||
|
||||
if (!is_file($classmap)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (file_exists($cacheDir.'/classes.php')) {
|
||||
return;
|
||||
}
|
||||
$declared = null !== $this->declaredClasses ? $this->declaredClasses : array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits());
|
||||
|
||||
ClassCollectionLoader::inline(include($classmap), $cacheDir.'/classes.php', $declared);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this warmer is optional or not.
|
||||
*
|
||||
* @return bool always true
|
||||
*/
|
||||
public function isOptional()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@ -95,14 +95,6 @@ class FrameworkExtension extends Extension
|
||||
|
||||
$loader->load('web.xml');
|
||||
$loader->load('services.xml');
|
||||
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$definition = $container->getDefinition('kernel.class_cache.cache_warmer');
|
||||
$definition->addTag('kernel.cache_warmer');
|
||||
// Ignore deprecation for PHP versions below 7.0
|
||||
$definition->setDeprecated(false);
|
||||
}
|
||||
|
||||
$loader->load('fragment_renderer.xml');
|
||||
|
||||
if (class_exists(Application::class)) {
|
||||
@ -288,46 +280,6 @@ class FrameworkExtension extends Extension
|
||||
->addTag('validator.constraint_validator');
|
||||
$container->registerForAutoconfiguration(ObjectInitializerInterface::class)
|
||||
->addTag('validator.initializer');
|
||||
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->addClassesToCompile(array(
|
||||
'Symfony\\Component\\Config\\ConfigCache',
|
||||
'Symfony\\Component\\Config\\FileLocator',
|
||||
|
||||
'Symfony\\Component\\Debug\\ErrorHandler',
|
||||
|
||||
'Symfony\\Component\\DependencyInjection\\ContainerAwareInterface',
|
||||
'Symfony\\Component\\DependencyInjection\\Container',
|
||||
|
||||
'Symfony\\Component\\EventDispatcher\\Event',
|
||||
|
||||
'Symfony\\Component\\HttpKernel\\EventListener\\ResponseListener',
|
||||
'Symfony\\Component\\HttpKernel\\EventListener\\RouterListener',
|
||||
'Symfony\\Component\\HttpKernel\\Bundle\\Bundle',
|
||||
'Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver',
|
||||
'Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolver',
|
||||
'Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadata',
|
||||
'Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadataFactory',
|
||||
'Symfony\\Component\\HttpKernel\\Event\\KernelEvent',
|
||||
'Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent',
|
||||
'Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent',
|
||||
'Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent',
|
||||
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent',
|
||||
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent',
|
||||
'Symfony\\Component\\HttpKernel\\HttpKernel',
|
||||
'Symfony\\Component\\HttpKernel\\KernelEvents',
|
||||
'Symfony\\Component\\HttpKernel\\Config\\FileLocator',
|
||||
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerNameParser',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver',
|
||||
|
||||
// Cannot be included because annotations will parse the big compiled class file
|
||||
// 'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',
|
||||
|
||||
// cannot be included as commands are discovered based on the path to this class via Reflection
|
||||
// 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -668,16 +620,6 @@ class FrameworkExtension extends Extension
|
||||
|
||||
$container->setParameter('request_listener.http_port', $config['http_port']);
|
||||
$container->setParameter('request_listener.https_port', $config['https_port']);
|
||||
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->addClassesToCompile(array(
|
||||
'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
|
||||
'Symfony\\Component\\Routing\\RequestContext',
|
||||
'Symfony\\Component\\Routing\\Router',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Routing\\RedirectableUrlMatcher',
|
||||
$container->findDefinition('router.default')->getClass(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -720,24 +662,6 @@ class FrameworkExtension extends Extension
|
||||
|
||||
$container->setParameter('session.save_path', $config['save_path']);
|
||||
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->addClassesToCompile(array(
|
||||
'Symfony\\Component\\HttpKernel\\EventListener\\SessionListener',
|
||||
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage',
|
||||
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\PhpBridgeSessionStorage',
|
||||
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeFileSessionHandler',
|
||||
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\AbstractProxy',
|
||||
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\SessionHandlerProxy',
|
||||
$container->getDefinition('session')->getClass(),
|
||||
));
|
||||
|
||||
if ($container->hasDefinition($config['storage_id'])) {
|
||||
$this->addClassesToCompile(array(
|
||||
$container->findDefinition('session.storage')->getClass(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$container->setParameter('session.metadata.update_threshold', $config['metadata_update_threshold']);
|
||||
}
|
||||
|
||||
@ -805,15 +729,6 @@ class FrameworkExtension extends Extension
|
||||
$container->setDefinition('templating.loader', $loaderCache);
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->addClassesToCompile(array(
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Templating\\GlobalVariables',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateReference',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateNameParser',
|
||||
$container->findDefinition('templating.locator')->getClass(),
|
||||
));
|
||||
}
|
||||
|
||||
$container->setParameter('templating.engines', $config['engines']);
|
||||
$engines = array_map(function ($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']);
|
||||
|
||||
@ -845,14 +760,6 @@ class FrameworkExtension extends Extension
|
||||
$container->setAlias('debug.templating.engine.php', 'templating.engine.php');
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->addClassesToCompile(array(
|
||||
'Symfony\\Component\\Templating\\Storage\\FileStorage',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Templating\\PhpEngine',
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Templating\\Loader\\FilesystemLoader',
|
||||
));
|
||||
}
|
||||
|
||||
if ($container->has('assets.packages')) {
|
||||
$container->getDefinition('templating.helper.assets')->replaceArgument(0, new Reference('assets.packages'));
|
||||
} else {
|
||||
@ -1185,13 +1092,6 @@ class FrameworkExtension extends Extension
|
||||
// Enable warmer only if PHP array is used for cache
|
||||
$definition = $container->findDefinition('annotations.cache_warmer');
|
||||
$definition->addTag('kernel.cache_warmer');
|
||||
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->addClassesToCompile(array(
|
||||
'Symfony\Component\Cache\Adapter\PhpArrayAdapter',
|
||||
'Symfony\Component\Cache\DoctrineProvider',
|
||||
));
|
||||
}
|
||||
} elseif ('file' === $config['cache']) {
|
||||
$cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']);
|
||||
|
||||
@ -1442,14 +1342,6 @@ class FrameworkExtension extends Extension
|
||||
$propertyAccessDefinition->setArguments(array(0, false));
|
||||
}
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->addClassesToCompile(array(
|
||||
'Symfony\Component\Cache\Adapter\ApcuAdapter',
|
||||
'Symfony\Component\Cache\Adapter\FilesystemAdapter',
|
||||
'Symfony\Component\Cache\CacheItem',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,18 +25,6 @@
|
||||
<argument type="collection" />
|
||||
</service>
|
||||
|
||||
<service id="kernel.class_cache.cache_warmer" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\ClassCacheCacheWarmer" public="true">
|
||||
<argument type="collection">
|
||||
<argument>Symfony\Component\HttpFoundation\ParameterBag</argument>
|
||||
<argument>Symfony\Component\HttpFoundation\HeaderBag</argument>
|
||||
<argument>Symfony\Component\HttpFoundation\FileBag</argument>
|
||||
<argument>Symfony\Component\HttpFoundation\ServerBag</argument>
|
||||
<argument>Symfony\Component\HttpFoundation\Request</argument>
|
||||
<argument>Symfony\Component\HttpKernel\Kernel</argument>
|
||||
</argument>
|
||||
<deprecated>The "%service_id%" option is deprecated since version 3.3, to be removed in 4.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="cache_clearer" class="Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer" public="true">
|
||||
<argument type="collection" />
|
||||
</service>
|
||||
|
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\CacheWarmer\ClassCacheCacheWarmer;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\DeclaredClass;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\WarmedClass;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class ClassCacheCacheWarmerTest extends TestCase
|
||||
{
|
||||
public function testWithDeclaredClasses()
|
||||
{
|
||||
$this->assertTrue(class_exists(WarmedClass::class, true));
|
||||
|
||||
$dir = sys_get_temp_dir();
|
||||
@unlink($dir.'/classes.php');
|
||||
file_put_contents($dir.'/classes.map', sprintf('<?php return %s;', var_export(array(WarmedClass::class), true)));
|
||||
|
||||
$warmer = new ClassCacheCacheWarmer(array(DeclaredClass::class));
|
||||
|
||||
$warmer->warmUp($dir);
|
||||
|
||||
$this->assertSame(<<<'EOTXT'
|
||||
<?php
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures
|
||||
{
|
||||
class WarmedClass extends DeclaredClass
|
||||
{
|
||||
}
|
||||
}
|
||||
EOTXT
|
||||
, file_get_contents($dir.'/classes.php')
|
||||
);
|
||||
|
||||
@unlink($dir.'/classes.map');
|
||||
@unlink($dir.'/classes.php');
|
||||
}
|
||||
}
|
@ -19,7 +19,6 @@
|
||||
"php": "^7.1.3",
|
||||
"ext-xml": "*",
|
||||
"symfony/cache": "~3.4|~4.0",
|
||||
"symfony/class-loader": "~3.4|~4.0",
|
||||
"symfony/dependency-injection": "~3.4|~4.0",
|
||||
"symfony/config": "~3.4|~4.0",
|
||||
"symfony/event-dispatcher": "~3.4|~4.0",
|
||||
|
@ -112,22 +112,6 @@ class SecurityExtension extends Extension
|
||||
|
||||
$container->registerForAutoconfiguration(VoterInterface::class)
|
||||
->addTag('security.voter');
|
||||
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
// add some required classes for compilation
|
||||
$this->addClassesToCompile(array(
|
||||
'Symfony\Component\Security\Http\Firewall',
|
||||
'Symfony\Component\Security\Core\User\UserProviderInterface',
|
||||
'Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager',
|
||||
'Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage',
|
||||
'Symfony\Component\Security\Core\Authorization\AccessDecisionManager',
|
||||
'Symfony\Component\Security\Core\Authorization\AuthorizationChecker',
|
||||
'Symfony\Component\Security\Core\Authorization\Voter\VoterInterface',
|
||||
'Symfony\Bundle\SecurityBundle\Security\FirewallConfig',
|
||||
'Symfony\Bundle\SecurityBundle\Security\FirewallContext',
|
||||
'Symfony\Component\HttpFoundation\RequestMatcher',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private function aclLoad($config, ContainerBuilder $container)
|
||||
@ -204,12 +188,6 @@ class SecurityExtension extends Extension
|
||||
return;
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->addClassesToCompile(array(
|
||||
'Symfony\\Component\\Security\\Http\\AccessMap',
|
||||
));
|
||||
}
|
||||
|
||||
foreach ($config['access_control'] as $access) {
|
||||
$matcher = $this->createRequestMatcher(
|
||||
$container,
|
||||
|
@ -148,19 +148,6 @@ class TwigExtension extends Extension
|
||||
->addTag('twig.extension');
|
||||
$container->registerForAutoconfiguration(\Twig_LoaderInterface::class)
|
||||
->addTag('twig.loader');
|
||||
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->addClassesToCompile(array(
|
||||
'Twig_Environment',
|
||||
'Twig_Extension',
|
||||
'Twig_Extension_Core',
|
||||
'Twig_Extension_Escaper',
|
||||
'Twig_Extension_Optimizer',
|
||||
'Twig_LoaderInterface',
|
||||
'Twig_Markup',
|
||||
'Twig_Template',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private function getBundleHierarchy(ContainerBuilder $container)
|
||||
|
3
src/Symfony/Component/ClassLoader/.gitignore
vendored
3
src/Symfony/Component/ClassLoader/.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
@ -1,145 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ApcClassLoader class is deprecated since version 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* ApcClassLoader implements a wrapping autoloader cached in APC for PHP 5.3.
|
||||
*
|
||||
* It expects an object implementing a findFile method to find the file. This
|
||||
* allows using it as a wrapper around the other loaders of the component (the
|
||||
* ClassLoader for instance) but also around any other autoloaders following
|
||||
* this convention (the Composer one for instance).
|
||||
*
|
||||
* // with a Symfony autoloader
|
||||
* use Symfony\Component\ClassLoader\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->addPrefix('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // or with a Composer autoloader
|
||||
* use Composer\Autoload\ClassLoader;
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* $cachedLoader = new ApcClassLoader('my_prefix', $loader);
|
||||
*
|
||||
* // activate the cached autoloader
|
||||
* $cachedLoader->register();
|
||||
*
|
||||
* // eventually deactivate the non-cached loader if it was registered previously
|
||||
* // to be sure to use the cached one.
|
||||
* $loader->unregister();
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0. Use `composer install --apcu-autoloader` instead.
|
||||
*/
|
||||
class ApcClassLoader
|
||||
{
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* A class loader object that implements the findFile() method.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $decorated;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $prefix The APC namespace prefix to use
|
||||
* @param object $decorated A class loader object that implements the findFile() method
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct($prefix, $decorated)
|
||||
{
|
||||
if (!function_exists('apcu_fetch')) {
|
||||
throw new \RuntimeException('Unable to use ApcClassLoader as APC is not installed.');
|
||||
}
|
||||
|
||||
if (!method_exists($decorated, 'findFile')) {
|
||||
throw new \InvalidArgumentException('The class finder must implement a "findFile" method.');
|
||||
}
|
||||
|
||||
$this->prefix = $prefix;
|
||||
$this->decorated = $decorated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return bool|null True, if loaded
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
require $file;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a file by class name while caching lookups to APC.
|
||||
*
|
||||
* @param string $class A class name to resolve to file
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
$file = apcu_fetch($this->prefix.$class, $success);
|
||||
|
||||
if (!$success) {
|
||||
apcu_store($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null);
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes through all unknown calls onto the decorated object.
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
return call_user_func_array(array($this->decorated, $method), $args);
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
3.3.0
|
||||
-----
|
||||
|
||||
* deprecated the component: use Composer instead
|
||||
|
||||
3.0.0
|
||||
-----
|
||||
|
||||
* The DebugClassLoader class has been removed
|
||||
* The DebugUniversalClassLoader class has been removed
|
||||
* The UniversalClassLoader class has been removed
|
||||
* The ApcUniversalClassLoader class has been removed
|
||||
|
||||
2.4.0
|
||||
-----
|
||||
|
||||
* deprecated the UniversalClassLoader in favor of the ClassLoader class instead
|
||||
* deprecated the ApcUniversalClassLoader in favor of the ApcClassLoader class instead
|
||||
* deprecated the DebugUniversalClassLoader in favor of the DebugClassLoader class from the Debug component
|
||||
* deprecated the DebugClassLoader as it has been moved to the Debug component instead
|
||||
|
||||
2.3.0
|
||||
-----
|
||||
|
||||
* added a WinCacheClassLoader for WinCache
|
||||
|
||||
2.1.0
|
||||
-----
|
||||
|
||||
* added a DebugClassLoader able to wrap any autoloader providing a findFile
|
||||
method
|
||||
* added a new ApcClassLoader and XcacheClassLoader using composition to wrap
|
||||
other loaders
|
||||
* added a new ClassLoader which does not distinguish between namespaced and
|
||||
pear-like classes (as the PEAR convention is a subset of PSR-0) and
|
||||
supports using Composer's namespace maps
|
||||
* added a class map generator
|
||||
* added support for loading globally-installed PEAR packages
|
@ -1,450 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
if (PHP_VERSION_ID >= 70000) {
|
||||
@trigger_error('The '.__NAMESPACE__.'\ClassCollectionLoader class is deprecated since version 3.3 and will be removed in 4.0.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
/**
|
||||
* ClassCollectionLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0.
|
||||
*/
|
||||
class ClassCollectionLoader
|
||||
{
|
||||
private static $loaded;
|
||||
private static $seen;
|
||||
private static $useTokenizer = true;
|
||||
|
||||
/**
|
||||
* Loads a list of classes and caches them in one big file.
|
||||
*
|
||||
* @param array $classes An array of classes to load
|
||||
* @param string $cacheDir A cache directory
|
||||
* @param string $name The cache name prefix
|
||||
* @param bool $autoReload Whether to flush the cache when the cache is stale or not
|
||||
* @param bool $adaptive Whether to remove already declared classes or not
|
||||
* @param string $extension File extension of the resulting file
|
||||
*
|
||||
* @throws \InvalidArgumentException When class can't be loaded
|
||||
*/
|
||||
public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = false, $extension = '.php')
|
||||
{
|
||||
// each $name can only be loaded once per PHP process
|
||||
if (isset(self::$loaded[$name])) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::$loaded[$name] = true;
|
||||
|
||||
if ($adaptive) {
|
||||
$declared = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits());
|
||||
|
||||
// don't include already declared classes
|
||||
$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);
|
||||
}
|
||||
|
||||
$classes = array_unique($classes);
|
||||
|
||||
// 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));
|
||||
}
|
||||
$cacheDir = rtrim(realpath($cacheDir) ?: $cacheDir, '/'.DIRECTORY_SEPARATOR);
|
||||
$cache = $cacheDir.'/'.$name.$extension;
|
||||
|
||||
// auto-reload
|
||||
$reload = false;
|
||||
if ($autoReload) {
|
||||
$metadata = $cache.'.meta';
|
||||
if (!is_file($metadata) || !is_file($cache)) {
|
||||
$reload = true;
|
||||
} else {
|
||||
$time = filemtime($cache);
|
||||
$meta = unserialize(file_get_contents($metadata));
|
||||
|
||||
sort($meta[1]);
|
||||
sort($classes);
|
||||
|
||||
if ($meta[1] != $classes) {
|
||||
$reload = true;
|
||||
} else {
|
||||
foreach ($meta[0] as $resource) {
|
||||
if (!is_file($resource) || filemtime($resource) > $time) {
|
||||
$reload = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$reload && file_exists($cache)) {
|
||||
require_once $cache;
|
||||
|
||||
return;
|
||||
}
|
||||
if (!$adaptive) {
|
||||
$declared = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits());
|
||||
}
|
||||
|
||||
$files = self::inline($classes, $cache, $declared);
|
||||
|
||||
if ($autoReload) {
|
||||
// save the resources
|
||||
self::writeCacheFile($metadata, serialize(array(array_values($files), $classes)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a file where classes and their parents are inlined.
|
||||
*
|
||||
* @param array $classes An array of classes to load
|
||||
* @param string $cache The file where classes are inlined
|
||||
* @param array $excluded An array of classes that won't be inlined
|
||||
*
|
||||
* @return array The source map of inlined classes, with classes as keys and files as values
|
||||
*
|
||||
* @throws \RuntimeException When class can't be loaded
|
||||
*/
|
||||
public static function inline($classes, $cache, array $excluded)
|
||||
{
|
||||
$declared = array();
|
||||
foreach (self::getOrderedClasses($excluded) as $class) {
|
||||
$declared[$class->getName()] = true;
|
||||
}
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
$spacesRegex = '(?:\s*+(?:(?:\#|//)[^\n]*+\n|/\*(?:(?<!\*/).)++)?+)*+';
|
||||
$dontInlineRegex = <<<REGEX
|
||||
'(?:
|
||||
^<\?php\s.declare.\(.strict_types.=.1.\).;
|
||||
| \b__halt_compiler.\(.\)
|
||||
| \b__(?:DIR|FILE)__\b
|
||||
)'isx
|
||||
REGEX;
|
||||
$dontInlineRegex = str_replace('.', $spacesRegex, $dontInlineRegex);
|
||||
|
||||
$cacheDir = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $cacheDir));
|
||||
$files = array();
|
||||
$content = '';
|
||||
foreach (self::getOrderedClasses($classes) as $class) {
|
||||
if (isset($declared[$class->getName()])) {
|
||||
continue;
|
||||
}
|
||||
$declared[$class->getName()] = true;
|
||||
|
||||
$files[$class->getName()] = $file = $class->getFileName();
|
||||
$c = file_get_contents($file);
|
||||
|
||||
if (preg_match($dontInlineRegex, $c)) {
|
||||
$file = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $file));
|
||||
|
||||
for ($i = 0; isset($file[$i], $cacheDir[$i]); ++$i) {
|
||||
if ($file[$i] !== $cacheDir[$i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (1 >= $i) {
|
||||
$file = var_export(implode('/', $file), true);
|
||||
} else {
|
||||
$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);
|
||||
|
||||
// fakes namespace declaration for global code
|
||||
if (!$class->inNamespace()) {
|
||||
$c = "\nnamespace\n{\n".$c."\n}\n";
|
||||
}
|
||||
|
||||
$c = self::fixNamespaceDeclarations('<?php '.$c);
|
||||
$c = preg_replace('/^\s*<\?php/', '', $c);
|
||||
}
|
||||
|
||||
$content .= $c;
|
||||
}
|
||||
self::writeCacheFile($cache, '<?php '.$content);
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds brackets around each namespace if it's not already the case.
|
||||
*
|
||||
* @param string $source Namespace string
|
||||
*
|
||||
* @return string Namespaces with brackets
|
||||
*/
|
||||
public static function fixNamespaceDeclarations($source)
|
||||
{
|
||||
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";
|
||||
}
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
$rawChunk = '';
|
||||
$output = '';
|
||||
$inNamespace = false;
|
||||
$tokens = token_get_all($source);
|
||||
|
||||
for ($i = 0; isset($tokens[$i]); ++$i) {
|
||||
$token = $tokens[$i];
|
||||
if (!isset($token[1]) || 'b"' === $token) {
|
||||
$rawChunk .= $token;
|
||||
} elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
|
||||
// strip comments
|
||||
continue;
|
||||
} elseif (T_NAMESPACE === $token[0]) {
|
||||
if ($inNamespace) {
|
||||
$rawChunk .= "}\n";
|
||||
}
|
||||
$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))) {
|
||||
$rawChunk .= $tokens[$i][1];
|
||||
}
|
||||
if ('{' === $tokens[$i]) {
|
||||
$inNamespace = false;
|
||||
--$i;
|
||||
} else {
|
||||
$rawChunk = rtrim($rawChunk)."\n{";
|
||||
$inNamespace = true;
|
||||
}
|
||||
} elseif (T_START_HEREDOC === $token[0]) {
|
||||
$output .= self::compressCode($rawChunk).$token[1];
|
||||
do {
|
||||
$token = $tokens[++$i];
|
||||
$output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token;
|
||||
} while ($token[0] !== T_END_HEREDOC);
|
||||
$output .= "\n";
|
||||
$rawChunk = '';
|
||||
} elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) {
|
||||
$output .= self::compressCode($rawChunk).$token[1];
|
||||
$rawChunk = '';
|
||||
} else {
|
||||
$rawChunk .= $token[1];
|
||||
}
|
||||
}
|
||||
|
||||
if ($inNamespace) {
|
||||
$rawChunk .= "}\n";
|
||||
}
|
||||
|
||||
$output .= self::compressCode($rawChunk);
|
||||
|
||||
if (PHP_VERSION_ID >= 70000) {
|
||||
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
|
||||
unset($tokens, $rawChunk);
|
||||
gc_mem_caches();
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is only useful for testing.
|
||||
*/
|
||||
public static function enableTokenizer($bool)
|
||||
{
|
||||
self::$useTokenizer = (bool) $bool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips leading & trailing ws, multiple EOL, multiple ws.
|
||||
*
|
||||
* @param string $code Original PHP code
|
||||
*
|
||||
* @return string compressed code
|
||||
*/
|
||||
private static function compressCode($code)
|
||||
{
|
||||
return preg_replace(
|
||||
array('/^\s+/m', '/\s+$/m', '/([\n\r]+ *[\n\r]+)+/', '/[ \t]+/'),
|
||||
array('', '', "\n", ' '),
|
||||
$code
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a cache file.
|
||||
*
|
||||
* @param string $file Filename
|
||||
* @param string $content Temporary file content
|
||||
*
|
||||
* @throws \RuntimeException when a cache file cannot be written
|
||||
*/
|
||||
private static function writeCacheFile($file, $content)
|
||||
{
|
||||
$dir = dirname($file);
|
||||
if (!is_writable($dir)) {
|
||||
throw new \RuntimeException(sprintf('Cache directory "%s" is not writable.', $dir));
|
||||
}
|
||||
|
||||
$tmpFile = tempnam($dir, basename($file));
|
||||
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
|
||||
@chmod($file, 0666 & ~umask());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an ordered array of passed classes including all their dependencies.
|
||||
*
|
||||
* @param array $classes
|
||||
*
|
||||
* @return \ReflectionClass[] An array of sorted \ReflectionClass instances (dependencies added if needed)
|
||||
*
|
||||
* @throws \InvalidArgumentException When a class can't be loaded
|
||||
*/
|
||||
private static function getOrderedClasses(array $classes)
|
||||
{
|
||||
$map = array();
|
||||
self::$seen = array();
|
||||
foreach ($classes as $class) {
|
||||
try {
|
||||
$reflectionClass = new \ReflectionClass($class);
|
||||
} catch (\ReflectionException $e) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
|
||||
}
|
||||
|
||||
$map = array_merge($map, self::getClassHierarchy($reflectionClass));
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
private static function getClassHierarchy(\ReflectionClass $class)
|
||||
{
|
||||
if (isset(self::$seen[$class->getName()])) {
|
||||
return array();
|
||||
}
|
||||
|
||||
self::$seen[$class->getName()] = true;
|
||||
|
||||
$classes = array($class);
|
||||
$parent = $class;
|
||||
while (($parent = $parent->getParentClass()) && $parent->isUserDefined() && !isset(self::$seen[$parent->getName()])) {
|
||||
self::$seen[$parent->getName()] = true;
|
||||
|
||||
array_unshift($classes, $parent);
|
||||
}
|
||||
|
||||
$traits = array();
|
||||
|
||||
foreach ($classes as $c) {
|
||||
foreach (self::resolveDependencies(self::computeTraitDeps($c), $c) as $trait) {
|
||||
if ($trait !== $c) {
|
||||
$traits[] = $trait;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge(self::getInterfaces($class), $traits, $classes);
|
||||
}
|
||||
|
||||
private static function getInterfaces(\ReflectionClass $class)
|
||||
{
|
||||
$classes = array();
|
||||
|
||||
foreach ($class->getInterfaces() as $interface) {
|
||||
$classes = array_merge($classes, self::getInterfaces($interface));
|
||||
}
|
||||
|
||||
if ($class->isUserDefined() && $class->isInterface() && !isset(self::$seen[$class->getName()])) {
|
||||
self::$seen[$class->getName()] = true;
|
||||
|
||||
$classes[] = $class;
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
private static function computeTraitDeps(\ReflectionClass $class)
|
||||
{
|
||||
$traits = $class->getTraits();
|
||||
$deps = array($class->getName() => $traits);
|
||||
while ($trait = array_pop($traits)) {
|
||||
if ($trait->isUserDefined() && !isset(self::$seen[$trait->getName()])) {
|
||||
self::$seen[$trait->getName()] = true;
|
||||
$traitDeps = $trait->getTraits();
|
||||
$deps[$trait->getName()] = $traitDeps;
|
||||
$traits = array_merge($traits, $traitDeps);
|
||||
}
|
||||
}
|
||||
|
||||
return $deps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dependencies resolution.
|
||||
*
|
||||
* This function does not check for circular dependencies as it should never
|
||||
* occur with PHP traits.
|
||||
*
|
||||
* @param array $tree The dependency tree
|
||||
* @param \ReflectionClass $node The node
|
||||
* @param \ArrayObject $resolved An array of already resolved dependencies
|
||||
* @param \ArrayObject $unresolved An array of dependencies to be resolved
|
||||
*
|
||||
* @return \ArrayObject The dependencies for the given node
|
||||
*
|
||||
* @throws \RuntimeException if a circular dependency is detected
|
||||
*/
|
||||
private static function resolveDependencies(array $tree, $node, \ArrayObject $resolved = null, \ArrayObject $unresolved = null)
|
||||
{
|
||||
if (null === $resolved) {
|
||||
$resolved = new \ArrayObject();
|
||||
}
|
||||
if (null === $unresolved) {
|
||||
$unresolved = new \ArrayObject();
|
||||
}
|
||||
$nodeName = $node->getName();
|
||||
|
||||
if (isset($tree[$nodeName])) {
|
||||
$unresolved[$nodeName] = $node;
|
||||
foreach ($tree[$nodeName] as $dependency) {
|
||||
if (!$resolved->offsetExists($dependency->getName())) {
|
||||
self::resolveDependencies($tree, $dependency, $resolved, $unresolved);
|
||||
}
|
||||
}
|
||||
$resolved[$nodeName] = $node;
|
||||
unset($unresolved[$nodeName]);
|
||||
}
|
||||
|
||||
return $resolved;
|
||||
}
|
||||
}
|
@ -1,207 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ClassLoader class is deprecated since version 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* ClassLoader implements an PSR-0 class loader.
|
||||
*
|
||||
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
|
||||
*
|
||||
* $loader = new ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->addPrefix('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (e.g. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0.
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
private $prefixes = array();
|
||||
private $fallbackDirs = array();
|
||||
private $useIncludePath = false;
|
||||
|
||||
/**
|
||||
* Returns prefixes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPrefixes()
|
||||
{
|
||||
return $this->prefixes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns fallback directories.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds prefixes.
|
||||
*
|
||||
* @param array $prefixes Prefixes to add
|
||||
*/
|
||||
public function addPrefixes(array $prefixes)
|
||||
{
|
||||
foreach ($prefixes as $prefix => $path) {
|
||||
$this->addPrefix($prefix, $path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of classes.
|
||||
*
|
||||
* @param string $prefix The classes prefix
|
||||
* @param array|string $paths The location(s) of the classes
|
||||
*/
|
||||
public function addPrefix($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
foreach ((array) $paths as $path) {
|
||||
$this->fallbackDirs[] = $path;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (isset($this->prefixes[$prefix])) {
|
||||
if (is_array($paths)) {
|
||||
$this->prefixes[$prefix] = array_unique(array_merge(
|
||||
$this->prefixes[$prefix],
|
||||
$paths
|
||||
));
|
||||
} elseif (!in_array($paths, $this->prefixes[$prefix])) {
|
||||
$this->prefixes[$prefix][] = $paths;
|
||||
}
|
||||
} else {
|
||||
$this->prefixes[$prefix] = array_unique((array) $paths);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = (bool) $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return bool|null True, if loaded
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
require $file;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|null The path, if found
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)).DIRECTORY_SEPARATOR;
|
||||
$className = substr($class, $pos + 1);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$classPath = null;
|
||||
$className = $class;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->fallbackDirs as $dir) {
|
||||
if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
|
||||
return $dir.DIRECTORY_SEPARATOR.$classPath;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ClassMapGenerator class is deprecated since version 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* ClassMapGenerator.
|
||||
*
|
||||
* @author Gyula Sallai <salla016@gmail.com>
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0.
|
||||
*/
|
||||
class ClassMapGenerator
|
||||
{
|
||||
/**
|
||||
* Generate a class map file.
|
||||
*
|
||||
* @param array|string $dirs Directories or a single path to search in
|
||||
* @param string $file The name of the class map file
|
||||
*/
|
||||
public static function dump($dirs, $file)
|
||||
{
|
||||
$dirs = (array) $dirs;
|
||||
$maps = array();
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
$maps = array_merge($maps, static::createMap($dir));
|
||||
}
|
||||
|
||||
file_put_contents($file, sprintf('<?php return %s;', var_export($maps, true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate over all files in the given directory searching for classes.
|
||||
*
|
||||
* @param \Iterator|string $dir The directory to search in or an iterator
|
||||
*
|
||||
* @return array A class map array
|
||||
*/
|
||||
public static function createMap($dir)
|
||||
{
|
||||
if (is_string($dir)) {
|
||||
$dir = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
|
||||
}
|
||||
|
||||
$map = array();
|
||||
|
||||
foreach ($dir as $file) {
|
||||
if (!$file->isFile()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = $file->getRealPath() ?: $file->getPathname();
|
||||
|
||||
if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$classes = self::findClasses($path);
|
||||
|
||||
if (PHP_VERSION_ID >= 70000) {
|
||||
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
|
||||
gc_mem_caches();
|
||||
}
|
||||
|
||||
foreach ($classes as $class) {
|
||||
$map[$class] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the classes in the given file.
|
||||
*
|
||||
* @param string $path The file to check
|
||||
*
|
||||
* @return array The found classes
|
||||
*/
|
||||
private static function findClasses($path)
|
||||
{
|
||||
$contents = file_get_contents($path);
|
||||
$tokens = token_get_all($contents);
|
||||
|
||||
$classes = array();
|
||||
|
||||
$namespace = '';
|
||||
for ($i = 0; isset($tokens[$i]); ++$i) {
|
||||
$token = $tokens[$i];
|
||||
|
||||
if (!isset($token[1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = '';
|
||||
|
||||
switch ($token[0]) {
|
||||
case T_NAMESPACE:
|
||||
$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))) {
|
||||
$namespace .= $tokens[$i][1];
|
||||
}
|
||||
}
|
||||
$namespace .= '\\';
|
||||
break;
|
||||
case T_CLASS:
|
||||
case T_INTERFACE:
|
||||
case T_TRAIT:
|
||||
// Skip usage of ::class constant
|
||||
$isClassConstant = false;
|
||||
for ($j = $i - 1; $j > 0; --$j) {
|
||||
if (!isset($tokens[$j][1])) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (T_DOUBLE_COLON === $tokens[$j][0]) {
|
||||
$isClassConstant = true;
|
||||
break;
|
||||
} elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($isClassConstant) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Find the classname
|
||||
while (isset($tokens[++$i][1])) {
|
||||
$t = $tokens[$i];
|
||||
if (T_STRING === $t[0]) {
|
||||
$class .= $t[1];
|
||||
} elseif ('' !== $class && T_WHITESPACE === $t[0]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$classes[] = ltrim($namespace.$class, '\\');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
Copyright (c) 2004-2017 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
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\MapClassLoader class is deprecated since version 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* A class loader that uses a mapping file to look up paths.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0.
|
||||
*/
|
||||
class MapClassLoader
|
||||
{
|
||||
private $map = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $map A map where keys are classes and values the absolute file path
|
||||
*/
|
||||
public function __construct(array $map)
|
||||
{
|
||||
$this->map = $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if (isset($this->map[$class])) {
|
||||
require $this->map[$class];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|null The path, if found
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
if (isset($this->map[$class])) {
|
||||
return $this->map[$class];
|
||||
}
|
||||
}
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\Psr4ClassLoader class is deprecated since version 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* A PSR-4 compatible class loader.
|
||||
*
|
||||
* See http://www.php-fig.org/psr/psr-4/
|
||||
*
|
||||
* @author Alexander M. Turek <me@derrabus.de>
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0.
|
||||
*/
|
||||
class Psr4ClassLoader
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $prefixes = array();
|
||||
|
||||
/**
|
||||
* @param string $prefix
|
||||
* @param string $baseDir
|
||||
*/
|
||||
public function addPrefix($prefix, $baseDir)
|
||||
{
|
||||
$prefix = trim($prefix, '\\').'\\';
|
||||
$baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
||||
$this->prefixes[] = array($prefix, $baseDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
$class = ltrim($class, '\\');
|
||||
|
||||
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';
|
||||
if (file_exists($file)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
$file = $this->findFile($class);
|
||||
if (null !== $file) {
|
||||
require $file;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this instance from the registered autoloaders.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
ClassLoader Component
|
||||
=====================
|
||||
|
||||
The ClassLoader component provides tools to autoload your classes and cache
|
||||
their locations for performance.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Documentation](https://symfony.com/doc/current/components/class_loader/index.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)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
@ -1,200 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\ClassLoader\ApcClassLoader;
|
||||
use Symfony\Component\ClassLoader\ClassLoader;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class ApcClassLoaderTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!(ini_get('apc.enabled') && ini_get('apc.enable_cli'))) {
|
||||
$this->markTestSkipped('The apc extension is not enabled.');
|
||||
} else {
|
||||
apcu_clear_cache();
|
||||
}
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
|
||||
apcu_clear_cache();
|
||||
}
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefix('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
|
||||
$loader = new ApcClassLoader('test.prefix.', $loader);
|
||||
|
||||
$this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apcu_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassTests
|
||||
*/
|
||||
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 = new ApcClassLoader('test.prefix.', $loader);
|
||||
$loader->loadClass($testClassName);
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
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'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassFromFallbackTests
|
||||
*/
|
||||
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 = new ApcClassLoader('test.prefix.fallback', $loader);
|
||||
$loader->loadClass($testClassName);
|
||||
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
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'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassNamespaceCollisionTests
|
||||
*/
|
||||
public function testLoadClassNamespaceCollision($namespaces, $className, $message)
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefixes($namespaces);
|
||||
|
||||
$loader = new ApcClassLoader('test.prefix.collision.', $loader);
|
||||
$loader->loadClass($className);
|
||||
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
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',
|
||||
),
|
||||
'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\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\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\Bar',
|
||||
'->loadClass() loads NamespaceCollision\A\B\Bar from beta.',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassPrefixCollisionTests
|
||||
*/
|
||||
public function testLoadClassPrefixCollision($prefixes, $className, $message)
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefixes($prefixes);
|
||||
|
||||
$loader = new ApcClassLoader('test.prefix.collision.', $loader);
|
||||
$loader->loadClass($className);
|
||||
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
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',
|
||||
),
|
||||
'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_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_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_Bar',
|
||||
'->loadClass() loads ApcPrefixCollision_A_B_Bar from beta.',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,319 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\ClassLoader\ClassCollectionLoader;
|
||||
use Symfony\Component\ClassLoader\Tests\Fixtures\DeclaredClass;
|
||||
use Symfony\Component\ClassLoader\Tests\Fixtures\WarmedClass;
|
||||
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/GInterface.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/CInterface.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/B.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/A.php';
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class ClassCollectionLoaderTest extends TestCase
|
||||
{
|
||||
public function testTraitDependencies()
|
||||
{
|
||||
require_once __DIR__.'/Fixtures/deps/traits.php';
|
||||
|
||||
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
|
||||
$m = $r->getMethod('getOrderedClasses');
|
||||
$m->setAccessible(true);
|
||||
|
||||
$ordered = $m->invoke(null, array('CTFoo'));
|
||||
|
||||
$this->assertEquals(
|
||||
array('TD', 'TC', 'TB', 'TA', 'TZ', 'CTFoo'),
|
||||
array_map(function ($class) { return $class->getName(); }, $ordered)
|
||||
);
|
||||
|
||||
$ordered = $m->invoke(null, array('CTBar'));
|
||||
|
||||
$this->assertEquals(
|
||||
array('TD', 'TZ', 'TC', 'TB', 'TA', 'CTBar'),
|
||||
array_map(function ($class) { return $class->getName(); }, $ordered)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDifferentOrders
|
||||
*/
|
||||
public function testClassReordering(array $classes)
|
||||
{
|
||||
$expected = array(
|
||||
'ClassesWithParents\\GInterface',
|
||||
'ClassesWithParents\\CInterface',
|
||||
'ClassesWithParents\\B',
|
||||
'ClassesWithParents\\A',
|
||||
);
|
||||
|
||||
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
|
||||
$m = $r->getMethod('getOrderedClasses');
|
||||
$m->setAccessible(true);
|
||||
|
||||
$ordered = $m->invoke(null, $classes);
|
||||
|
||||
$this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered));
|
||||
}
|
||||
|
||||
public function getDifferentOrders()
|
||||
{
|
||||
return array(
|
||||
array(array(
|
||||
'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',
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDifferentOrdersForTraits
|
||||
*/
|
||||
public function testClassWithTraitsReordering(array $classes)
|
||||
{
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/ATrait.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/BTrait.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/D.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/E.php';
|
||||
|
||||
$expected = array(
|
||||
'ClassesWithParents\\GInterface',
|
||||
'ClassesWithParents\\CInterface',
|
||||
'ClassesWithParents\\ATrait',
|
||||
'ClassesWithParents\\BTrait',
|
||||
'ClassesWithParents\\CTrait',
|
||||
'ClassesWithParents\\B',
|
||||
'ClassesWithParents\\A',
|
||||
'ClassesWithParents\\D',
|
||||
'ClassesWithParents\\E',
|
||||
);
|
||||
|
||||
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
|
||||
$m = $r->getMethod('getOrderedClasses');
|
||||
$m->setAccessible(true);
|
||||
|
||||
$ordered = $m->invoke(null, $classes);
|
||||
|
||||
$this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered));
|
||||
}
|
||||
|
||||
public function getDifferentOrdersForTraits()
|
||||
{
|
||||
return array(
|
||||
array(array(
|
||||
'ClassesWithParents\\E',
|
||||
'ClassesWithParents\\ATrait',
|
||||
)),
|
||||
array(array(
|
||||
'ClassesWithParents\\E',
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
public function testFixClassWithTraitsOrdering()
|
||||
{
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/F.php';
|
||||
require_once __DIR__.'/Fixtures/ClassesWithParents/G.php';
|
||||
|
||||
$classes = array(
|
||||
'ClassesWithParents\\F',
|
||||
'ClassesWithParents\\G',
|
||||
);
|
||||
|
||||
$expected = array(
|
||||
'ClassesWithParents\\CTrait',
|
||||
'ClassesWithParents\\F',
|
||||
'ClassesWithParents\\G',
|
||||
);
|
||||
|
||||
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
|
||||
$m = $r->getMethod('getOrderedClasses');
|
||||
$m->setAccessible(true);
|
||||
|
||||
$ordered = $m->invoke(null, $classes);
|
||||
|
||||
$this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFixNamespaceDeclarationsData
|
||||
*/
|
||||
public function testFixNamespaceDeclarations($source, $expected)
|
||||
{
|
||||
$this->assertEquals('<?php '.$expected, ClassCollectionLoader::fixNamespaceDeclarations('<?php '.$source));
|
||||
}
|
||||
|
||||
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}"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFixNamespaceDeclarationsDataWithoutTokenizer
|
||||
*/
|
||||
public function testFixNamespaceDeclarationsWithoutTokenizer($source, $expected)
|
||||
{
|
||||
ClassCollectionLoader::enableTokenizer(false);
|
||||
$this->assertEquals('<?php '.$expected, ClassCollectionLoader::fixNamespaceDeclarations('<?php '.$source));
|
||||
ClassCollectionLoader::enableTokenizer(true);
|
||||
}
|
||||
|
||||
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"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testUnableToLoadClassException()
|
||||
{
|
||||
if (is_file($file = sys_get_temp_dir().'/foo.php')) {
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
ClassCollectionLoader::load(array('SomeNotExistingClass'), sys_get_temp_dir(), 'foo', false);
|
||||
}
|
||||
|
||||
public function testCommentStripping()
|
||||
{
|
||||
if (is_file($file = __DIR__.'/bar.php')) {
|
||||
unlink($file);
|
||||
}
|
||||
spl_autoload_register($r = function ($class) {
|
||||
if (0 === strpos($class, 'Namespaced') || 0 === strpos($class, 'Pearlike_')) {
|
||||
@require_once __DIR__.'/Fixtures/'.str_replace(array('\\', '_'), '/', $class).'.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'),
|
||||
__DIR__,
|
||||
'bar',
|
||||
false
|
||||
);
|
||||
|
||||
spl_autoload_unregister($r);
|
||||
|
||||
$this->assertEquals(<<<'EOF'
|
||||
namespace Namespaced
|
||||
{
|
||||
class WithComments
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
||||
$string ='string should not be modified {$string}';
|
||||
$heredoc = (<<<HD
|
||||
|
||||
|
||||
Heredoc should not be modified {$string}
|
||||
|
||||
|
||||
HD
|
||||
);
|
||||
$nowdoc =<<<'ND'
|
||||
|
||||
|
||||
Nowdoc should not be modified {$string}
|
||||
|
||||
|
||||
ND
|
||||
;
|
||||
}
|
||||
namespace
|
||||
{
|
||||
class Pearlike_WithComments
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
||||
}
|
||||
namespace {require __DIR__.'/Fixtures/Namespaced/WithDirMagic.php';}
|
||||
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))
|
||||
);
|
||||
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
public function testInline()
|
||||
{
|
||||
$this->assertTrue(class_exists(WarmedClass::class, true));
|
||||
|
||||
@unlink($cache = sys_get_temp_dir().'/inline.php');
|
||||
|
||||
$classes = array(WarmedClass::class);
|
||||
$excluded = array(DeclaredClass::class);
|
||||
|
||||
ClassCollectionLoader::inline($classes, $cache, $excluded);
|
||||
|
||||
$this->assertSame(<<<'EOTXT'
|
||||
<?php
|
||||
namespace Symfony\Component\ClassLoader\Tests\Fixtures
|
||||
{
|
||||
interface WarmedInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
namespace Symfony\Component\ClassLoader\Tests\Fixtures
|
||||
{
|
||||
class WarmedClass extends DeclaredClass implements WarmedInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
EOTXT
|
||||
, file_get_contents($cache)
|
||||
);
|
||||
|
||||
unlink($cache);
|
||||
}
|
||||
}
|
@ -1,238 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\ClassLoader\ClassLoader;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
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');
|
||||
$prefixes = $loader->getPrefixes();
|
||||
$this->assertArrayHasKey('Foo', $prefixes);
|
||||
$this->assertArrayNotHasKey('Foo1', $prefixes);
|
||||
$this->assertArrayHasKey('Bar', $prefixes);
|
||||
$this->assertArrayHasKey('Bas', $prefixes);
|
||||
}
|
||||
|
||||
public function testGetFallbackDirs()
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefix(null, __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$loader->addPrefix(null, __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
||||
$fallback_dirs = $loader->getFallbackDirs();
|
||||
$this->assertCount(2, $fallback_dirs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassTests
|
||||
*/
|
||||
public function testLoadClass($className, $testClassName, $message)
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$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'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadNonexistentClassTests
|
||||
*/
|
||||
public function testLoadNonexistentClass($className, $testClassName, $message)
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$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'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testAddPrefixSingle()
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$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']);
|
||||
}
|
||||
|
||||
public function testAddPrefixesSingle()
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefixes(array('Foo' => array('foo', 'foo')));
|
||||
$loader->addPrefixes(array('Foo' => array('foo')));
|
||||
$prefixes = $loader->getPrefixes();
|
||||
$this->assertArrayHasKey('Foo', $prefixes);
|
||||
$this->assertCount(1, $prefixes['Foo'], print_r($prefixes, true));
|
||||
}
|
||||
|
||||
public function testAddPrefixMulti()
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefix('Foo', 'foo');
|
||||
$loader->addPrefix('Foo', 'bar');
|
||||
$prefixes = $loader->getPrefixes();
|
||||
$this->assertArrayHasKey('Foo', $prefixes);
|
||||
$this->assertCount(2, $prefixes['Foo']);
|
||||
$this->assertContains('foo', $prefixes['Foo']);
|
||||
$this->assertContains('bar', $prefixes['Foo']);
|
||||
}
|
||||
|
||||
public function testUseIncludePath()
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$this->assertFalse($loader->getUseIncludePath());
|
||||
|
||||
$this->assertNull($loader->findFile('Foo'));
|
||||
|
||||
$includePath = get_include_path();
|
||||
|
||||
$loader->setUseIncludePath(true);
|
||||
$this->assertTrue($loader->getUseIncludePath());
|
||||
|
||||
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'));
|
||||
|
||||
set_include_path($includePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassFromFallbackTests
|
||||
*/
|
||||
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->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'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadClassNamespaceCollisionTests
|
||||
*/
|
||||
public function testLoadClassNamespaceCollision($namespaces, $className, $message)
|
||||
{
|
||||
$loader = new ClassLoader();
|
||||
$loader->addPrefixes($namespaces);
|
||||
|
||||
$loader->loadClass($className);
|
||||
$this->assertTrue(class_exists($className), $message);
|
||||
}
|
||||
|
||||
public function getLoadClassNamespaceCollisionTests()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'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\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\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\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_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_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_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_Bar',
|
||||
'->loadClass() loads PrefixCollision_C_B_Bar from beta.',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\ClassLoader\ClassMapGenerator;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class ClassMapGeneratorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $workspace = null;
|
||||
|
||||
public function prepare_workspace()
|
||||
{
|
||||
$this->workspace = sys_get_temp_dir().'/'.microtime(true).'.'.mt_rand();
|
||||
mkdir($this->workspace, 0777, true);
|
||||
$this->workspace = realpath($this->workspace);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
*/
|
||||
private function clean($file)
|
||||
{
|
||||
if (is_dir($file) && !is_link($file)) {
|
||||
$dir = new \FilesystemIterator($file);
|
||||
foreach ($dir as $childFile) {
|
||||
$this->clean($childFile);
|
||||
}
|
||||
|
||||
rmdir($file);
|
||||
} else {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestCreateMapTests
|
||||
*/
|
||||
public function testDump($directory)
|
||||
{
|
||||
$this->prepare_workspace();
|
||||
|
||||
$file = $this->workspace.'/file';
|
||||
|
||||
$generator = new ClassMapGenerator();
|
||||
$generator->dump($directory, $file);
|
||||
$this->assertFileExists($file);
|
||||
|
||||
$this->clean($this->workspace);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestCreateMapTests
|
||||
*/
|
||||
public function testCreateMap($directory, $expected)
|
||||
{
|
||||
$this->assertEqualsNormalized($expected, ClassMapGenerator::createMap($directory));
|
||||
}
|
||||
|
||||
public function getTestCreateMapTests()
|
||||
{
|
||||
$data = array(
|
||||
array(__DIR__.'/Fixtures/Namespaced', array(
|
||||
'Namespaced\\Bar' => realpath(__DIR__).'/Fixtures/Namespaced/Bar.php',
|
||||
'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php',
|
||||
'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php',
|
||||
'Namespaced\\WithComments' => realpath(__DIR__).'/Fixtures/Namespaced/WithComments.php',
|
||||
'Namespaced\\WithStrictTypes' => realpath(__DIR__).'/Fixtures/Namespaced/WithStrictTypes.php',
|
||||
'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(
|
||||
'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(
|
||||
'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(
|
||||
'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',
|
||||
'Alpha\\A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Alpha\\B' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Beta\\A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'Beta\\B' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php',
|
||||
'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(
|
||||
'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(
|
||||
'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php',
|
||||
)),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function testCreateMapFinderSupport()
|
||||
{
|
||||
$finder = new \Symfony\Component\Finder\Finder();
|
||||
$finder->files()->in(__DIR__.'/Fixtures/beta/NamespaceCollision');
|
||||
|
||||
$this->assertEqualsNormalized(array(
|
||||
'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));
|
||||
}
|
||||
|
||||
protected function assertEqualsNormalized($expected, $actual, $message = null)
|
||||
{
|
||||
foreach ($expected as $ns => $path) {
|
||||
$expected[$ns] = str_replace('\\', '/', $path);
|
||||
}
|
||||
foreach ($actual as $ns => $path) {
|
||||
$actual[$ns] = str_replace('\\', '/', $path);
|
||||
}
|
||||
$this->assertEquals($expected, $actual, $message);
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\Namespaced;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\Namespaced;
|
||||
|
||||
class Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\Namespaced;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\Namespaced;
|
||||
|
||||
class FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Apc_Pearlike_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Apc_Pearlike_Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Apc_Pearlike_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class ApcPrefixCollision_A_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class ApcPrefixCollision_A_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\NamespaceCollision\A;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\NamespaceCollision\A;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class ApcPrefixCollision_A_B_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class ApcPrefixCollision_A_B_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\NamespaceCollision\A\B;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\NamespaceCollision\A\B;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Apc_Pearlike_FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Apc\Namespaced;
|
||||
|
||||
class FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class A extends B
|
||||
{
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
trait ATrait
|
||||
{
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class B implements CInterface
|
||||
{
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
trait BTrait
|
||||
{
|
||||
use ATrait;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
interface CInterface extends GInterface
|
||||
{
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
trait CTrait
|
||||
{
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class D extends A
|
||||
{
|
||||
use BTrait;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class E extends D
|
||||
{
|
||||
use CTrait;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class F
|
||||
{
|
||||
use CTrait;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
class G
|
||||
{
|
||||
use CTrait;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ClassesWithParents;
|
||||
|
||||
interface GInterface
|
||||
{
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests\Fixtures;
|
||||
|
||||
class DeclaredClass implements DeclaredInterface
|
||||
{
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests\Fixtures;
|
||||
|
||||
interface DeclaredInterface
|
||||
{
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class WithComments
|
||||
{
|
||||
/** @Boolean */
|
||||
public static $loaded = true;
|
||||
}
|
||||
|
||||
$string = 'string should not be modified {$string}';
|
||||
|
||||
$heredoc = (<<<HD
|
||||
|
||||
|
||||
Heredoc should not be modified {$string}
|
||||
|
||||
|
||||
HD
|
||||
);
|
||||
|
||||
$nowdoc = <<<'ND'
|
||||
|
||||
|
||||
Nowdoc should not be modified {$string}
|
||||
|
||||
|
||||
ND;
|
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* foo
|
||||
*/
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class WithDirMagic
|
||||
{
|
||||
public function getDir()
|
||||
{
|
||||
return __DIR__;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* foo
|
||||
*/
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class WithFileMagic
|
||||
{
|
||||
public function getFile()
|
||||
{
|
||||
return __FILE__;
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* foo
|
||||
*/
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class WithHaltCompiler
|
||||
{
|
||||
}
|
||||
|
||||
// the end of the script execution
|
||||
__halt_compiler(); data
|
||||
data
|
||||
data
|
||||
data
|
||||
...
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* foo
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class WithStrictTypes
|
||||
{
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Namespaced2;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Namespaced2;
|
||||
|
||||
class Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Namespaced2;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Pearlike_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Pearlike_Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Pearlike_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
class Pearlike_WithComments
|
||||
{
|
||||
/** @Boolean */
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Pearlike2_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Pearlike2_Baz
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Pearlike2_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests\Fixtures;
|
||||
|
||||
class WarmedClass extends DeclaredClass implements WarmedInterface
|
||||
{
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests\Fixtures;
|
||||
|
||||
interface WarmedInterface
|
||||
{
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace NamespaceCollision\A;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace NamespaceCollision\A;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace NamespaceCollision\C;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace NamespaceCollision\C;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class PrefixCollision_A_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class PrefixCollision_A_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class PrefixCollision_C_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class PrefixCollision_C_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace NamespaceCollision\A\B;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace NamespaceCollision\A\B;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace NamespaceCollision\C\B;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace NamespaceCollision\C\B;
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class PrefixCollision_A_B_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class PrefixCollision_A_B_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class PrefixCollision_C_B_Bar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class PrefixCollision_C_B_Foo
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace ClassMap;
|
||||
|
||||
class SomeClass extends SomeParent implements SomeInterface
|
||||
{
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace ClassMap;
|
||||
|
||||
interface SomeInterface
|
||||
{
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace ClassMap;
|
||||
|
||||
abstract class SomeParent
|
||||
{
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace {
|
||||
class A
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace Alpha {
|
||||
class A
|
||||
{
|
||||
}
|
||||
class B
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beta {
|
||||
class A
|
||||
{
|
||||
}
|
||||
class B
|
||||
{
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
<?php
|
||||
|
||||
$a = new stdClass();
|
@ -1 +0,0 @@
|
||||
This file should be skipped.
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Foo\Bar;
|
||||
|
||||
class A
|
||||
{
|
||||
}
|
||||
class B
|
||||
{
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
trait TD
|
||||
{
|
||||
}
|
||||
|
||||
trait TZ
|
||||
{
|
||||
use TD;
|
||||
}
|
||||
|
||||
trait TC
|
||||
{
|
||||
use TD;
|
||||
}
|
||||
|
||||
trait TB
|
||||
{
|
||||
use TC;
|
||||
}
|
||||
|
||||
trait TA
|
||||
{
|
||||
use TB;
|
||||
}
|
||||
|
||||
class CTFoo
|
||||
{
|
||||
use TA;
|
||||
use TZ;
|
||||
}
|
||||
|
||||
class CTBar
|
||||
{
|
||||
use TZ;
|
||||
use TA;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Namespaced;
|
||||
|
||||
class FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Namespaced2;
|
||||
|
||||
class FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Pearlike_FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Pearlike2_FooBar
|
||||
{
|
||||
public static $loaded = true;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user