Browse Source

Use fully qualified calls in hot classes

Jordi Boggiano 4 years ago
parent
commit
81bf47ffa2

+ 6 - 6
src/Composer/DependencyResolver/Decisions.php

@@ -108,17 +108,17 @@ class Decisions implements \Iterator, \Countable
 
     public function validOffset($queueOffset)
     {
-        return $queueOffset >= 0 && $queueOffset < count($this->decisionQueue);
+        return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
     }
 
     public function lastReason()
     {
-        return $this->decisionQueue[count($this->decisionQueue) - 1][self::DECISION_REASON];
+        return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_REASON];
     }
 
     public function lastLiteral()
     {
-        return $this->decisionQueue[count($this->decisionQueue) - 1][self::DECISION_LITERAL];
+        return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_LITERAL];
     }
 
     public function reset()
@@ -130,7 +130,7 @@ class Decisions implements \Iterator, \Countable
 
     public function resetToOffset($offset)
     {
-        while (count($this->decisionQueue) > $offset + 1) {
+        while (\count($this->decisionQueue) > $offset + 1) {
             $decision = array_pop($this->decisionQueue);
             $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
         }
@@ -144,7 +144,7 @@ class Decisions implements \Iterator, \Countable
 
     public function count()
     {
-        return count($this->decisionQueue);
+        return \count($this->decisionQueue);
     }
 
     public function rewind()
@@ -174,7 +174,7 @@ class Decisions implements \Iterator, \Countable
 
     public function isEmpty()
     {
-        return count($this->decisionQueue) === 0;
+        return \count($this->decisionQueue) === 0;
     }
 
     protected function addDecision($literal, $level)

+ 1 - 1
src/Composer/DependencyResolver/DefaultPolicy.php

@@ -60,7 +60,7 @@ class DefaultPolicy implements PolicyInterface
             $sortedLiterals = $this->pruneRemoteAliases($pool, $sortedLiterals);
         }
 
-        $selected = call_user_func_array('array_merge', $packages);
+        $selected = \call_user_func_array('array_merge', $packages);
 
         // now sort the result across all packages to respect replaces across packages
         usort($selected, function ($a, $b) use ($policy, $pool, $requiredPackage) {

+ 1 - 1
src/Composer/DependencyResolver/GenericRule.php

@@ -64,7 +64,7 @@ class GenericRule extends Rule
 
     public function isAssertion()
     {
-        return 1 === count($this->literals);
+        return 1 === \count($this->literals);
     }
 
     /**

+ 1 - 1
src/Composer/DependencyResolver/MultiConflictRule.php

@@ -33,7 +33,7 @@ class MultiConflictRule extends Rule
     {
         parent::__construct($reason, $reasonData);
 
-        if (count($literals) < 3) {
+        if (\count($literals) < 3) {
             throw new \RuntimeException("multi conflict rule requires at least 3 literals");
         }
 

+ 2 - 2
src/Composer/DependencyResolver/Pool.php

@@ -71,7 +71,7 @@ class Pool implements \Countable
      */
     public function count()
     {
-        return count($this->packages);
+        return \count($this->packages);
     }
 
     /**
@@ -189,6 +189,6 @@ class Pool implements \Countable
 
     public function isUnacceptableFixedPackage(PackageInterface $package)
     {
-        return in_array($package, $this->unacceptableFixedPackages, true);
+        return \in_array($package, $this->unacceptableFixedPackages, true);
     }
 }

+ 3 - 3
src/Composer/DependencyResolver/PoolBuilder.php

@@ -161,7 +161,7 @@ class PoolBuilder
         // filter packages according to all the require statements collected for each package
         $nameConstraints = array();
         foreach ($this->nameConstraints as $name => $constraints) {
-            if (is_array($constraints)) {
+            if (\is_array($constraints)) {
                 $nameConstraints[$name] = MultiConstraint::create(array_values(array_unique($constraints)), false);
             }
         }
@@ -275,9 +275,9 @@ class PoolBuilder
 
             $linkConstraint = $link->getConstraint();
             if ($linkConstraint && !($linkConstraint instanceof EmptyConstraint)) {
-                if (!array_key_exists($require, $this->nameConstraints)) {
+                if (!\array_key_exists($require, $this->nameConstraints)) {
                     $this->nameConstraints[$require] = array($linkConstraint);
-                } elseif (is_array($this->nameConstraints[$require])) {
+                } elseif (\is_array($this->nameConstraints[$require])) {
                     $this->nameConstraints[$require][] = $linkConstraint;
                 }
                 // else it is null and should stay null

+ 1 - 1
src/Composer/DependencyResolver/Rule.php

@@ -264,7 +264,7 @@ abstract class Rule
     {
         $prepared = array();
         foreach ($packages as $index => $package) {
-            if (!is_object($package)) {
+            if (!\is_object($package)) {
                 $packages[$index] = $pool->literalToPackage($package);
             }
         }

+ 1 - 1
src/Composer/DependencyResolver/Rule2Literals.php

@@ -76,7 +76,7 @@ class Rule2Literals extends Rule
         }
 
         $literals = $rule->getLiterals();
-        if (2 != count($literals)) {
+        if (2 != \count($literals)) {
             return false;
         }
 

+ 4 - 4
src/Composer/DependencyResolver/RuleSet.php

@@ -65,7 +65,7 @@ class RuleSet implements \IteratorAggregate, \Countable
         // Do not add if rule already exists
         if (isset($this->rulesByHash[$hash])) {
             $potentialDuplicates = $this->rulesByHash[$hash];
-            if (is_array($potentialDuplicates)) {
+            if (\is_array($potentialDuplicates)) {
                 foreach ($potentialDuplicates as $potentialDuplicate) {
                     if ($rule->equals($potentialDuplicate)) {
                         return;
@@ -90,7 +90,7 @@ class RuleSet implements \IteratorAggregate, \Countable
 
         if (!isset($this->rulesByHash[$hash])) {
             $this->rulesByHash[$hash] = $rule;
-        } elseif (is_array($this->rulesByHash[$hash])) {
+        } elseif (\is_array($this->rulesByHash[$hash])) {
             $this->rulesByHash[$hash][] = $rule;
         } else {
             $originalRule = $this->rulesByHash[$hash];
@@ -120,7 +120,7 @@ class RuleSet implements \IteratorAggregate, \Countable
 
     public function getIteratorFor($types)
     {
-        if (!is_array($types)) {
+        if (!\is_array($types)) {
             $types = array($types);
         }
 
@@ -136,7 +136,7 @@ class RuleSet implements \IteratorAggregate, \Countable
 
     public function getIteratorWithout($types)
     {
-        if (!is_array($types)) {
+        if (!\is_array($types)) {
             $types = array($types);
         }
 

+ 2 - 2
src/Composer/DependencyResolver/RuleSetGenerator.php

@@ -120,7 +120,7 @@ class RuleSetGenerator
             $literals[] = -$package->id;
         }
 
-        if (count($literals) == 2) {
+        if (\count($literals) == 2) {
             return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData);
         }
 
@@ -207,7 +207,7 @@ class RuleSetGenerator
         }
 
         foreach ($this->addedPackagesByNames as $name => $packages) {
-            if (count($packages) > 1) {
+            if (\count($packages) > 1) {
                 $reason = Rule::RULE_PACKAGE_SAME_NAME;
                 $this->addRule(RuleSet::TYPE_PACKAGE, $this->createMultiConflictRule($packages, $reason, $name));
             }

+ 3 - 3
src/Composer/DependencyResolver/RuleSetIterator.php

@@ -51,7 +51,7 @@ class RuleSetIterator implements \Iterator
             return;
         }
 
-        if ($this->currentOffset >= count($this->rules[$this->currentType])) {
+        if ($this->currentOffset >= \count($this->rules[$this->currentType])) {
             $this->currentOffset = 0;
 
             do {
@@ -63,7 +63,7 @@ class RuleSetIterator implements \Iterator
                 }
 
                 $this->currentType = $this->types[$this->currentTypeOffset];
-            } while (isset($this->types[$this->currentTypeOffset]) && !count($this->rules[$this->currentType]));
+            } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
         }
     }
 
@@ -83,7 +83,7 @@ class RuleSetIterator implements \Iterator
             }
 
             $this->currentType = $this->types[$this->currentTypeOffset];
-        } while (isset($this->types[$this->currentTypeOffset]) && !count($this->rules[$this->currentType]));
+        } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
     }
 
     public function valid()

+ 2 - 2
src/Composer/DependencyResolver/RuleWatchNode.php

@@ -37,7 +37,7 @@ class RuleWatchNode
 
         $literals = $rule->getLiterals();
 
-        $literalCount = count($literals);
+        $literalCount = \count($literals);
         $this->watch1 = $literalCount > 0 ? $literals[0] : 0;
         $this->watch2 = $literalCount > 1 ? $literals[1] : 0;
     }
@@ -55,7 +55,7 @@ class RuleWatchNode
         $literals = $this->rule->getLiterals();
 
         // if there are only 2 elements, both are being watched anyway
-        if (count($literals) < 3 || $this->rule instanceof MultiConflictRule) {
+        if (\count($literals) < 3 || $this->rule instanceof MultiConflictRule) {
             return;
         }
 

+ 16 - 16
src/Composer/DependencyResolver/Solver.php

@@ -75,7 +75,7 @@ class Solver
      */
     public function getRuleSetSize()
     {
-        return count($this->rules);
+        return \count($this->rules);
     }
 
     public function getPool()
@@ -87,9 +87,9 @@ class Solver
 
     private function makeAssertionRuleDecisions()
     {
-        $decisionStart = count($this->decisions) - 1;
+        $decisionStart = \count($this->decisions) - 1;
 
-        $rulesCount = count($this->rules);
+        $rulesCount = \count($this->rules);
         for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
             $rule = $this->rules->ruleById[$ruleIndex];
 
@@ -269,10 +269,10 @@ class Solver
             }
 
             $this->decisions->revertLast();
-            $this->propagateIndex = count($this->decisions);
+            $this->propagateIndex = \count($this->decisions);
         }
 
-        while (!empty($this->branches) && $this->branches[count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
+        while (!empty($this->branches) && $this->branches[\count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
             array_pop($this->branches);
         }
     }
@@ -357,7 +357,7 @@ class Solver
         $selectedLiteral = array_shift($literals);
 
         // if there are multiple candidates, then branch
-        if (count($literals)) {
+        if (\count($literals)) {
             $this->branches[] = array($literals, $level);
         }
 
@@ -378,12 +378,12 @@ class Solver
         $seen = array();
         $learnedLiterals = array(null);
 
-        $decisionId = count($this->decisions);
+        $decisionId = \count($this->decisions);
 
         $this->learnedPool[] = array();
 
         while (true) {
-            $this->learnedPool[count($this->learnedPool) - 1][] = $rule;
+            $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
 
             foreach ($rule->getLiterals() as $literal) {
                 // skip the one true literal
@@ -466,7 +466,7 @@ class Solver
             $rule = $decision[Decisions::DECISION_REASON];
         }
 
-        $why = count($this->learnedPool) - 1;
+        $why = \count($this->learnedPool) - 1;
 
         if (!$learnedLiterals[0]) {
             throw new SolverBugException(
@@ -647,7 +647,7 @@ class Solver
                             }
                         }
 
-                        if ($noneSatisfied && count($decisionQueue)) {
+                        if ($noneSatisfied && \count($decisionQueue)) {
                             // if any of the options in the decision queue are fixed, only use those
                             $prunedQueue = array();
                             foreach ($decisionQueue as $literal) {
@@ -660,7 +660,7 @@ class Solver
                             }
                         }
 
-                        if ($noneSatisfied && count($decisionQueue)) {
+                        if ($noneSatisfied && \count($decisionQueue)) {
                             $oLevel = $level;
                             $level = $this->selectAndInstall($level, $decisionQueue, $rule);
 
@@ -687,7 +687,7 @@ class Solver
                 $systemLevel = $level;
             }
 
-            $rulesCount = count($this->rules);
+            $rulesCount = \count($this->rules);
             $pass = 1;
 
             $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG);
@@ -734,7 +734,7 @@ class Solver
                 }
 
                 // need to have at least 2 item to pick from
-                if (count($decisionQueue) < 2) {
+                if (\count($decisionQueue) < 2) {
                     continue;
                 }
 
@@ -745,7 +745,7 @@ class Solver
                 }
 
                 // something changed, so look at all rules again
-                $rulesCount = count($this->rules);
+                $rulesCount = \count($this->rules);
                 $n = -1;
             }
 
@@ -754,13 +754,13 @@ class Solver
             }
 
             // minimization step
-            if (count($this->branches)) {
+            if (\count($this->branches)) {
                 $lastLiteral = null;
                 $lastLevel = null;
                 $lastBranchIndex = 0;
                 $lastBranchOffset = 0;
 
-                for ($i = count($this->branches) - 1; $i >= 0; $i--) {
+                for ($i = \count($this->branches) - 1; $i >= 0; $i--) {
                     list($literals, $l) = $this->branches[$i];
 
                     foreach ($literals as $offset => $literal) {

+ 1 - 1
src/Composer/Package/AliasPackage.php

@@ -179,7 +179,7 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
             $prettyVersion = $this->aliasOf->getPrettyVersion();
         }
 
-        if (in_array($linkType, array('conflicts', 'provides', 'replaces'), true)) {
+        if (\in_array($linkType, array('conflicts', 'provides', 'replaces'), true)) {
             $newLinks = array();
             foreach ($links as $link) {
                 // link is self.version, but must be replacing also the replaced version

+ 2 - 2
src/Composer/Package/BasePackage.php

@@ -215,7 +215,7 @@ abstract class BasePackage implements PackageInterface
     public function getFullPrettyVersion($truncate = true, $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV)
     {
         if ($displayMode === PackageInterface::DISPLAY_SOURCE_REF_IF_DEV &&
-            (!$this->isDev() || !in_array($this->getSourceType(), array('hg', 'git')))
+            (!$this->isDev() || !\in_array($this->getSourceType(), array('hg', 'git')))
         ) {
             return $this->getPrettyVersion();
         }
@@ -233,7 +233,7 @@ abstract class BasePackage implements PackageInterface
         }
 
         // if source reference is a sha1 hash -- truncate
-        if ($truncate && strlen($reference) === 40) {
+        if ($truncate && \strlen($reference) === 40) {
             return $this->getPrettyVersion() . ' ' . substr($reference, 0, 7);
         }
 

+ 1 - 1
src/Composer/Package/CompletePackage.php

@@ -213,6 +213,6 @@ class CompletePackage extends Package implements CompletePackageInterface
      */
     public function getReplacementPackage()
     {
-        return is_string($this->abandoned) ? $this->abandoned : null;
+        return \is_string($this->abandoned) ? $this->abandoned : null;
     }
 }

+ 3 - 3
src/Composer/Package/Dumper/ArrayDumper.php

@@ -109,7 +109,7 @@ class ArrayDumper
 
             $data = $this->dumpValues($package, $keys, $data);
 
-            if (isset($data['keywords']) && is_array($data['keywords'])) {
+            if (isset($data['keywords']) && \is_array($data['keywords'])) {
                 sort($data['keywords']);
             }
 
@@ -125,7 +125,7 @@ class ArrayDumper
             }
         }
 
-        if (count($package->getTransportOptions()) > 0) {
+        if (\count($package->getTransportOptions()) > 0) {
             $data['transport-options'] = $package->getTransportOptions();
         }
 
@@ -142,7 +142,7 @@ class ArrayDumper
             $getter = 'get'.ucfirst($method);
             $value = $package->$getter();
 
-            if (null !== $value && !(is_array($value) && 0 === count($value))) {
+            if (null !== $value && !(\is_array($value) && 0 === \count($value))) {
                 $data[$key] = $value;
             }
         }

+ 13 - 13
src/Composer/Package/Loader/ArrayLoader.php

@@ -109,7 +109,7 @@ class ArrayLoader implements LoaderInterface
             $package->setTargetDir($config['target-dir']);
         }
 
-        if (isset($config['extra']) && is_array($config['extra'])) {
+        if (isset($config['extra']) && \is_array($config['extra'])) {
             $package->setExtra($config['extra']);
         }
 
@@ -159,7 +159,7 @@ class ArrayLoader implements LoaderInterface
             }
         }
 
-        if (isset($config['suggest']) && is_array($config['suggest'])) {
+        if (isset($config['suggest']) && \is_array($config['suggest'])) {
             foreach ($config['suggest'] as $target => $reason) {
                 if ('self.version' === trim($reason)) {
                     $config['suggest'][$target] = $package->getPrettyVersion();
@@ -199,7 +199,7 @@ class ArrayLoader implements LoaderInterface
         }
 
         if ($package instanceof Package\CompletePackageInterface) {
-            if (isset($config['scripts']) && is_array($config['scripts'])) {
+            if (isset($config['scripts']) && \is_array($config['scripts'])) {
                 foreach ($config['scripts'] as $event => $listeners) {
                     $config['scripts'][$event] = (array) $listeners;
                 }
@@ -209,23 +209,23 @@ class ArrayLoader implements LoaderInterface
                 $package->setScripts($config['scripts']);
             }
 
-            if (!empty($config['description']) && is_string($config['description'])) {
+            if (!empty($config['description']) && \is_string($config['description'])) {
                 $package->setDescription($config['description']);
             }
 
-            if (!empty($config['homepage']) && is_string($config['homepage'])) {
+            if (!empty($config['homepage']) && \is_string($config['homepage'])) {
                 $package->setHomepage($config['homepage']);
             }
 
-            if (!empty($config['keywords']) && is_array($config['keywords'])) {
+            if (!empty($config['keywords']) && \is_array($config['keywords'])) {
                 $package->setKeywords($config['keywords']);
             }
 
             if (!empty($config['license'])) {
-                $package->setLicense(is_array($config['license']) ? $config['license'] : array($config['license']));
+                $package->setLicense(\is_array($config['license']) ? $config['license'] : array($config['license']));
             }
 
-            if (!empty($config['authors']) && is_array($config['authors'])) {
+            if (!empty($config['authors']) && \is_array($config['authors'])) {
                 $package->setAuthors($config['authors']);
             }
 
@@ -233,7 +233,7 @@ class ArrayLoader implements LoaderInterface
                 $package->setSupport($config['support']);
             }
 
-            if (!empty($config['funding']) && is_array($config['funding'])) {
+            if (!empty($config['funding']) && \is_array($config['funding'])) {
                 $package->setFunding($config['funding']);
             }
 
@@ -307,8 +307,8 @@ class ArrayLoader implements LoaderInterface
 
     private function createLink($source, $sourceVersion, $description, $target, $prettyConstraint)
     {
-        if (!is_string($prettyConstraint)) {
-            throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.gettype($prettyConstraint) . ' (' . var_export($prettyConstraint, true) . ')');
+        if (!\is_string($prettyConstraint)) {
+            throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.\gettype($prettyConstraint) . ' (' . var_export($prettyConstraint, true) . ')');
         }
         if ('self.version' === $prettyConstraint) {
             $parsedConstraint = $this->versionParser->parseConstraints($sourceVersion);
@@ -331,7 +331,7 @@ class ArrayLoader implements LoaderInterface
             return;
         }
 
-        if (isset($config['extra']['branch-alias']) && is_array($config['extra']['branch-alias'])) {
+        if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) {
             foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
                 // ensure it is an alias to a -dev package
                 if ('-dev' !== substr($targetBranch, -4)) {
@@ -361,7 +361,7 @@ class ArrayLoader implements LoaderInterface
             }
         }
 
-        if (in_array($config['version'], array('dev-master', 'dev-default', 'dev-trunk'), true)) {
+        if (\in_array($config['version'], array('dev-master', 'dev-default', 'dev-trunk'), true)) {
             return VersionParser::DEV_MASTER_ALIAS;
         }
     }

+ 1 - 1
src/Composer/Package/Package.php

@@ -619,7 +619,7 @@ class Package extends BasePackage
                 } else {
                     continue;
                 }
-                if (!in_array($mirrorUrl, $urls)) {
+                if (!\in_array($mirrorUrl, $urls)) {
                     $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
                     $func($urls, $mirrorUrl);
                 }

+ 15 - 15
src/Composer/Util/Filesystem.php

@@ -58,7 +58,7 @@ class Filesystem
             ->depth(0)
             ->in($dir);
 
-        return count($finder) === 0;
+        return \count($finder) === 0;
     }
 
     public function emptyDirectory($dir, $ensureDirectoryExists = true)
@@ -116,7 +116,7 @@ class Filesystem
             throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
         }
 
-        if (!function_exists('proc_open')) {
+        if (!\function_exists('proc_open')) {
             return $this->removeDirectoryPhp($directory);
         }
 
@@ -311,7 +311,7 @@ class Filesystem
             return;
         }
 
-        if (!function_exists('proc_open')) {
+        if (!\function_exists('proc_open')) {
             $this->copyThenRemove($source, $target);
 
             return;
@@ -369,13 +369,13 @@ class Filesystem
             $from = rtrim($from, '/') . '/dummy_file';
         }
 
-        if (dirname($from) === dirname($to)) {
+        if (\dirname($from) === \dirname($to)) {
             return './'.basename($to);
         }
 
         $commonPath = $to;
         while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath)) {
-            $commonPath = strtr(dirname($commonPath), '\\', '/');
+            $commonPath = strtr(\dirname($commonPath), '\\', '/');
         }
 
         if (0 !== strpos($from, $commonPath) || '/' === $commonPath) {
@@ -383,10 +383,10 @@ class Filesystem
         }
 
         $commonPath = rtrim($commonPath, '/') . '/';
-        $sourcePathDepth = substr_count(substr($from, strlen($commonPath)), '/');
+        $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/');
         $commonPathCode = str_repeat('../', $sourcePathDepth);
 
-        return ($commonPathCode . substr($to, strlen($commonPath))) ?: './';
+        return ($commonPathCode . substr($to, \strlen($commonPath))) ?: './';
     }
 
     /**
@@ -414,7 +414,7 @@ class Filesystem
 
         $commonPath = $to;
         while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
-            $commonPath = strtr(dirname($commonPath), '\\', '/');
+            $commonPath = strtr(\dirname($commonPath), '\\', '/');
         }
 
         if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
@@ -423,17 +423,17 @@ class Filesystem
 
         $commonPath = rtrim($commonPath, '/') . '/';
         if (strpos($to, $from.'/') === 0) {
-            return '__DIR__ . '.var_export(substr($to, strlen($from)), true);
+            return '__DIR__ . '.var_export(substr($to, \strlen($from)), true);
         }
-        $sourcePathDepth = substr_count(substr($from, strlen($commonPath)), '/') + $directories;
+        $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/') + $directories;
         if ($staticCode) {
             $commonPathCode = "__DIR__ . '".str_repeat('/..', $sourcePathDepth)."'";
         } else {
             $commonPathCode = str_repeat('dirname(', $sourcePathDepth).'__DIR__'.str_repeat(')', $sourcePathDepth);
         }
-        $relTarget = substr($to, strlen($commonPath));
+        $relTarget = substr($to, \strlen($commonPath));
 
-        return $commonPathCode . (strlen($relTarget) ? '.' . var_export('/' . $relTarget, true) : '');
+        return $commonPathCode . (\strlen($relTarget) ? '.' . var_export('/' . $relTarget, true) : '');
     }
 
     /**
@@ -484,7 +484,7 @@ class Filesystem
         // extract a prefix being a protocol://, protocol:, protocol://drive: or simply drive:
         if (preg_match('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
             $prefix = $match[1];
-            $path = substr($path, strlen($prefix));
+            $path = substr($path, \strlen($prefix));
         }
 
         if (substr($path, 0, 1) === '/') {
@@ -579,7 +579,7 @@ class Filesystem
         $cwd = getcwd();
 
         $relativePath = $this->findShortestPath($link, $target);
-        chdir(dirname($link));
+        chdir(\dirname($link));
         $result = @symlink($relativePath, $link);
 
         chdir($cwd);
@@ -632,7 +632,7 @@ class Filesystem
 
         $resolved = rtrim($pathname, '/');
 
-        if (!strlen($resolved)) {
+        if (!\strlen($resolved)) {
             return $pathname;
         }
 

+ 4 - 4
src/Composer/Util/Platform.php

@@ -55,7 +55,7 @@ class Platform
             return $home;
         }
 
-        if (function_exists('posix_getuid') && function_exists('posix_getpwuid')) {
+        if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
             $info = posix_getpwuid(posix_getuid());
 
             return $info['dir'];
@@ -69,7 +69,7 @@ class Platform
      */
     public static function isWindows()
     {
-        return defined('PHP_WINDOWS_VERSION_BUILD');
+        return \defined('PHP_WINDOWS_VERSION_BUILD');
     }
 
     /**
@@ -80,13 +80,13 @@ class Platform
     {
         static $useMbString = null;
         if (null === $useMbString) {
-            $useMbString = function_exists('mb_strlen') && ini_get('mbstring.func_overload');
+            $useMbString = \function_exists('mb_strlen') && ini_get('mbstring.func_overload');
         }
 
         if ($useMbString) {
             return mb_strlen($str, '8bit');
         }
 
-        return strlen($str);
+        return \strlen($str);
     }
 }