8000 [PhpUnitBridge] cs fix · symfony/symfony@cd2dec3 · GitHub
[go: up one dir, main page]

Skip to content

Commit cd2dec3

Browse files
[PhpUnitBridge] cs fix
1 parent cacb503 commit cd2dec3

9 files changed

+40
-44
lines changed

src/Symfony/Bridge/PhpUnit/ClockMock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public static function register($class)
9494
{
9595
$self = \get_called_class();
9696

97-
$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
97+
$mockedNs = [substr($class, 0, strrpos($class, '\\'))];
9898
if (0 < strpos($class, '\\Tests\\')) {
9999
$ns = str_replace('\\Tests\\', '\\', $class);
100100
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));

src/Symfony/Bridge/PhpUnit/DnsMock.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717
class DnsMock
1818
{
19-
private static $hosts = array();
20-
private static $dnsTypes = array(
19+
private static $hosts = [];
20+
private static $dnsTypes = [
2121
'A' => DNS_A,
2222
'MX' => DNS_MX,
2323
'NS' => DNS_NS,
@@ -30,7 +30,7 @@ class DnsMock
3030
'NAPTR' => DNS_NAPTR,
3131
'TXT' => DNS_TXT,
3232
'HINFO' => DNS_HINFO,
33-
);
33+
];
3434

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

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

127127
if (isset(self::$hosts[$hostname])) {
128-
$ips = array();
128+
$ips = [];
129129

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

154154
foreach (self::$hosts[$hostname] as $record) {
155155
if (isset(self::$dnsTypes[$record['type']]) && (self::$dnsTypes[$record['type']] & $type)) {
156-
$records[] = array_merge(array('host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']), $record);
156+
$records[] = array_merge(['host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']], $record);
157157
}
158158
}
159159
}
@@ -165,7 +165,7 @@ public static function register($class)
165165
{
166166
$self = \get_called_class();
167167

168-
$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
168+
$mockedNs = [substr($class, 0, strrpos($class, '\\'))];
169169
if (0 < strpos($class, '\\Tests\\')) {
170170
$ns = str_replace('\\Tests\\', '\\', $class);
171171
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));

