Skip to content

Commit

Permalink
switched array() to []
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 16, 2019
1 parent 5dab0d4 commit 23c29c4
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 115 deletions.
2 changes: 1 addition & 1 deletion ClockMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static function register($class)
{
$self = \get_called_class();

$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
$mockedNs = [substr($class, 0, strrpos($class, '\\'))];
if (0 < strpos($class, '\\Tests\\')) {
$ns = str_replace('\\Tests\\', '\\', $class);
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));
Expand Down
52 changes: 26 additions & 26 deletions DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public static function register($mode = 0)
if (false === $mode) {
$mode = getenv('SYMFONY_DEPRECATIONS_HELPER');
}
if (DeprecationErrorHandler::MODE_DISABLED !== $mode
&& DeprecationErrorHandler::MODE_WEAK !== $mode
&& DeprecationErrorHandler::MODE_WEAK_VENDORS !== $mode
if (self::MODE_DISABLED !== $mode
&& self::MODE_WEAK !== $mode
&& self::MODE_WEAK_VENDORS !== $mode
&& (!isset($mode[0]) || '/' !== $mode[0])
) {
$mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0;
Expand Down Expand Up @@ -92,29 +92,29 @@ public static function register($mode = 0)
return false;
};

$deprecations = array(
$deprecations = [
'unsilencedCount' => 0,
'remainingCount' => 0,
'legacyCount' => 0,
'otherCount' => 0,
'remaining vendorCount' => 0,
'unsilenced' => array(),
'remaining' => array(),
'legacy' => array(),
'other' => array(),
'remaining vendor' => array(),
);
$deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) {
'unsilenced' => [],
'remaining' => [],
'legacy' => [],
'other' => [],
'remaining vendor' => [],
];
$deprecationHandler = function ($type, $msg, $file, $line, $context = []) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) {
$mode = $getMode();
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || DeprecationErrorHandler::MODE_DISABLED === $mode) {
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || self::MODE_DISABLED === $mode) {
$ErrorHandler = $UtilPrefix.'ErrorHandler';

return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
}

$trace = debug_backtrace();
$group = 'other';
$isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $inVendors($file);
$isVendor = self::MODE_WEAK_VENDORS === $mode && $inVendors($file);

$i = \count($trace);
while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) {
Expand All @@ -131,7 +131,7 @@ public static function register($mode = 0)
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
// then we need to use the serialized information to determine
// if the error has been triggered from vendor code.
$isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']);
$isVendor = self::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']);
} else {
$class = isset($trace[$i]['object']) ? \get_class($trace[$i]['object']) : $trace[$i]['class'];
$method = $trace[$i]['function'];
Expand Down Expand Up @@ -168,13 +168,13 @@ public static function register($mode = 0)

exit(1);
}
if ('legacy' !== $group && DeprecationErrorHandler::MODE_WEAK !== $mode) {
if ('legacy' !== $group && self::MODE_WEAK !== $mode) {
$ref = &$deprecations[$group][$msg]['count'];
++$ref;
$ref = &$deprecations[$group][$msg][$class.'::'.$method];
++$ref;
}
} elseif (DeprecationErrorHandler::MODE_WEAK !== $mode) {
} elseif (self::MODE_WEAK !== $mode) {
$ref = &$deprecations[$group][$msg]['count'];
++$ref;
}
Expand All @@ -184,7 +184,7 @@ public static function register($mode = 0)

