示例#1
0
 /**
  * @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 provideClassNotFoundData()
 {
     $prefixes = array('Symfony\\Component\\Debug\\Exception\\' => realpath(__DIR__ . '/../../Exception'));
     $symfonyAutoloader = new SymfonyClassLoader();
     $symfonyAutoloader->addPrefixes($prefixes);
     $debugClassLoader = new DebugClassLoader(array($symfonyAutoloader, 'loadClass'));
     return array(array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'WhizBangFactory\' not found'), "Attempted to load class \"WhizBangFactory\" from the global namespace.\nDid you forget a \"use\" statement?"), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\WhizBangFactory\' not found'), "Attempted to load class \"WhizBangFactory\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for another namespace?"), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from the global namespace.\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?"), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'PEARClass\' not found'), "Attempted to load class \"PEARClass\" from the global namespace.\nDid you forget a \"use\" statement for \"Symfony_Component_Debug_Tests_Fixtures_PEARClass\"?"), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?"), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?", array($symfonyAutoloader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?", array($debugClassLoader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for another namespace?", function ($className) {
         /* do nothing here */
     }));
 }
 public function provideLegacyClassNotFoundData()
 {
     $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
     $prefixes = array('Symfony\\Component\\Debug\\Exception\\' => realpath(__DIR__ . '/../../Exception'));
     $symfonyAutoloader = new SymfonyClassLoader();
     $symfonyAutoloader->addPrefixes($prefixes);
     return array(array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?", array($symfonyAutoloader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for another namespace?", function ($className) {
         /* do nothing here */
     }));
 }
 public function provideClassNotFoundData()
 {
     $prefixes = array('Symfony\\Component\\Debug\\Exception\\' => realpath(__DIR__ . '/../../Exception'));
     $symfonyAutoloader = new SymfonyClassLoader();
     $symfonyAutoloader->addPrefixes($prefixes);
     $symfonyUniversalClassLoader = new SymfonyUniversalClassLoader();
     $symfonyUniversalClassLoader->registerPrefixes($prefixes);
     return array(array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'WhizBangFactory\' not found'), 'Attempted to load class "WhizBangFactory" from the global namespace in foo.php line 12. Did you forget a use statement for this class?'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\WhizBangFactory\' not found'), 'Attempted to load class "WhizBangFactory" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace?'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from the global namespace in foo.php line 12. Did you forget a use statement for this class? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'PEARClass\' not found'), 'Attempted to load class "PEARClass" from the global namespace in foo.php line 12. Did you forget a use statement for this class? Perhaps you need to add a use statement for one of the following: Symfony_Component_Debug_Tests_Fixtures_PEARClass.'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.', array($symfonyAutoloader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.', array($symfonyUniversalClassLoader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace?', function ($className) {
         /* do nothing here */
     }));
 }
 /**
  * Check for composer in Namespace
  * and include via phar if possible
  */
 public static function checkComposer($pathToComposer = null)
 {
     if (!class_exists('Composer\\Factory')) {
         if (false === ($pathToComposer = self::whichComposer($pathToComposer))) {
             throw new \RuntimeException("Could not find composer.phar");
         }
         \Phar::loadPhar($pathToComposer, 'composer.phar');
         $loader = new ClassLoader();
         $namespaces = (include "phar://composer.phar/vendor/composer/autoload_namespaces.php");
         $loader->addPrefixes(array_merge(array('Composer' => "phar://composer.phar/src/"), $namespaces));
         $loader->register(true);
     }
 }
示例#6
0
<?php