src/Symfony/Bridge/PhpUnit/Legacy/CommandForV5.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CommandForV5 extends \PHPUnit_TextUI_Command
2323
*/
2424
protected function createRunner()
2525
{
26-
$this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : array();
26+
$this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : [];
2727

2828
$registeredLocally = false;
2929

src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(callable $sutFqcnResolver = null, $warningOnSutNotFo
3232
{
3333
$this->sutFqcnResolver = $sutFqcnResolver;
3434
$this->warningOnSutNotFound = $warningOnSutNotFound;
35-
$this->warnings = array();
35+
$this->warnings = [];
3636
}
3737

3838
public function startTest($test)
@@ -43,7 +43,7 @@ public function startTest($test)
4343

4444
$annotations = $test->getAnnotations();
4545

46-
$ignoredAnnotations = array('covers', 'coversDefaultClass', 'coversNothing');
46+
$ignoredAnnotations = ['covers', 'coversDefaultClass', 'coversNothing'];
4747

4848
foreach ($ignoredAnnotations as $annotation) {
4949
if (isset($annotations['class'][$annotation]) || isset($annotations['method'][$annotation])) {
@@ -70,11 +70,11 @@ public function startTest($test)
7070
$r->setAccessible(true);
7171

7272
$cache = $r->getValue();
73-
$cache = array_replace_recursive($cache, array(
74-
\get_class($test) => array(
75-
'covers' => \is_array($sutFqcn) ? $sutFqcn : array($sutFqcn),
76-
),
77-
));
73+
$cache = array_replace_recursive($cache, [
74+
\get_class($test) => [
75+
'covers' => \is_array($sutFqcn) ? $sutFqcn : [$sutFqcn],
76+
],
77+
]);
7878
$r->setValue(Test::class, $cache);
7979
}
8080

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SymfonyTestsListenerForV5 extends \PHPUnit_Framework_BaseTestListener
2222
{
2323
private $trait;
2424

25-
public function __construct(array $mockedNamespaces = array())
25+
public function __construct(array $mockedNamespaces = [])
2626
{
2727
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
2828
}

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use PHPUnit\Framework\BaseTestListener;
1515
use PHPUnit\Framework\Test;
1616
use PHPUnit\Framework\TestSuite;
17-
use PHPUnit\Framework\Warning;
1817

1918
/**
2019
* Collects and replays skipped tests.
@@ -27,7 +26,7 @@ class SymfonyTestsListenerForV6 extends BaseTestListener
2726
{
2827
private $trait;
2928

30-
public function __construct(array $mockedNamespaces = array())
29+
public function __construct(array $mockedNamespaces = [])
3130
{
3231
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
3332
}

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use PHPUnit\Framework\TestListener;
1616
use PHPUnit\Framework\TestListenerDefaultImplementation;
1717
use PHPUnit\Framework\TestSuite;
18-
use PHPUnit\Framework\Warning;
1918

2019
/**
2120
* Collects and replays skipped tests.
@@ -30,7 +29,7 @@ class SymfonyTestsListenerForV7 implements TestListener
3029

3130
private $trait;
3231

33-
public function __construct(array $mockedNamespaces = array())
32+
public function __construct(array $mockedNamespaces = [])
3433
{
3534
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
3635
}

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,26 @@ class SymfonyTestsListenerTrait
3535
private static $globallyEnabled = false;
3636
private $state = -1;
3737
private $skippedFile = false;
38-
private $wasSkipped = array();
39-
private $isSkipped = array();
40-
private $expectedDeprecations = array();
41-
private $gatheredDeprecations = array();
38+
private $wasSkipped = [];
39+
private $isSkipped = [];
40+
private $expectedDeprecations = [];
41+
private $gatheredDeprecations = [];
4242
private $previousErrorHandler;
4343
private $error;
4444
private $runsInSeparateProcess = false;
4545

4646
/**
4747
* @param array $mockedNamespaces List of namespaces, indexed by mocked features (time-sensitive or dns-sensitive)
4848
*/
49-
public function __construct(array $mockedNamespaces = array())
49+
public function __construct(array $mockedNamespaces = [])
5050
{
5151
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2;
5252

5353
$enableDebugClassLoader = class_exists(DebugClassLoader::class) || class_exists(LegacyDebugClassLoader::class);
5454

5555
foreach ($mockedNamespaces as $type => $namespaces) {
5656
if (!\is_array($namespaces)) {
57-
$namespaces = array($namespaces);
57+
$namespaces = [$namespaces];
5858
}
5959
if ('time-sensitive' === $type) {
6060
foreach ($namespaces as $ns) {
@@ -140,11 +140,11 @@ public function startTestSuite($suite)
140140

141141
if (!$this->wasSkipped = require $this->skippedFile) {
142142
echo "All tests already ran successfully.\n";
143-
$suite->setTests(array());
143+
$suite->setTests([]);
144144
}
145145
}
146146
}
147-
$testSuites = array($suite);
147+
$testSuites = [$suite];
148148
for ($i = 0; isset($testSuites[$i]); ++$i) {
149149
foreach ($testSuites[$i]->tests() as $test) {
150150
if ($test instanceof TestSuite) {
@@ -163,7 +163,7 @@ public function startTestSuite($suite)
163163
}
164164
}
165165
} elseif (2 === $this->state) {
166-
$skipped = array();
166+
$skipped = [];
167167
foreach ($suite->tests() as $test) {
168168
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)
169169
|| isset($this->wasSkipped[$suiteName]['*'])
@@ -228,7 +228,7 @@ public function startTest($test)
228228
$test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false);
229229

230230
$this->expectedDeprecations = $annotations['method']['expectedDeprecation'];
231-
$this->previousErrorHandler = set_error_handler(array($this, 'handleError'));
231+
$this->previousErrorHandler = set_error_handler([$this, 'handleError']);
232232
}
233233
}
234234
}
@@ -251,8 +251,8 @@ public function endTest($test, $time)
251251
$deprecations = file_get_contents($this->runsInSeparateProcess);
252252
unlink($this->runsInSeparateProcess);
253253
putenv('SYMFONY_DEPRECATIONS_SERIALIZE');
254-
foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) {
255-
$error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null));
254+
foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) {
255+
$error = serialize(['deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null]);
256256
if ($deprecation[0]) {
257257
// unsilenced on purpose
258258
trigger_error($error, E_USER_DEPRECATED);
@@ -264,13 +264,13 @@ public function endTest($test, $time)
264264
}
265265

266266
if ($this->expectedDeprecations) {
267-
if (!\in_array($test->getStatus(), array(BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE), true)) {
267+
if (!\in_array($test->getStatus(), [BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE], true)) {
268268
$test->addToAssertionCount(\count($this->expectedDeprecations));
269269
}
270270

271271
restore_error_handler();
272272

273-
if (!$errored && !\in_array($test->getStatus(), ar 325D ray(BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE, BaseTestRunner::STATUS_FAILURE, BaseTestRunner::STATUS_ERROR), true)) {
273+
if (!$errored && !\in_array($test->getStatus(), [BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE, BaseTestRunner::STATUS_FAILURE, BaseTestRunner::STATUS_ERROR], true)) {
274274
try {
275275
$prefix = "@expectedDeprecation:\n";
276276
$test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n");
@@ -279,20 +279,20 @@ public function endTest($test, $time)
279279
}
280280
}
281281

282-
$this->expectedDeprecations = $this->gatheredDeprecations = array();
282+
$this->expectedDeprecations = $this->gatheredDeprecations = [];
283283
$this->previousErrorHandler = null;
284284
}
285285
if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
286286
if (\in_array('time-sensitive', $groups, true)) {
287287
ClockMock::withClockMock(false);
288288
}
289289
if (\in_array('dns-sensitive', $groups, true)) {
290-
DnsMock::withMockedHosts(array());
290+
DnsMock::withMockedHosts([]);
291291
}
292292
}
293293
}
294294

295-
public function handleError($type, $msg, $file, $line, $context = array())
295+
public function handleError($type, $msg, $file, $line, $context = [])
296296
{
297297
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
298298
$h = $this->previousErrorHandler;

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler;
1313

14-
use Composer\Autoload\ClassLoader;
1514
use PHPUnit\Framework\TestCase;
1615
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
1716
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
@@ -46,7 +45,6 @@ private static function getVendorDir()
4645
touch($vendorDir.'/myfakevendor/myfakepackage1/MyFakeFile2.php');
4746
touch($vendorDir.'/myfakevendor/myfakepackage2/MyFakeFile.php');
4847

49-
5048
return self::$vendorDir;
5149
}
5250

@@ -106,12 +104,12 @@ public function mutedProvider()
106104
yield 'not from phpunit, and not a whitelisted message' => [
107105
false,
108106
\My\Source\Code::class,
109-
'Self deprecating humor is deprecated by itself'
107+
'Self deprecating humor is deprecated by itself',
110108
];
111109
yield 'from phpunit, but not a whitelisted message' => [
112110
false,
113111
\PHPUnit\Random\Piece\Of\Code::class,
114-
'Self deprecating humor is deprecated by itself'
112+
'Self deprecating humor is deprecated by itself',
115113
];
116114
yield 'whitelisted message, but not from phpunit' => [
117115
false,
@@ -146,7 +144,7 @@ public function testItTakesMutesDeprecationFromPhpUnitFiles()
146144
['file' => 'should_not_matter.php'],
147145
['file' => 'should_not_matter_either.php'],
148146
],
149-
'random_path' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'phpunit' . \DIRECTORY_SEPARATOR . 'whatever.php'
147+
'random_path'.\DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR.'phpunit'.\DIRECTORY_SEPARATOR.'whatever.php'
150148
);
151149
$this->assertTrue($deprecation->isMuted());
152150
}

0 commit comments

Comments
 (0)
0