
# Conflicts: # .gitignore # vendor/autoload.php # vendor/composer/ClassLoader.php # vendor/composer/LICENSE # vendor/composer/autoload_classmap.php # vendor/composer/autoload_files.php # vendor/composer/autoload_psr4.php # vendor/composer/autoload_real.php # vendor/composer/autoload_static.php # vendor/composer/installed.json # vendor/fgrosse/phpasn1/CHANGELOG.md # vendor/fgrosse/phpasn1/composer.json # vendor/fgrosse/phpasn1/lib/Utility/BigInteger.php # vendor/geoip2/geoip2/CHANGELOG.md # vendor/geoip2/geoip2/composer.json # vendor/geoip2/geoip2/src/Database/Reader.php # vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php # vendor/geoip2/geoip2/src/Exception/AuthenticationException.php # vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php # vendor/geoip2/geoip2/src/Exception/HttpException.php # vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php # vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php # vendor/geoip2/geoip2/src/Model/AbstractModel.php # vendor/geoip2/geoip2/src/Model/AnonymousIp.php # vendor/geoip2/geoip2/src/Model/Asn.php # vendor/geoip2/geoip2/src/Model/City.php # vendor/geoip2/geoip2/src/Model/ConnectionType.php # vendor/geoip2/geoip2/src/Model/Country.php # vendor/geoip2/geoip2/src/Model/Domain.php # vendor/geoip2/geoip2/src/Model/Enterprise.php # vendor/geoip2/geoip2/src/Model/Insights.php # vendor/geoip2/geoip2/src/Model/Isp.php # vendor/geoip2/geoip2/src/ProviderInterface.php # vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php # vendor/geoip2/geoip2/src/Record/AbstractRecord.php # vendor/geoip2/geoip2/src/Record/City.php # vendor/geoip2/geoip2/src/Record/Continent.php # vendor/geoip2/geoip2/src/Record/Country.php # vendor/geoip2/geoip2/src/Record/Location.php # vendor/geoip2/geoip2/src/Record/MaxMind.php # vendor/geoip2/geoip2/src/Record/Postal.php # vendor/geoip2/geoip2/src/Record/RepresentedCountry.php # vendor/geoip2/geoip2/src/Record/Subdivision.php # vendor/geoip2/geoip2/src/Record/Traits.php # vendor/geoip2/geoip2/src/Util.php # vendor/geoip2/geoip2/src/WebService/Client.php # vendor/guzzlehttp/promises/CHANGELOG.md # vendor/guzzlehttp/promises/README.md # vendor/guzzlehttp/promises/composer.json # vendor/guzzlehttp/promises/src/AggregateException.php # vendor/guzzlehttp/promises/src/CancellationException.php # vendor/guzzlehttp/promises/src/Coroutine.php # vendor/guzzlehttp/promises/src/EachPromise.php # vendor/guzzlehttp/promises/src/FulfilledPromise.php # vendor/guzzlehttp/promises/src/Promise.php # vendor/guzzlehttp/promises/src/PromiseInterface.php # vendor/guzzlehttp/promises/src/PromisorInterface.php # vendor/guzzlehttp/promises/src/RejectedPromise.php # vendor/guzzlehttp/promises/src/RejectionException.php # vendor/guzzlehttp/promises/src/TaskQueue.php # vendor/guzzlehttp/promises/src/TaskQueueInterface.php # vendor/guzzlehttp/promises/src/functions.php # vendor/guzzlehttp/psr7/CHANGELOG.md # vendor/guzzlehttp/psr7/README.md # vendor/guzzlehttp/psr7/composer.json # vendor/guzzlehttp/psr7/src/AppendStream.php # vendor/guzzlehttp/psr7/src/BufferStream.php # vendor/guzzlehttp/psr7/src/CachingStream.php # vendor/guzzlehttp/psr7/src/DroppingStream.php # vendor/guzzlehttp/psr7/src/FnStream.php # vendor/guzzlehttp/psr7/src/InflateStream.php # vendor/guzzlehttp/psr7/src/LazyOpenStream.php # vendor/guzzlehttp/psr7/src/LimitStream.php # vendor/guzzlehttp/psr7/src/MessageTrait.php # vendor/guzzlehttp/psr7/src/MultipartStream.php # vendor/guzzlehttp/psr7/src/NoSeekStream.php # vendor/guzzlehttp/psr7/src/PumpStream.php # vendor/guzzlehttp/psr7/src/Request.php # vendor/guzzlehttp/psr7/src/Response.php # vendor/guzzlehttp/psr7/src/ServerRequest.php # vendor/guzzlehttp/psr7/src/Stream.php # vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php # vendor/guzzlehttp/psr7/src/StreamWrapper.php # vendor/guzzlehttp/psr7/src/UploadedFile.php # vendor/guzzlehttp/psr7/src/Uri.php # vendor/guzzlehttp/psr7/src/UriNormalizer.php # vendor/guzzlehttp/psr7/src/UriResolver.php # vendor/guzzlehttp/psr7/src/functions.php # vendor/maxmind-db/reader/CHANGELOG.md # vendor/maxmind-db/reader/composer.json # vendor/maxmind-db/reader/ext/maxminddb.c # vendor/maxmind-db/reader/ext/php_maxminddb.h # vendor/maxmind-db/reader/package.xml # vendor/maxmind/web-service-common/CHANGELOG.md # vendor/maxmind/web-service-common/README.md # vendor/maxmind/web-service-common/composer.json # vendor/maxmind/web-service-common/src/Exception/AuthenticationException.php # vendor/maxmind/web-service-common/src/Exception/HttpException.php # vendor/maxmind/web-service-common/src/Exception/InsufficientFundsException.php # vendor/maxmind/web-service-common/src/Exception/InvalidInputException.php # vendor/maxmind/web-service-common/src/Exception/InvalidRequestException.php # vendor/maxmind/web-service-common/src/Exception/IpAddressNotFoundException.php # vendor/maxmind/web-service-common/src/Exception/PermissionRequiredException.php # vendor/maxmind/web-service-common/src/Exception/WebServiceException.php # vendor/maxmind/web-service-common/src/WebService/Client.php # vendor/maxmind/web-service-common/src/WebService/Http/CurlRequest.php # vendor/maxmind/web-service-common/src/WebService/Http/Request.php # vendor/maxmind/web-service-common/src/WebService/Http/RequestFactory.php # vendor/paragonie/random_compat/composer.json # vendor/paragonie/sodium_compat/.gitignore # vendor/paragonie/sodium_compat/composer.json # vendor/paragonie/sodium_compat/psalm-above-3.xml # vendor/paragonie/sodium_compat/src/Core/Ed25519.php # vendor/paragonie/sodium_compat/src/Core/SipHash.php # vendor/paragonie/sodium_compat/src/Core/Util.php # vendor/paragonie/sodium_compat/src/Core32/Ed25519.php # vendor/paragonie/sodium_compat/src/File.php # vendor/paragonie/sodium_compat/src/PHP52/SplFixedArray.php # vendor/phpmailer/phpmailer/README.md # vendor/phpmailer/phpmailer/VERSION # vendor/phpmailer/phpmailer/composer.json # vendor/phpmailer/phpmailer/get_oauth_token.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-af.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-ar.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-az.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-ba.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-be.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-bg.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-ca.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-ch.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-cs.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-da.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-de.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-el.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-eo.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-es.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-et.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-fa.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-fi.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-fo.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-fr.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-gl.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-he.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-hi.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-hr.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-hu.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-hy.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-id.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-it.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-ja.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-ka.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-ko.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-lt.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-lv.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-mg.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-ms.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-nb.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-nl.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-pl.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-pt.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-pt_br.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-ro.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-ru.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-sk.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-sl.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-sr.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-sv.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-tl.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-tr.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-uk.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-vi.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-zh.php # vendor/phpmailer/phpmailer/language/phpmailer.lang-zh_cn.php # vendor/phpmailer/phpmailer/src/Exception.php # vendor/phpmailer/phpmailer/src/OAuth.php # vendor/phpmailer/phpmailer/src/PHPMailer.php # vendor/phpmailer/phpmailer/src/POP3.php # vendor/phpmailer/phpmailer/src/SMTP.php # vendor/spomky-labs/base64url/composer.json # vendor/stripe/stripe-php/CHANGELOG.md # vendor/stripe/stripe-php/VERSION # vendor/stripe/stripe-php/composer.json # vendor/stripe/stripe-php/init.php # vendor/stripe/stripe-php/lib/Account.php # vendor/stripe/stripe-php/lib/ApiRequestor.php # vendor/stripe/stripe-php/lib/ApplicationFeeRefund.php # vendor/stripe/stripe-php/lib/Balance.php # vendor/stripe/stripe-php/lib/BalanceTransaction.php # vendor/stripe/stripe-php/lib/BaseStripeClient.php # vendor/stripe/stripe-php/lib/BitcoinReceiver.php # vendor/stripe/stripe-php/lib/Card.php # vendor/stripe/stripe-php/lib/Charge.php # vendor/stripe/stripe-php/lib/Checkout/Session.php # vendor/stripe/stripe-php/lib/Coupon.php # vendor/stripe/stripe-php/lib/CreditNote.php # vendor/stripe/stripe-php/lib/CreditNoteLineItem.php # vendor/stripe/stripe-php/lib/Customer.php # vendor/stripe/stripe-php/lib/ErrorObject.php # vendor/stripe/stripe-php/lib/Event.php # vendor/stripe/stripe-php/lib/HttpClient/CurlClient.php # vendor/stripe/stripe-php/lib/Invoice.php # vendor/stripe/stripe-php/lib/InvoiceItem.php # vendor/stripe/stripe-php/lib/InvoiceLineItem.php # vendor/stripe/stripe-php/lib/Order.php # vendor/stripe/stripe-php/lib/PaymentIntent.php # vendor/stripe/stripe-php/lib/PaymentMethod.php # vendor/stripe/stripe-php/lib/Payout.php # vendor/stripe/stripe-php/lib/Plan.php # vendor/stripe/stripe-php/lib/PromotionCode.php # vendor/stripe/stripe-php/lib/Refund.php # vendor/stripe/stripe-php/lib/Service/CoreServiceFactory.php # vendor/stripe/stripe-php/lib/Service/CustomerService.php # vendor/stripe/stripe-php/lib/Service/InvoiceService.php # vendor/stripe/stripe-php/lib/Service/PayoutService.php # vendor/stripe/stripe-php/lib/Service/SubscriptionScheduleService.php # vendor/stripe/stripe-php/lib/Service/SubscriptionService.php # vendor/stripe/stripe-php/lib/SetupIntent.php # vendor/stripe/stripe-php/lib/Source.php # vendor/stripe/stripe-php/lib/Stripe.php # vendor/stripe/stripe-php/lib/StripeClient.php # vendor/stripe/stripe-php/lib/StripeObject.php # vendor/stripe/stripe-php/lib/Subscription.php # vendor/stripe/stripe-php/lib/TaxId.php # vendor/stripe/stripe-php/lib/TaxRate.php # vendor/stripe/stripe-php/lib/TransferReversal.php # vendor/stripe/stripe-php/lib/Util/ObjectTypes.php # vendor/stripe/stripe-php/lib/Util/Util.php # vendor/symfony/polyfill-intl-idn/Idn.php # vendor/symfony/polyfill-intl-idn/composer.json # vendor/symfony/polyfill-intl-normalizer/bootstrap.php # vendor/symfony/polyfill-intl-normalizer/composer.json # vendor/symfony/polyfill-php72/Php72.php # vendor/symfony/polyfill-php72/bootstrap.php # vendor/symfony/polyfill-php72/composer.json
488 lines
14 KiB
PHP
488 lines
14 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Composer.
|
|
*
|
|
* (c) Nils Adermann <naderman@naderman.de>
|
|
* Jordi Boggiano <j.boggiano@seld.be>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Composer\Autoload;
|
|
|
|
/**
|
|
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
|
*
|
|
* $loader = new \Composer\Autoload\ClassLoader();
|
|
*
|
|
* // register classes with namespaces
|
|
* $loader->add('Symfony\Component', __DIR__.'/component');
|
|
* $loader->add('Symfony', __DIR__.'/framework');
|
|
*
|
|
* // activate the autoloader
|
|
* $loader->register();
|
|
*
|
|
* // to enable searching the include path (eg. 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.
|
|
*
|
|
* This class is loosely based on the Symfony UniversalClassLoader.
|
|
*
|
|
* @author Fabien Potencier <fabien@symfony.com>
|
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
|
* @see http://www.php-fig.org/psr/psr-0/
|
|
* @see http://www.php-fig.org/psr/psr-4/
|
|
*/
|
|
class ClassLoader
|
|
{
|
|
// PSR-4
|
|
private $prefixLengthsPsr4 = array();
|
|
private $prefixDirsPsr4 = array();
|
|
private $fallbackDirsPsr4 = array();
|
|
|
|
// PSR-0
|
|
private $prefixesPsr0 = array();
|
|
private $fallbackDirsPsr0 = array();
|
|
|
|
private $useIncludePath = false;
|
|
private $classMap = array();
|
|
<<<<<<< HEAD
|
|
|
|
private $classMapAuthoritative = false;
|
|
=======
|
|
private $classMapAuthoritative = false;
|
|
private $missingClasses = array();
|
|
private $apcuPrefix;
|
|
>>>>>>> master
|
|
|
|
public function getPrefixes()
|
|
{
|
|
if (!empty($this->prefixesPsr0)) {
|
|
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
|
}
|
|
|
|
return array();
|
|
}
|
|
|
|
public function getPrefixesPsr4()
|
|
{
|
|
return $this->prefixDirsPsr4;
|
|
}
|
|
|
|
public function getFallbackDirs()
|
|
{
|
|
return $this->fallbackDirsPsr0;
|
|
}
|
|
|
|
public function getFallbackDirsPsr4()
|
|
{
|
|
return $this->fallbackDirsPsr4;
|
|
}
|
|
|
|
public function getClassMap()
|
|
{
|
|
return $this->classMap;
|
|
}
|
|
|
|
/**
|
|
* @param array $classMap Class to filename map
|
|
*/
|
|
public function addClassMap(array $classMap)
|
|
{
|
|
if ($this->classMap) {
|
|
$this->classMap = array_merge($this->classMap, $classMap);
|
|
} else {
|
|
$this->classMap = $classMap;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Registers a set of PSR-0 directories for a given prefix, either
|
|
* appending or prepending to the ones previously set for this prefix.
|
|
*
|
|
* @param string $prefix The prefix
|
|
* @param array|string $paths The PSR-0 root directories
|
|
* @param bool $prepend Whether to prepend the directories
|
|
*/
|
|
public function add($prefix, $paths, $prepend = false)
|
|
{
|
|
if (!$prefix) {
|
|
if ($prepend) {
|
|
$this->fallbackDirsPsr0 = array_merge(
|
|
(array) $paths,
|
|
$this->fallbackDirsPsr0
|
|
);
|
|
} else {
|
|
$this->fallbackDirsPsr0 = array_merge(
|
|
$this->fallbackDirsPsr0,
|
|
(array) $paths
|
|
);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
$first = $prefix[0];
|
|
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
|
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
|
|
|
return;
|
|
}
|
|
if ($prepend) {
|
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
|
(array) $paths,
|
|
$this->prefixesPsr0[$first][$prefix]
|
|
);
|
|
} else {
|
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
|
$this->prefixesPsr0[$first][$prefix],
|
|
(array) $paths
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Registers a set of PSR-4 directories for a given namespace, either
|
|
* appending or prepending to the ones previously set for this namespace.
|
|
*
|
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
|
* @param array|string $paths The PSR-4 base directories
|
|
* @param bool $prepend Whether to prepend the directories
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
*/
|
|
public function addPsr4($prefix, $paths, $prepend = false)
|
|
{
|
|
if (!$prefix) {
|
|
// Register directories for the root namespace.
|
|
if ($prepend) {
|
|
$this->fallbackDirsPsr4 = array_merge(
|
|
(array) $paths,
|
|
$this->fallbackDirsPsr4
|
|
);
|
|
} else {
|
|
$this->fallbackDirsPsr4 = array_merge(
|
|
$this->fallbackDirsPsr4,
|
|
(array) $paths
|
|
);
|
|
}
|
|
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
|
// Register directories for a new namespace.
|
|
$length = strlen($prefix);
|
|
if ('\\' !== $prefix[$length - 1]) {
|
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
|
}
|
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
|
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
|
} elseif ($prepend) {
|
|
// Prepend directories for an already registered namespace.
|
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
|
(array) $paths,
|
|
$this->prefixDirsPsr4[$prefix]
|
|
);
|
|
} else {
|
|
// Append directories for an already registered namespace.
|
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
|
$this->prefixDirsPsr4[$prefix],
|
|
(array) $paths
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Registers a set of PSR-0 directories for a given prefix,
|
|
* replacing any others previously set for this prefix.
|
|
*
|
|
* @param string $prefix The prefix
|
|
* @param array|string $paths The PSR-0 base directories
|
|
*/
|
|
public function set($prefix, $paths)
|
|
{
|
|
if (!$prefix) {
|
|
$this->fallbackDirsPsr0 = (array) $paths;
|
|
} else {
|
|
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Registers a set of PSR-4 directories for a given namespace,
|
|
* replacing any others previously set for this namespace.
|
|
*
|
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
|
* @param array|string $paths The PSR-4 base directories
|
|
*
|
|
* @throws \InvalidArgumentException
|
|
*/
|
|
public function setPsr4($prefix, $paths)
|
|
{
|
|
if (!$prefix) {
|
|
$this->fallbackDirsPsr4 = (array) $paths;
|
|
} else {
|
|
$length = strlen($prefix);
|
|
if ('\\' !== $prefix[$length - 1]) {
|
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
|
}
|
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
|
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Turns on searching the include path for class files.
|
|
*
|
|
* @param bool $useIncludePath
|
|
*/
|
|
public function setUseIncludePath($useIncludePath)
|
|
{
|
|
$this->useIncludePath = $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;
|
|
}
|
|
|
|
/**
|
|
* Turns off searching the prefix and fallback directories for classes
|
|
* that have not been registered with the class map.
|
|
*
|
|
* @param bool $classMapAuthoritative
|
|
*/
|
|
public function setClassMapAuthoritative($classMapAuthoritative)
|
|
{
|
|
$this->classMapAuthoritative = $classMapAuthoritative;
|
|
}
|
|
|
|
/**
|
|
* Should class lookup fail if not found in the current class map?
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function isClassMapAuthoritative()
|
|
{
|
|
return $this->classMapAuthoritative;
|
|
}
|
|
|
|
/**
|
|
<<<<<<< HEAD
|
|
=======
|
|
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
|
*
|
|
* @param string|null $apcuPrefix
|
|
*/
|
|
public function setApcuPrefix($apcuPrefix)
|
|
{
|
|
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
|
}
|
|
|
|
/**
|
|
* The APCu prefix in use, or null if APCu caching is not enabled.
|
|
*
|
|
* @return string|null
|
|
*/
|
|
public function getApcuPrefix()
|
|
{
|
|
return $this->apcuPrefix;
|
|
}
|
|
|
|
/**
|
|
>>>>>>> master
|
|
* 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, null otherwise
|
|
*/
|
|
public function loadClass($class)
|
|
{
|
|
if ($file = $this->findFile($class)) {
|
|
includeFile($file);
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Finds the path to the file where the class is defined.
|
|
*
|
|
* @param string $class The name of the class
|
|
*
|
|
* @return string|false The path if found, false otherwise
|
|
*/
|
|
public function findFile($class)
|
|
{
|
|
<<<<<<< HEAD
|
|
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
|
|
if ('\\' == $class[0]) {
|
|
$class = substr($class, 1);
|
|
}
|
|
|
|
=======
|
|
>>>>>>> master
|
|
// class map lookup
|
|
if (isset($this->classMap[$class])) {
|
|
return $this->classMap[$class];
|
|
}
|
|
<<<<<<< HEAD
|
|
if ($this->classMapAuthoritative) {
|
|
return false;
|
|
}
|
|
=======
|
|
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
|
return false;
|
|
}
|
|
if (null !== $this->apcuPrefix) {
|
|
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
|
if ($hit) {
|
|
return $file;
|
|
}
|
|
}
|
|
>>>>>>> master
|
|
|
|
$file = $this->findFileWithExtension($class, '.php');
|
|
|
|
// Search for Hack files if we are running on HHVM
|
|
<<<<<<< HEAD
|
|
if ($file === null && defined('HHVM_VERSION')) {
|
|
$file = $this->findFileWithExtension($class, '.hh');
|
|
}
|
|
|
|
if ($file === null) {
|
|
// Remember that this class does not exist.
|
|
return $this->classMap[$class] = false;
|
|
=======
|
|
if (false === $file && defined('HHVM_VERSION')) {
|
|
$file = $this->findFileWithExtension($class, '.hh');
|
|
}
|
|
|
|
if (null !== $this->apcuPrefix) {
|
|
apcu_add($this->apcuPrefix.$class, $file);
|
|
}
|
|
|
|
if (false === $file) {
|
|
// Remember that this class does not exist.
|
|
$this->missingClasses[$class] = true;
|
|
>>>>>>> master
|
|
}
|
|
|
|
return $file;
|
|
}
|
|
|
|
private function findFileWithExtension($class, $ext)
|
|
{
|
|
// PSR-4 lookup
|
|
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
|
|
|
$first = $class[0];
|
|
if (isset($this->prefixLengthsPsr4[$first])) {
|
|
<<<<<<< HEAD
|
|
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
|
|
if (0 === strpos($class, $prefix)) {
|
|
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
|
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
|
=======
|
|
$subPath = $class;
|
|
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
|
$subPath = substr($subPath, 0, $lastPos);
|
|
$search = $subPath . '\\';
|
|
if (isset($this->prefixDirsPsr4[$search])) {
|
|
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
|
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
|
if (file_exists($file = $dir . $pathEnd)) {
|
|
>>>>>>> master
|
|
return $file;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// PSR-4 fallback dirs
|
|
foreach ($this->fallbackDirsPsr4 as $dir) {
|
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
|
return $file;
|
|
}
|
|
}
|
|
|
|
// PSR-0 lookup
|
|
if (false !== $pos = strrpos($class, '\\')) {
|
|
// namespaced class name
|
|
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
|
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
|
} else {
|
|
// PEAR-like class name
|
|
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
|
}
|
|
|
|
if (isset($this->prefixesPsr0[$first])) {
|
|
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
|
if (0 === strpos($class, $prefix)) {
|
|
foreach ($dirs as $dir) {
|
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
|
return $file;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// PSR-0 fallback dirs
|
|
foreach ($this->fallbackDirsPsr0 as $dir) {
|
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
|
return $file;
|
|
}
|
|
}
|
|
|
|
// PSR-0 include paths.
|
|
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
|
return $file;
|
|
}
|
|
<<<<<<< HEAD
|
|
=======
|
|
|
|
return false;
|
|
>>>>>>> master
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Scope isolated include.
|
|
*
|
|
* Prevents access to $this/self from included files.
|
|
*/
|
|
function includeFile($file)
|
|
{
|
|
include $file;
|
|
}
|