use Symfony\Component\Debug\Debug;
use Symfony\Component\ClassLoader\ClassLoader;
// class loader
$loader = new ClassLoader();
$loader->addPrefixes(['' => __DIR__ . '/../validators']);
$loader->register();
// bootstrap
Debug::enable();
 /**
  * @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);
 }
示例#8
0
<?php

// Work around the lack of proper autoload.php from composer by using
// the ClassLoader element from Symfony.
// http://symfony.com/doc/current/components/class_loader/class_loader.html
require_once 'Symfony/Component/ClassLoader/ClassLoader.php';
use Symfony\Component\ClassLoader\ClassLoader;
$loader = new ClassLoader();
$loader->setUseIncludePath(true);
$loader->register();
$loader->addPrefixes(array());
// Load additional files as registered in composer
require_once 'getid3/getid3.php';
require_once 'libphp-phpmailer/class.phpmailer.php';
require_once 'libphp-phpmailer/class.pop3.php';
require_once 'libphp-phpmailer/class.smtp.php';
require_once 'Assetic/functions.php';
require_once 'Crypt/Random.php';
示例#9
0
<?php

require_once __DIR__ . '/../../vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassLoader.php';
use Symfony\Component\ClassLoader\ClassLoader;
$loader = new ClassLoader();
$loader->addPrefixes(array('Respect' => __DIR__ . '/../../vendor/respect/validation/library', 'Symfony\\Component\\Validator' => __DIR__ . '/../../vendor/symfony/validator', 'Symfony\\Component\\PropertyAccess' => __DIR__ . '/../../vendor/symfony/property-access', 'Symfony\\Component\\Translation' => __DIR__ . '/../../vendor/symfony/translation', 'HybridLogic' => __DIR__ . '/../../vendor/hybridlogic/validation/src', 'Fuel' => __DIR__ . '/../../vendor/fuelphp/validation/src', 'Zend\\Validator' => __DIR__ . '/../../vendor/zendframework/zend-validator', 'Zend\\Stdlib' => __DIR__ . '/../../vendor/zendframework/zend-stdlib', 'Kpacha\\ComponentBenchmark' => __DIR__ . '/../../src', 'Kpacha\\BenchmarkTool' => __DIR__ . '/../../vendor/kpacha/php-benchmark-tool/src', 'Symfony\\Component\\Finder' => __DIR__ . '/../../vendor/symfony/finder'));
$loader->register();
include __DIR__ . '/common.php';
示例#10
0
<?php

use Symfony\Component\ClassLoader\ClassLoader;
require_once __DIR__ . '/../../autoload.php';
function deleteTree($path)
{
    if (!is_dir($path)) {
        return;
    }
    $iterator = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
    foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $subpath) {
        if ($subpath->isDir()) {
            rmdir((string) $subpath);
        } else {
            unlink((string) $subpath);
        }
    }
    rmdir($path);
}
// Wipe previously generated proxies
deleteTree(__DIR__ . '/../../test/proxies/Doctrine/OrientDB/Proxy/test/Doctrine');
deleteTree(__DIR__ . '/../../test/proxies/Doctrine/OrientDB/Proxy/test/Integration');
// Set up autoloading for testing
$loader = new ClassLoader();
$loader->addPrefixes(array('Doctrine\\OrientDB\\Proxy' => __DIR__ . '/../../test/proxies/', 'test' => __DIR__ . '/../../'));
$loader->register();
示例#11
0
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once __DIR__ . '/../../../../ClassLoader/ClassLoader.php';
use Symfony\Component\ClassLoader\ClassLoader;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Security\Acl\Dbal\Schema;
$loader = new ClassLoader();
$loader->addPrefixes(array('Symfony' => __DIR__ . '/../../../../../..', 'Doctrine\\Common' => __DIR__ . '/../../../../../../../vendor/doctrine-common/lib', 'Doctrine\\DBAL\\Migrations' => __DIR__ . '/../../../../../../../vendor/doctrine-migrations/lib', 'Doctrine\\DBAL' => __DIR__ . '/../../../../../../../vendor/doctrine-dbal/lib', 'Doctrine' => __DIR__ . '/../../../../../../../vendor/doctrine/lib'));
$loader->register();
$schema = new Schema(array('class_table_name' => 'acl_classes', 'entry_table_name' => 'acl_entries', 'oid_table_name' => 'acl_object_identities', 'oid_ancestors_table_name' => 'acl_object_identity_ancestors', 'sid_table_name' => 'acl_security_identities'));
$reflection = new ReflectionClass('Doctrine\\DBAL\\Platforms\\AbstractPlatform');
$finder = new Finder();
$finder->name('*Platform.php')->in(dirname($reflection->getFileName()));
foreach ($finder as $file) {
    require_once $file->getPathName();
    $className = 'Doctrine\\DBAL\\Platforms\\' . $file->getBasename('.php');
    $reflection = new ReflectionClass($className);
    if ($reflection->isAbstract()) {
        continue;
    }
    $platform = $reflection->newInstance();
    $targetFile = sprintf(__DIR__ . '/../schema/%s.sql', $platform->name);
    file_put_contents($targetFile, implode("\n\n", $schema->toSql($platform)));
<?php

require_once __DIR__ . '/../vendor/symfony/class-loader/ClassLoader.php';
use Symfony\Component\ClassLoader\ClassLoader;
$loader = new ClassLoader();
$loader->register();
$loader->addPrefixes(array('DoublesSearchBundle' => __DIR__ . '/../src'));
return $loader;