Skip to content

Commit

Permalink
Merge branch '2.8' into 3.4
Browse files Browse the repository at this point in the history
* 2.8:
  Fix Clidumper tests
  Enable the fixer enforcing fully-qualified calls for compiler-optimized functions
  Apply fixers
  Disable the native_constant_invocation fixer until it can be scoped
  Update the list of excluded files for the CS fixer
  • Loading branch information
nicolas-grekas committed Jul 26, 2018
2 parents c501f46 + 812df74 commit 68fe675
Show file tree
Hide file tree
Showing 28 changed files with 106 additions and 106 deletions.
8 changes: 4 additions & 4 deletions Caster/ArgsStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public function __construct(array $args, $function, $class)

return;
}
if (count($values) < count($params)) {
$params = array_slice($params, 0, count($values));
} elseif (count($values) > count($params)) {
$values[] = new EnumStub(array_splice($values, count($params)), false);
if (\count($values) < \count($params)) {
$params = \array_slice($params, 0, \count($values));
} elseif (\count($values) > \count($params)) {
$values[] = new EnumStub(array_splice($values, \count($params)), false);
$params[] = $variadic;
}
if (array('...') === $params) {
Expand Down
4 changes: 2 additions & 2 deletions Caster/Caster.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ public static function filter(array $a, $filter, array $listedProperties = array
} elseif (false === $v || '' === $v || '0' === $v || 0 === $v || 0.0 === $v || array() === $v) {
$type |= self::EXCLUDE_EMPTY & $filter;
}
if ((self::EXCLUDE_NOT_IMPORTANT & $filter) && !in_array($k, $listedProperties, true)) {
if ((self::EXCLUDE_NOT_IMPORTANT & $filter) && !\in_array($k, $listedProperties, true)) {
$type |= self::EXCLUDE_NOT_IMPORTANT;
}
if ((self::EXCLUDE_VERBOSE & $filter) && in_array($k, $listedProperties, true)) {
if ((self::EXCLUDE_VERBOSE & $filter) && \in_array($k, $listedProperties, true)) {
$type |= self::EXCLUDE_VERBOSE;
}

Expand Down
14 changes: 7 additions & 7 deletions Caster/ClassStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct($identifier, $callable = null)
$this->value = $identifier;

if (0 < $i = strrpos($identifier, '\\')) {
$this->attr['ellipsis'] = strlen($identifier) - $i;
$this->attr['ellipsis'] = \strlen($identifier) - $i;
$this->attr['ellipsis-type'] = 'class';
$this->attr['ellipsis-tail'] = 1;
}
Expand All @@ -36,9 +36,9 @@ public function __construct($identifier, $callable = null)
if (null !== $callable) {
if ($callable instanceof \Closure) {
$r = new \ReflectionFunction($callable);
} elseif (is_object($callable)) {
} elseif (\is_object($callable)) {
$r = array($callable, '__invoke');
} elseif (is_array($callable)) {
} elseif (\is_array($callable)) {
$r = $callable;
} elseif (false !== $i = strpos($callable, '::')) {
$r = array(substr($callable, 0, $i), substr($callable, 2 + $i));
Expand All @@ -51,7 +51,7 @@ public function __construct($identifier, $callable = null)
$r = new \ReflectionClass($identifier);
}

if (is_array($r)) {
if (\is_array($r)) {
try {
$r = new \ReflectionMethod($r[0], $r[1]);
} catch (\ReflectionException $e) {
Expand All @@ -70,13 +70,13 @@ public function __construct($identifier, $callable = null)

public static function wrapCallable($callable)
{
if (is_object($callable) || !is_callable($callable)) {
if (\is_object($callable) || !\is_callable($callable)) {
return $callable;
}

if (!is_array($callable)) {
if (!\is_array($callable)) {
$callable = new static($callable);
} elseif (is_string($callable[0])) {
} elseif (\is_string($callable[0])) {
$callable[0] = new static($callable[0]);
} else {
$callable[1] = new static($callable[1], $callable);
Expand Down
2 changes: 1 addition & 1 deletion Caster/CutArrayStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public function __construct(array $value, array $preservedKeys)
parent::__construct($value);

$this->preservedSubset = array_intersect_key($value, array_flip($preservedKeys));
$this->cut -= count($this->preservedSubset);
$this->cut -= \count($this->preservedSubset);
}
}
8 changes: 4 additions & 4 deletions Caster/CutStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ public function __construct($value)
{
$this->value = $value;

switch (gettype($value)) {
switch (\gettype($value)) {
case 'object':
$this->type = self::TYPE_OBJECT;
$this->class = get_class($value);
$this->class = \get_class($value);
$this->cut = -1;
break;

case 'array':
$this->type = self::TYPE_ARRAY;
$this->class = self::ARRAY_ASSOC;
$this->cut = $this->value = count($value);
$this->cut = $this->value = \count($value);
break;

case 'resource':
Expand All @@ -51,7 +51,7 @@ public function __construct($value)
case 'string':
$this->type = self::TYPE_STRING;
$this->class = preg_match('//u', $value) ? self::STRING_UTF8 : self::STRING_BINARY;
$this->cut = self::STRING_BINARY === $this->class ? strlen($value) : mb_strlen($value, 'UTF-8');
$this->cut = self::STRING_BINARY === $this->class ? \strlen($value) : mb_strlen($value, 'UTF-8');
$this->value = '';
break;
}
Expand Down
6 changes: 3 additions & 3 deletions Caster/DateCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stu
{
$location = $timeZone->getLocation();
$formatted = (new \DateTime('now', $timeZone))->format($location ? 'e (P)' : 'P');
$title = $location && extension_loaded('intl') ? \Locale::getDisplayRegion('-'.$location['country_code'], \Locale::getDefault()) : '';
$title = $location && \extension_loaded('intl') ? \Locale::getDisplayRegion('-'.$location['country_code'], \Locale::getDefault()) : '';

$z = array(Caster::PREFIX_VIRTUAL.'timezone' => new ConstStub($formatted, $title));

Expand All @@ -85,7 +85,7 @@ public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stu

public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, $isNested, $filter)
{
if (defined('HHVM_VERSION_ID') || \PHP_VERSION_ID < 50620 || (\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70005)) { // see https://bugs.php.net/bug.php?id=71635
if (\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID < 50620 || (\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70005)) { // see https://bugs.php.net/bug.php?id=71635
return $a;
}

Expand Down Expand Up @@ -124,6 +124,6 @@ private static function formatDateTime(\DateTimeInterface $d, $extra = '')

private static function formatSeconds($s, $us)
{
return sprintf('%02d.%s', $s, 0 === ($len = strlen($t = rtrim($us, '0'))) ? '0' : ($len <= 3 ? str_pad($t, 3, '0') : $us));
return sprintf('%02d.%s', $s, 0 === ($len = \strlen($t = rtrim($us, '0'))) ? '0' : ($len <= 3 ? str_pad($t, 3, '0') : $us));
}
}
14 changes: 7 additions & 7 deletions Caster/ExceptionCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public static function castThrowingCasterException(ThrowingCasterException $e, a

if (isset($a[$xPrefix.'previous'], $a[$trace]) && $a[$xPrefix.'previous'] instanceof \Exception) {
$b = (array) $a[$xPrefix.'previous'];
self::traceUnshift($b[$xPrefix.'trace'], get_class($a[$xPrefix.'previous']), $b[$prefix.'file'], $b[$prefix.'line']);
$a[$trace] = new TraceStub($b[$xPrefix.'trace'], false, 0, -count($a[$trace]->value));
self::traceUnshift($b[$xPrefix.'trace'], \get_class($a[$xPrefix.'previous']), $b[$prefix.'file'], $b[$prefix.'line']);
$a[$trace] = new TraceStub($b[$xPrefix.'trace'], false, 0, -\count($a[$trace]->value));
}

unset($a[$xPrefix.'previous'], $a[$prefix.'code'], $a[$prefix.'file'], $a[$prefix.'line']);
Expand Down Expand Up @@ -118,7 +118,7 @@ public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, $is
$prefix = Caster::PREFIX_VIRTUAL;

$a = array();
$j = count($frames);
$j = \count($frames);
if (0 > $i = $trace->sliceOffset) {
$i = max(0, $j + $i);
}
Expand Down Expand Up @@ -175,7 +175,7 @@ public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, $is
$lastCall = $call;
}
if (null !== $trace->sliceLength) {
$a = array_slice($a, 0, $trace->sliceLength, true);
$a = \array_slice($a, 0, $trace->sliceLength, true);
}

return $a;
Expand All @@ -199,7 +199,7 @@ public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, $is
$a[$prefix.'src'] = self::$framesCache[$cacheKey];
} else {
if (preg_match('/\((\d+)\)(?:\([\da-f]{32}\))? : (?:eval\(\)\'d code|runtime-created function)$/', $f['file'], $match)) {
$f['file'] = substr($f['file'], 0, -strlen($match[0]));
$f['file'] = substr($f['file'], 0, -\strlen($match[0]));
$f['line'] = (int) $match[1];
}
$caller = isset($f['function']) ? sprintf('in %s() on line %d', (isset($f['class']) ? $f['class'].$f['type'] : '').$f['function'], $f['line']) : null;
Expand All @@ -212,7 +212,7 @@ public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, $is

if (file_exists($f['file']) && 0 <= self::$srcContext) {
if (!empty($f['class']) && (is_subclass_of($f['class'], 'Twig\Template') || is_subclass_of($f['class'], 'Twig_Template')) && method_exists($f['class'], 'getDebugInfo')) {
$template = isset($f['object']) ? $f['object'] : unserialize(sprintf('O:%d:"%s":0:{}', strlen($f['class']), $f['class']));
$template = isset($f['object']) ? $f['object'] : unserialize(sprintf('O:%d:"%s":0:{}', \strlen($f['class']), $f['class']));

$ellipsis = 0;
$templateSrc = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getCode() : (method_exists($template, 'getSource') ? $template->getSource() : '');
Expand All @@ -231,7 +231,7 @@ public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, $is
$src = self::extractSource(file_get_contents($f['file']), $f['line'], self::$srcContext, $caller, 'php', $f['file']);
$srcKey .= ':'.$f['line'];
if ($ellipsis) {
$ellipsis += 1 + strlen($f['line']);
$ellipsis += 1 + \strlen($f['line']);
}
}
$srcAttr .= '&separator= ';
Expand Down
18 changes: 9 additions & 9 deletions Caster/LinkStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct($label, $line = 0, $href = null)
if (null === $href) {
$href = $label;
}
if (!is_string($href)) {
if (!\is_string($href)) {
return;
}
if (0 === strpos($href, 'file://')) {
Expand All @@ -53,11 +53,11 @@ public function __construct($label, $line = 0, $href = null)
return;
}
if ($composerRoot = $this->getComposerRoot($href, $this->inVendor)) {
$this->attr['ellipsis'] = strlen($href) - strlen($composerRoot) + 1;
$this->attr['ellipsis'] = \strlen($href) - \strlen($composerRoot) + 1;
$this->attr['ellipsis-type'] = 'path';
$this->attr['ellipsis-tail'] = 1 + ($this->inVendor ? 2 + strlen(implode(array_slice(explode(DIRECTORY_SEPARATOR, substr($href, 1 - $this->attr['ellipsis'])), 0, 2))) : 0);
} elseif (3 < count($ellipsis = explode(DIRECTORY_SEPARATOR, $href))) {
$this->attr['ellipsis'] = 2 + strlen(implode(array_slice($ellipsis, -2)));
$this->attr['ellipsis-tail'] = 1 + ($this->inVendor ? 2 + \strlen(implode(\array_slice(explode(DIRECTORY_SEPARATOR, substr($href, 1 - $this->attr['ellipsis'])), 0, 2))) : 0);
} elseif (3 < \count($ellipsis = explode(DIRECTORY_SEPARATOR, $href))) {
$this->attr['ellipsis'] = 2 + \strlen(implode(\array_slice($ellipsis, -2)));
$this->attr['ellipsis-type'] = 'path';
$this->attr['ellipsis-tail'] = 1;
}
Expand All @@ -71,7 +71,7 @@ private function getComposerRoot($file, &$inVendor)
foreach (get_declared_classes() as $class) {
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
$r = new \ReflectionClass($class);
$v = dirname(dirname($r->getFileName()));
$v = \dirname(\dirname($r->getFileName()));
if (file_exists($v.'/composer/installed.json')) {
self::$vendorRoots[] = $v.DIRECTORY_SEPARATOR;
}
Expand All @@ -80,7 +80,7 @@ private function getComposerRoot($file, &$inVendor)
}
$inVendor = false;

if (isset(self::$composerRoots[$dir = dirname($file)])) {
if (isset(self::$composerRoots[$dir = \dirname($file)])) {
return self::$composerRoots[$dir];
}

Expand All @@ -96,11 +96,11 @@ private function getComposerRoot($file, &$inVendor)
// open_basedir restriction in effect
break;
}
if ($parent === dirname($parent)) {
if ($parent === \dirname($parent)) {
return self::$composerRoots[$dir] = false;
}

$parent = dirname($parent);
$parent = \dirname($parent);
}

return self::$composerRoots[$dir] = $parent.DIRECTORY_SEPARATOR;
Expand Down
2 changes: 1 addition & 1 deletion Caster/PdoCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static function castPdo(\PDO $c, array $a, Stub $stub, $isNested)
}

try {
$attr[$k] = 'ERRMODE' === $k ? $errmode : $c->getAttribute(constant('PDO::ATTR_'.$k));
$attr[$k] = 'ERRMODE' === $k ? $errmode : $c->getAttribute(\constant('PDO::ATTR_'.$k));
if ($v && isset($v[$attr[$k]])) {
$attr[$k] = new ConstStub($v[$attr[$k]], $attr[$k]);
}
Expand Down
4 changes: 2 additions & 2 deletions Caster/RedisCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function castRedis(\Redis $c, array $a, Stub $stub, $isNested)
{
$prefix = Caster::PREFIX_VIRTUAL;

if (defined('HHVM_VERSION_ID')) {
if (\defined('HHVM_VERSION_ID')) {
if (isset($a[Caster::PREFIX_PROTECTED.'serializer'])) {
$ser = $a[Caster::PREFIX_PROTECTED.'serializer'];
$a[Caster::PREFIX_PROTECTED.'serializer'] = isset(self::$serializer[$ser]) ? new ConstStub(self::$serializer[$ser], $ser) : $ser;
Expand All @@ -46,7 +46,7 @@ public static function castRedis(\Redis $c, array $a, Stub $stub, $isNested)
}

$ser = $c->getOption(\Redis::OPT_SERIALIZER);
$retry = defined('Redis::OPT_SCAN') ? $c->getOption(\Redis::OPT_SCAN) : 0;
$retry = \defined('Redis::OPT_SCAN') ? $c->getOption(\Redis::OPT_SCAN) : 0;

return $a + array(
$prefix.'isConnected' => $connected,
Expand Down
2 changes: 1 addition & 1 deletion Caster/ReflectionCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, arra

if ($v = $c->getStaticVariables()) {
foreach ($v as $k => &$v) {
if (is_object($v)) {
if (\is_object($v)) {
$a[$prefix.'use']['$'.$k] = new CutStub($v);
} else {
$a[$prefix.'use']['$'.$k] = &$v;
Expand Down
4 changes: 2 additions & 2 deletions Caster/StubCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function castStub(Stub $c, array $a, Stub $stub, $isNested)
$stub->cut = $c->cut;
$stub->attr = $c->attr;

if (Stub::TYPE_REF === $c->type && !$c->class && is_string($c->value) && !preg_match('//u', $c->value)) {
if (Stub::TYPE_REF === $c->type && !$c->class && \is_string($c->value) && !preg_match('//u', $c->value)) {
$stub->type = Stub::TYPE_STRING;
$stub->class = Stub::STRING_BINARY;
}
Expand All @@ -49,7 +49,7 @@ public static function castCutArray(CutArrayStub $c, array $a, Stub $stub, $isNe
public static function cutInternals($obj, array $a, Stub $stub, $isNested)
{
if ($isNested) {
$stub->cut += count($a);
$stub->cut += \count($a);

return array();
}
Expand Down
6 changes: 3 additions & 3 deletions Cloner/AbstractCloner.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function __construct(array $casters = null)
$casters = static::$defaultCasters;
}
$this->addCasters($casters);
$this->useExt = extension_loaded('symfony_debug');
$this->useExt = \extension_loaded('symfony_debug');
}

/**
Expand All @@ -168,7 +168,7 @@ public function __construct(array $casters = null)
public function addCasters(array $casters)
{
foreach ($casters as $type => $callback) {
$this->casters[strtolower($type)][] = is_string($callback) && false !== strpos($callback, '::') ? explode('::', $callback, 2) : $callback;
$this->casters[strtolower($type)][] = \is_string($callback) && false !== strpos($callback, '::') ? explode('::', $callback, 2) : $callback;
}
}

Expand Down Expand Up @@ -220,7 +220,7 @@ public function cloneVar($var, $filter = 0)
}

if ($this->prevErrorHandler) {
return call_user_func($this->prevErrorHandler, $type, $msg, $file, $line, $context);
return \call_user_func($this->prevErrorHandler, $type, $msg, $file, $line, $context);
}

return false;
Expand Down
Loading

0 comments on commit 68fe675

Please sign in to comment.