if (null !== $oldErrorHandler) {
restore_error_handler();
if (array($UtilPrefix.'ErrorHandler', 'handleError') === $oldErrorHandler) {
if ([$UtilPrefix.'ErrorHandler', 'handleError'] === $oldErrorHandler) {
restore_error_handler();
self::register($mode);
}
Expand All @@ -207,7 +207,7 @@ public static function register($mode = 0)
$currErrorHandler = set_error_handler('var_dump');
restore_error_handler();

if (DeprecationErrorHandler::MODE_WEAK === $mode) {
if (self::MODE_WEAK === $mode) {
$colorize = function ($str) { return $str; };
}
if ($currErrorHandler !== $deprecationHandler) {
Expand All @@ -218,8 +218,8 @@ public static function register($mode = 0)
return $b['count'] - $a['count'];
};

$groups = array('unsilenced', 'remaining');
if (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode) {
$groups = ['unsilenced', 'remaining'];
if (self::MODE_WEAK_VENDORS === $mode) {
$groups[] = 'remaining vendor';
}
array_push($groups, 'legacy', 'other');
Expand Down Expand Up @@ -255,11 +255,11 @@ public static function register($mode = 0)
$displayDeprecations($deprecations);

// store failing status
$isFailing = DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount'];
$isFailing = self::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount'];

// reset deprecations array
foreach ($deprecations as $group => $arrayOrInt) {
$deprecations[$group] = \is_int($arrayOrInt) ? 0 : array();
$deprecations[$group] = \is_int($arrayOrInt) ? 0 : [];
}

register_shutdown_function(function () use (&$deprecations, $isFailing, $displayDeprecations, $mode) {
Expand All @@ -270,7 +270,7 @@ public static function register($mode = 0)
}
}
$displayDeprecations($deprecations);
if ($isFailing || DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) {
if ($isFailing || self::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) {
exit(1);
}
});
Expand All @@ -280,8 +280,8 @@ public static function register($mode = 0)

public static function collectDeprecations($outputFile)
{
$deprecations = array();
$previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, &$previousErrorHandler) {
$deprecations = [];
$previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$previousErrorHandler) {
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
if ($previousErrorHandler) {
return $previousErrorHandler($type, $msg, $file, $line, $context);
Expand All @@ -293,7 +293,7 @@ public static function collectDeprecations($outputFile)

return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
}
$deprecations[] = array(error_reporting(), $msg, $file);
$deprecations[] = [error_reporting(), $msg, $file];
});

register_shutdown_function(function () use ($outputFile, &$deprecations) {
Expand Down
16 changes: 8 additions & 8 deletions DnsMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
class DnsMock
{
private static $hosts = array();
private static $dnsTypes = array(
private static $hosts = [];
private static $dnsTypes = [
'A' => DNS_A,
'MX' => DNS_MX,
'NS' => DNS_NS,
Expand All @@ -30,7 +30,7 @@ class DnsMock
'NAPTR' => DNS_NAPTR,
'TXT' => DNS_TXT,
'HINFO' => DNS_HINFO,
);
];

/**
* Configures the mock values for DNS queries.
Expand Down Expand Up @@ -68,7 +68,7 @@ public static function getmxrr($hostname, &$mxhosts, &$weight = null)
if (!self::$hosts) {
return \getmxrr($hostname, $mxhosts, $weight);
}
$mxhosts = $weight = array();
$mxhosts = $weight = [];

if (isset(self::$hosts[$hostname])) {
foreach (self::$hosts[$hostname] as $record) {
Expand Down Expand Up @@ -125,7 +125,7 @@ public static function gethostbynamel($hostname)
$ips = false;

if (isset(self::$hosts[$hostname])) {
$ips = array();
$ips = [];

foreach (self::$hosts[$hostname] as $record) {
if ('A' === $record['type']) {
Expand All @@ -149,11 +149,11 @@ public static function dns_get_record($hostname, $type = DNS_ANY, &$authns = nul
if (DNS_ANY === $type) {
$type = DNS_ALL;
}
$records = array();
$records = [];

foreach (self::$hosts[$hostname] as $record) {
if (isset(self::$dnsTypes[$record['type']]) && (self::$dnsTypes[$record['type']] & $type)) {
$records[] = array_merge(array('host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']), $record);
$records[] = array_merge(['host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']], $record);
}
}
}
Expand All @@ -165,7 +165,7 @@ public static function register($class)
{
$self = \get_called_class();

$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
$mockedNs = [substr($class, 0, strrpos($class, '\\'))];
if (0 < strpos($class, '\\Tests\\')) {
$ns = str_replace('\\Tests\\', '\\', $class);
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));
Expand Down
14 changes: 7 additions & 7 deletions Legacy/CoverageListenerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(callable $sutFqcnResolver = null, $warningOnSutNotFo
{
$this->sutFqcnResolver = $sutFqcnResolver;
$this->warningOnSutNotFound = $warningOnSutNotFound;
$this->warnings = array();
$this->warnings = [];
}

public function startTest($test)
Expand All @@ -42,7 +42,7 @@ public function startTest($test)

$annotations = $test->getAnnotations();

$ignoredAnnotations = array('covers', 'coversDefaultClass', 'coversNothing');
$ignoredAnnotations = ['covers', 'coversDefaultClass', 'coversNothing'];

foreach ($ignoredAnnotations as $annotation) {
if (isset($annotations['class'][$annotation]) || isset($annotations['method'][$annotation])) {
Expand Down Expand Up @@ -74,11 +74,11 @@ public function startTest($test)
$r->setAccessible(true);

$cache = $r->getValue();
$cache = array_replace_recursive($cache, array(
\get_class($test) => array(
'covers' => array($sutFqcn),
),
));
$cache = array_replace_recursive($cache, [
\get_class($test) => [
'covers' => [$sutFqcn],
],
]);
$r->setValue($testClass, $cache);
}

Expand Down
2 changes: 1 addition & 1 deletion Legacy/SymfonyTestsListenerForV5.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SymfonyTestsListenerForV5 extends \PHPUnit_Framework_BaseTestListener
{
private $trait;

public function __construct(array $mockedNamespaces = array())
public function __construct(array $mockedNamespaces = [])
{
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
}
Expand Down
2 changes: 1 addition & 1 deletion Legacy/SymfonyTestsListenerForV6.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SymfonyTestsListenerForV6 extends BaseTestListener
{
private $trait;

public function __construct(array $mockedNamespaces = array())
public function __construct(array $mockedNamespaces = [])
{
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
}
Expand Down
2 changes: 1 addition & 1 deletion Legacy/SymfonyTestsListenerForV7.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SymfonyTestsListenerForV7 implements TestListener

private $trait;

public function __construct(array $mockedNamespaces = array())
public function __construct(array $mockedNamespaces = [])
{
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
}
Expand Down
Loading

0 comments on commit 23c29c4

Please sign in to comment.