Merge pull request #9187 from simonberger/substring-to-strpos
commit
7604c36bc5
|
@ -251,7 +251,7 @@ class ClassMapGenerator
|
|||
// strip strings
|
||||
$contents = preg_replace('{"[^"\\\\]*+(\\\\.[^"\\\\]*+)*+"|\'[^\'\\\\]*+(\\\\.[^\'\\\\]*+)*+\'}s', 'null', $contents);
|
||||
// strip leading non-php code if needed
|
||||
if (substr($contents, 0, 2) !== '<?') {
|
||||
if (strpos($contents, '<?') !== 0) {
|
||||
$contents = preg_replace('{^.+?<\?}s', '<?', $contents, 1, $replacements);
|
||||
if ($replacements === 0) {
|
||||
return array();
|
||||
|
|
|
@ -565,7 +565,7 @@ EOT
|
|||
),
|
||||
);
|
||||
|
||||
if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || substr($settingKey, 0, 6) === 'extra.')) {
|
||||
if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || strpos($settingKey, 'extra.') === 0)) {
|
||||
throw new \InvalidArgumentException('The '.$settingKey.' property can not be set in the global config.json file. Use `composer global config` to apply changes to the global composer.json');
|
||||
}
|
||||
if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) {
|
||||
|
|
|
@ -148,7 +148,7 @@ EOT
|
|||
$io->write('Checking disk free space: ', false);
|
||||
$this->outputResult($this->checkDiskSpace($config));
|
||||
|
||||
if ('phar:' === substr(__FILE__, 0, 5)) {
|
||||
if (strpos(__FILE__, 'phar:') === 0) {
|
||||
$io->write('Checking pubkeys: ', false);
|
||||
$this->outputResult($this->checkPubKeys($config));
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ EOT
|
|||
}
|
||||
|
||||
$file = new JsonFile(Factory::getComposerFile());
|
||||
$json = $file->encode($options);
|
||||
$json = JsonFile::encode($options);
|
||||
|
||||
if ($input->isInteractive()) {
|
||||
$io->writeError(array('', $json, ''));
|
||||
|
@ -655,7 +655,7 @@ EOT
|
|||
if (file_exists($ignoreFile)) {
|
||||
$contents = file_get_contents($ignoreFile);
|
||||
|
||||
if ("\n" !== substr($contents, 0, -1)) {
|
||||
if (strpos($contents, "\n") !== 0) {
|
||||
$contents .= "\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ EOT
|
|||
}
|
||||
}
|
||||
|
||||
if ($requestedChannel && is_numeric($requestedChannel) && substr($latestStable['version'], 0, 1) !== $requestedChannel) {
|
||||
if ($requestedChannel && is_numeric($requestedChannel) && strpos($latestStable['version'], $requestedChannel) !== 0) {
|
||||
$io->writeError('<warning>Warning: You forced the install of '.$latestVersion.' via --'.$requestedChannel.', but '.$latestStable['version'].' is the latest stable version. Updating to it via composer self-update --stable is recommended.</warning>');
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
|||
public function addProperty($name, $value)
|
||||
{
|
||||
$this->manipulateJson('addProperty', $name, $value, function (&$config, $key, $val) {
|
||||
if (substr($key, 0, 6) === 'extra.' || substr($key, 0, 8) === 'scripts.') {
|
||||
if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
|
||||
$bits = explode('.', $key);
|
||||
$last = array_pop($bits);
|
||||
$arr = &$config[reset($bits)];
|
||||
|
@ -157,9 +157,8 @@ class JsonConfigSource implements ConfigSourceInterface
|
|||
*/
|
||||
public function removeProperty($name)
|
||||
{
|
||||
$authConfig = $this->authConfig;
|
||||
$this->manipulateJson('removeProperty', $name, function (&$config, $key) {
|
||||
if (substr($key, 0, 6) === 'extra.' || substr($key, 0, 8) === 'scripts.') {
|
||||
if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
|
||||
$bits = explode('.', $key);
|
||||
$last = array_pop($bits);
|
||||
$arr = &$config[reset($bits)];
|
||||
|
|
|
@ -473,7 +473,7 @@ class Application extends BaseApplication
|
|||
new Command\FundCommand(),
|
||||
));
|
||||
|
||||
if ('phar:' === substr(__FILE__, 0, 5)) {
|
||||
if (strpos(__FILE__, 'phar:') === 0) {
|
||||
$commands[] = new Command\SelfUpdateCommand();
|
||||
}
|
||||
|
||||
|
|
|
@ -116,8 +116,8 @@ class DefaultPolicy implements PolicyInterface
|
|||
if ($requiredPackage && false !== ($pos = strpos($requiredPackage, '/'))) {
|
||||
$requiredVendor = substr($requiredPackage, 0, $pos);
|
||||
|
||||
$aIsSameVendor = substr($a->getName(), 0, $pos) === $requiredVendor;
|
||||
$bIsSameVendor = substr($b->getName(), 0, $pos) === $requiredVendor;
|
||||
$aIsSameVendor = strpos($a->getName(), $requiredVendor) === 0;
|
||||
$bIsSameVendor = strpos($b->getName(), $requiredVendor) === 0;
|
||||
|
||||
if ($bIsSameVendor !== $aIsSameVendor) {
|
||||
return $aIsSameVendor ? -1 : 1;
|
||||
|
|
|
@ -12,17 +12,12 @@
|
|||
|
||||
namespace Composer\EventDispatcher;
|
||||
|
||||
use Composer\DependencyResolver\PolicyInterface;
|
||||
use Composer\DependencyResolver\Request;
|
||||
use Composer\DependencyResolver\Pool;
|
||||
use Composer\DependencyResolver\Transaction;
|
||||
use Composer\Installer\InstallerEvent;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Composer;
|
||||
use Composer\DependencyResolver\Operation\OperationInterface;
|
||||
use Composer\Repository\CompositeRepository;
|
||||
use Composer\Repository\RepositoryInterface;
|
||||
use Composer\Repository\RepositorySet;
|
||||
use Composer\Script;
|
||||
use Composer\Installer\PackageEvent;
|
||||
use Composer\Installer\BinaryInstaller;
|
||||
|
@ -177,7 +172,7 @@ class EventDispatcher
|
|||
|
||||
$args = array_merge($script, $event->getArguments());
|
||||
$flags = $event->getFlags();
|
||||
if (substr($callable, 0, 10) === '@composer ') {
|
||||
if (strpos($callable, '@composer ') === 0) {
|
||||
$exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . ' ' . implode(' ', $args);
|
||||
if (0 !== ($exitCode = $this->executeTty($exec))) {
|
||||
$this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
|
||||
|
@ -239,11 +234,12 @@ class EventDispatcher
|
|||
}
|
||||
}
|
||||
|
||||
if (substr($exec, 0, 8) === '@putenv ') {
|
||||
if (strpos($exec, '@putenv ') === 0) {
|
||||
putenv(substr($exec, 8));
|
||||
|
||||
continue;
|
||||
} elseif (substr($exec, 0, 5) === '@php ') {
|
||||
}
|
||||
if (strpos($exec, '@php ') === 0) {
|
||||
$exec = $this->getPhpExecCommand() . ' ' . substr($exec, 5);
|
||||
} else {
|
||||
$finder = new PhpExecutableFinder();
|
||||
|
@ -257,7 +253,7 @@ class EventDispatcher
|
|||
// if composer is being executed, make sure it runs the expected composer from current path
|
||||
// resolution, even if bin-dir contains composer too because the project requires composer/composer
|
||||
// see https://github.com/composer/composer/issues/8748
|
||||
if (substr($exec, 0, 9) === 'composer ') {
|
||||
if (strpos($exec, 'composer ') === 0) {
|
||||
$exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($exec, 8);
|
||||
}
|
||||
|
||||
|
@ -472,7 +468,7 @@ class EventDispatcher
|
|||
*/
|
||||
protected function isComposerScript($callable)
|
||||
{
|
||||
return '@' === substr($callable, 0, 1) && '@php ' !== substr($callable, 0, 5) && '@putenv ' !== substr($callable, 0, 8);
|
||||
return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -651,7 +651,7 @@ class Factory
|
|||
private static function useXdg()
|
||||
{
|
||||
foreach (array_keys($_SERVER) as $key) {
|
||||
if (substr($key, 0, 4) === 'XDG_') {
|
||||
if (strpos($key, 'XDG_') === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,8 +262,8 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
|
|||
if ($targetDownloadPath !== $initialDownloadPath) {
|
||||
// if the target and initial dirs intersect, we force a remove + install
|
||||
// to avoid the rename wiping the target dir as part of the initial dir cleanup
|
||||
if (substr($initialDownloadPath, 0, strlen($targetDownloadPath)) === $targetDownloadPath
|
||||
|| substr($targetDownloadPath, 0, strlen($initialDownloadPath)) === $initialDownloadPath
|
||||
if (strpos($initialDownloadPath, $targetDownloadPath) === 0
|
||||
|| strpos($targetDownloadPath, $initialDownloadPath) === 0
|
||||
) {
|
||||
$promise = $this->removeCode($initial);
|
||||
if (!$promise instanceof PromiseInterface) {
|
||||
|
|
|
@ -167,15 +167,15 @@ class JsonManipulator
|
|||
|
||||
public function addProperty($name, $value)
|
||||
{
|
||||
if (substr($name, 0, 8) === 'suggest.') {
|
||||
if (strpos($name, 'suggest.') === 0) {
|
||||
return $this->addSubNode('suggest', substr($name, 8), $value);
|
||||
}
|
||||
|
||||
if (substr($name, 0, 6) === 'extra.') {
|
||||
if (strpos($name, 'extra.') === 0) {
|
||||
return $this->addSubNode('extra', substr($name, 6), $value);
|
||||
}
|
||||
|
||||
if (substr($name, 0, 8) === 'scripts.') {
|
||||
if (strpos($name, 'scripts.') === 0) {
|
||||
return $this->addSubNode('scripts', substr($name, 8), $value);
|
||||
}
|
||||
|
||||
|
@ -184,15 +184,15 @@ class JsonManipulator
|
|||
|
||||
public function removeProperty($name)
|
||||
{
|
||||
if (substr($name, 0, 8) === 'suggest.') {
|
||||
if (strpos($name, 'suggest.') === 0) {
|
||||
return $this->removeSubNode('suggest', substr($name, 8));
|
||||
}
|
||||
|
||||
if (substr($name, 0, 6) === 'extra.') {
|
||||
if (strpos($name, 'extra.') === 0) {
|
||||
return $this->removeSubNode('extra', substr($name, 6));
|
||||
}
|
||||
|
||||
if (substr($name, 0, 8) === 'scripts.') {
|
||||
if (strpos($name, 'scripts.') === 0) {
|
||||
return $this->removeSubNode('scripts', substr($name, 8));
|
||||
}
|
||||
|
||||
|
|
|
@ -334,7 +334,7 @@ class ArrayLoader implements LoaderInterface
|
|||
*/
|
||||
public function getBranchAlias(array $config)
|
||||
{
|
||||
if ('dev-' !== substr($config['version'], 0, 4) && '-dev' !== substr($config['version'], -4)) {
|
||||
if (strpos($config['version'], 'dev-') !== 0 && '-dev' !== substr($config['version'], -4)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@ class ValidatingArrayLoader implements LoaderInterface
|
|||
// check requires for exact constraints
|
||||
($this->flags & self::CHECK_STRICT_CONSTRAINTS)
|
||||
&& 'require' === $linkType
|
||||
&& substr($linkConstraint, 0, 1) === '='
|
||||
&& strpos($linkConstraint, '=') === 0
|
||||
&& $stableConstraint->versionCompare($stableConstraint, $linkConstraint, '<=')
|
||||
) {
|
||||
$this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
|
||||
|
|
|
@ -20,8 +20,6 @@ use Composer\Util\Git as GitUtil;
|
|||
use Composer\Util\HttpDownloader;
|
||||
use Composer\Util\ProcessExecutor;
|
||||
use Composer\Util\Svn as SvnUtil;
|
||||
use Composer\Util\Platform;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -96,7 +94,7 @@ class VersionGuesser
|
|||
|
||||
private function postprocess(array $versionData)
|
||||
{
|
||||
if (!empty($versionData['feature_version']) && $versionData['feature_version'] === $versionData['version'] && $versionData['feature_pretty_version'] === $versionData['feature_pretty_version']) {
|
||||
if (!empty($versionData['feature_version']) && $versionData['feature_version'] === $versionData['version'] && $versionData['feature_pretty_version'] === $versionData['pretty_version']) {
|
||||
unset($versionData['feature_version'], $versionData['feature_pretty_version']);
|
||||
}
|
||||
|
||||
|
@ -129,7 +127,11 @@ class VersionGuesser
|
|||
// find current branch and collect all branch names
|
||||
foreach ($this->process->splitLines($output) as $branch) {
|
||||
if ($branch && preg_match('{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
|
||||
if ($match[1] === '(no branch)' || substr($match[1], 0, 10) === '(detached ' || substr($match[1], 0, 17) === '(HEAD detached at') {
|
||||
if (
|
||||
$match[1] === '(no branch)'
|
||||
|| strpos($match[1], '(detached ') === 0
|
||||
|| strpos($match[1], '(HEAD detached at') === 0
|
||||
) {
|
||||
$version = 'dev-' . $match[2];
|
||||
$prettyVersion = $version;
|
||||
$isFeatureBranch = true;
|
||||
|
|
|
@ -79,7 +79,7 @@ class VersionParser extends SemverVersionParser
|
|||
$normalizedFrom = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEFAULT_BRANCH_ALIAS, $normalizedFrom);
|
||||
$normalizedTo = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEFAULT_BRANCH_ALIAS, $normalizedTo);
|
||||
|
||||
if (substr($normalizedFrom, 0, 4) === 'dev-' || substr($normalizedTo, 0, 4) === 'dev-') {
|
||||
if (strpos($normalizedFrom, 'dev-') === 0 || strpos($normalizedTo, 'dev-') === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ use Composer\Package\Version\StabilityFilter;
|
|||
use Composer\Json\JsonFile;
|
||||
use Composer\Cache;
|
||||
use Composer\Config;
|
||||
use Composer\Composer;
|
||||
use Composer\Factory;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Semver\CompilingMatcher;
|
||||
use Composer\Util\HttpDownloader;
|
||||
|
@ -36,7 +34,6 @@ use Composer\Semver\Constraint\MatchAllConstraint;
|
|||
use Composer\Util\Http\Response;
|
||||
use Composer\Util\MetadataMinifier;
|
||||
use Composer\Util\Url;
|
||||
use React\Promise\Promise;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
|
@ -815,7 +812,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
return $this->rootData;
|
||||
}
|
||||
|
||||
if (!extension_loaded('openssl') && 'https' === substr($this->url, 0, 5)) {
|
||||
if (!extension_loaded('openssl') && strpos($this->url, 'https') === 0) {
|
||||
throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from '.$this->url);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class RepositoryFactory
|
|||
} else {
|
||||
throw new \InvalidArgumentException("Invalid repository URL ($repository) given. This file does not contain a valid composer repository.");
|
||||
}
|
||||
} elseif ('{' === substr($repository, 0, 1)) {
|
||||
} elseif (strpos($repository, '{') === 0) {
|
||||
// assume it is a json object that makes a repo config
|
||||
$repoConfig = JsonFile::parseJson($repository);
|
||||
} else {
|
||||
|
|
|
@ -302,10 +302,10 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
|||
}
|
||||
|
||||
// make sure branch packages have a dev flag
|
||||
if ('dev-' === substr($parsedBranch, 0, 4) || VersionParser::DEFAULT_BRANCH_ALIAS === $parsedBranch) {
|
||||
if (strpos($parsedBranch, 'dev-') === 0 || VersionParser::DEFAULT_BRANCH_ALIAS === $parsedBranch) {
|
||||
$version = 'dev-' . $branch;
|
||||
} else {
|
||||
$prefix = substr($branch, 0, 1) === 'v' ? 'v' : '';
|
||||
$prefix = strpos($branch, 'v') === 0 ? 'v' : '';
|
||||
$version = $prefix . preg_replace('{(\.9{7})+}', '.x', $parsedBranch);
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,8 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
|||
$this->addPackage($cachedPackage);
|
||||
|
||||
continue;
|
||||
} elseif ($cachedPackage === false) {
|
||||
}
|
||||
if ($cachedPackage === false) {
|
||||
$this->emptyReferences[] = $identifier;
|
||||
|
||||
continue;
|
||||
|
|
|
@ -444,7 +444,7 @@ class Filesystem
|
|||
*/
|
||||
public function isAbsolutePath($path)
|
||||
{
|
||||
return substr($path, 0, 1) === '/' || substr($path, 1, 1) === ':' || substr($path, 0, 2) === '\\\\';
|
||||
return strpos($path, '/') === 0 || substr($path, 1, 1) === ':' || strpos($path, '\\\\') === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -487,7 +487,7 @@ class Filesystem
|
|||
$path = substr($path, \strlen($prefix));
|
||||
}
|
||||
|
||||
if (substr($path, 0, 1) === '/') {
|
||||
if (strpos($path, '/') === 0) {
|
||||
$absolute = true;
|
||||
$path = substr($path, 1);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ use Composer\Downloader\MaxFileSizeExceededException;
|
|||
use Composer\IO\IOInterface;
|
||||
use Composer\Downloader\TransportException;
|
||||
use Composer\CaBundle\CaBundle;
|
||||
use Composer\Util\HttpDownloader;
|
||||
use Composer\Util\Http\Response;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +40,6 @@ class RemoteFilesystem
|
|||
private $options = array();
|
||||
private $peerCertificateMap = array();
|
||||
private $disableTls = false;
|
||||
private $retryAuthFailure;
|
||||
private $lastHeaders;
|
||||
private $storeAuth;
|
||||
private $authHelper;
|
||||
|
@ -206,13 +204,13 @@ class RemoteFilesystem
|
|||
$this->fileName = $fileName;
|
||||
$this->progress = $progress;
|
||||
$this->lastProgress = null;
|
||||
$this->retryAuthFailure = true;
|
||||
$retryAuthFailure = true;
|
||||
$this->lastHeaders = array();
|
||||
$this->redirects = 1; // The first request counts.
|
||||
|
||||
$tempAdditionalOptions = $additionalOptions;
|
||||
if (isset($tempAdditionalOptions['retry-auth-failure'])) {
|
||||
$this->retryAuthFailure = (bool) $tempAdditionalOptions['retry-auth-failure'];
|
||||
$retryAuthFailure = (bool) $tempAdditionalOptions['retry-auth-failure'];
|
||||
|
||||
unset($tempAdditionalOptions['retry-auth-failure']);
|
||||
}
|
||||
|
@ -239,7 +237,7 @@ class RemoteFilesystem
|
|||
$options['http']['ignore_errors'] = true;
|
||||
}
|
||||
|
||||
if ($this->degradedMode && substr($fileUrl, 0, 26) === 'http://repo.packagist.org/') {
|
||||
if ($this->degradedMode && strpos($fileUrl, 'http://repo.packagist.org/') === 0) {
|
||||
// access packagist using the resolved IPv4 instead of the hostname to force IPv4 protocol
|
||||
$fileUrl = 'http://' . gethostbyname('repo.packagist.org') . substr($fileUrl, 20);
|
||||
$degradedPackagist = true;
|
||||
|
@ -255,7 +253,7 @@ class RemoteFilesystem
|
|||
|
||||
$actualContextOptions = stream_context_get_options($ctx);
|
||||
$usingProxy = !empty($actualContextOptions['http']['proxy']) ? ' using proxy ' . $actualContextOptions['http']['proxy'] : '';
|
||||
$this->io->writeError((substr($origFileUrl, 0, 4) === 'http' ? 'Downloading ' : 'Reading ') . Url::sanitize($origFileUrl) . $usingProxy, true, IOInterface::DEBUG);
|
||||
$this->io->writeError((strpos($origFileUrl, 'http') === 0 ? 'Downloading ' : 'Reading ') . Url::sanitize($origFileUrl) . $usingProxy, true, IOInterface::DEBUG);
|
||||
unset($origFileUrl, $actualContextOptions);
|
||||
|
||||
// Check for secure HTTP, but allow insecure Packagist calls to $hashed providers as file integrity is verified with sha256
|
||||
|
@ -283,12 +281,12 @@ class RemoteFilesystem
|
|||
$result = $this->getRemoteContents($originUrl, $fileUrl, $ctx, $http_response_header, $maxFileSize);
|
||||
|
||||
if (!empty($http_response_header[0])) {
|
||||
$statusCode = $this->findStatusCode($http_response_header);
|
||||
$statusCode = self::findStatusCode($http_response_header);
|
||||
if ($statusCode >= 400 && Response::findHeaderValue($http_response_header, 'content-type') === 'application/json') {
|
||||
HttpDownloader::outputWarnings($this->io, $originUrl, json_decode($result, true));
|
||||
}
|
||||
|
||||
if (in_array($statusCode, array(401, 403)) && $this->retryAuthFailure) {
|
||||
if (in_array($statusCode, array(401, 403)) && $retryAuthFailure) {
|
||||
$this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $http_response_header);
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +296,7 @@ class RemoteFilesystem
|
|||
// alas, this is not possible via the stream callback because STREAM_NOTIFY_COMPLETED is documented, but not implemented anywhere in PHP
|
||||
$e = new TransportException('Content-Length mismatch, received '.Platform::strlen($result).' bytes out of the expected '.$contentLength);
|
||||
$e->setHeaders($http_response_header);
|
||||
$e->setStatusCode($this->findStatusCode($http_response_header));
|
||||
$e->setStatusCode(self::findStatusCode($http_response_header));
|
||||
try {
|
||||
$e->setResponse($this->decodeResult($result, $http_response_header));
|
||||
} catch (\Exception $e) {
|
||||
|
@ -324,7 +322,7 @@ class RemoteFilesystem
|
|||
} catch (\Exception $e) {
|
||||
if ($e instanceof TransportException && !empty($http_response_header[0])) {
|
||||
$e->setHeaders($http_response_header);
|
||||
$e->setStatusCode($this->findStatusCode($http_response_header));
|
||||
$e->setStatusCode(self::findStatusCode($http_response_header));
|
||||
}
|
||||
if ($e instanceof TransportException && $result !== false) {
|
||||
$e->setResponse($this->decodeResult($result, $http_response_header));
|
||||
|
@ -354,7 +352,7 @@ class RemoteFilesystem
|
|||
$contentType = null;
|
||||
$locationHeader = null;
|
||||
if (!empty($http_response_header[0])) {
|
||||
$statusCode = $this->findStatusCode($http_response_header);
|
||||
$statusCode = self::findStatusCode($http_response_header);
|
||||
$contentType = Response::findHeaderValue($http_response_header, 'content-type');
|
||||
$locationHeader = Response::findHeaderValue($http_response_header, 'location');
|
||||
}
|
||||
|
@ -367,7 +365,7 @@ class RemoteFilesystem
|
|||
&& $contentType && preg_match('{^text/html\b}i', $contentType)
|
||||
) {
|
||||
$result = false;
|
||||
if ($this->retryAuthFailure) {
|
||||
if ($retryAuthFailure) {
|
||||
$this->promptAuthAndRetry(401);
|
||||
}
|
||||
}
|
||||
|
@ -378,7 +376,7 @@ class RemoteFilesystem
|
|||
&& false !== strpos($fileUrl, 'archive.zip')
|
||||
) {
|
||||
$result = false;
|
||||
if ($this->retryAuthFailure) {
|
||||
if ($retryAuthFailure) {
|
||||
$this->promptAuthAndRetry(401);
|
||||
}
|
||||
}
|
||||
|
@ -411,7 +409,7 @@ class RemoteFilesystem
|
|||
}
|
||||
|
||||
// decode gzip
|
||||
if ($result && extension_loaded('zlib') && substr($fileUrl, 0, 4) === 'http' && !$hasFollowedRedirect) {
|
||||
if ($result && extension_loaded('zlib') && strpos($fileUrl, 'http') === 0 && !$hasFollowedRedirect) {
|
||||
try {
|
||||
$result = $this->decodeResult($result, $http_response_header);
|
||||
} catch (\Exception $e) {
|
||||
|
@ -558,6 +556,7 @@ class RemoteFilesystem
|
|||
throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . Platform::strlen($result) . ' of allowed ' . $maxFileSize . ' bytes');
|
||||
}
|
||||
|
||||
// https://www.php.net/manual/en/reserved.variables.httpresponseheader.php
|
||||
$responseHeaders = isset($http_response_header) ? $http_response_header : array();
|
||||
|
||||
if (null !== $e) {
|
||||
|
|
|
@ -57,7 +57,7 @@ final class StreamContextFactory
|
|||
/**
|
||||
* @param string $url
|
||||
* @param array $options
|
||||
* @psalm-return array{http:{header: string[], proxy?: string, request_fulluri: bool}, ssl: array}
|
||||
* @psalm-return array{http:{header: string[], proxy?: string, request_fulluri: bool}, ssl: array}
|
||||
* @return array formatted as a stream context array
|
||||
*/
|
||||
public static function initOptions($url, array $options)
|
||||
|
@ -99,9 +99,9 @@ final class StreamContextFactory
|
|||
|
||||
if (isset($proxy['port'])) {
|
||||
$proxyURL .= ":" . $proxy['port'];
|
||||
} elseif ('http://' == substr($proxyURL, 0, 7)) {
|
||||
} elseif (strpos($proxyURL, 'http://') === 0) {
|
||||
$proxyURL .= ":80";
|
||||
} elseif ('https://' == substr($proxyURL, 0, 8)) {
|
||||
} elseif (strpos($proxyURL, 'https://') === 0) {
|
||||
$proxyURL .= ":443";
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ class Svn
|
|||
if ($type !== 'out') {
|
||||
return;
|
||||
}
|
||||
if ('Redirecting to URL ' === substr($buffer, 0, 19)) {
|
||||
if (strpos($buffer, 'Redirecting to URL ') === 0) {
|
||||
return;
|
||||
}
|
||||
$output .= $buffer;
|
||||
|
|
Loading…
Reference in New Issue