Skip to content

Commit d64bf59

Browse files
authored
Merge pull request #6 from dachcom-digital/coding-standard/refactor-3.0
[CS] Refactor
2 parents 4b8dab6 + cb4a4a8 commit d64bf59

27 files changed

+454
-160
lines changed

src/Support/AcceptanceTester.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace Dachcom\Codeception\Support;
415

516
class AcceptanceTester extends \Codeception\Actor

src/Support/App/TestKernel.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
<?php
22

3-
use Pimcore\Kernel;
3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
414
use Pimcore\HttpKernel\BundleCollection\BundleCollection;
15+
use Pimcore\Kernel;
516
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
617
use Symfony\Component\Config\FileLocator;
718
use Symfony\Component\Config\Loader\LoaderInterface;
@@ -57,7 +68,7 @@ public function registerBundlesToCollection(BundleCollection $collection): void
5768

5869
if (is_array($testBundles)) {
5970
foreach ($testBundles as $testBundle) {
60-
$collection->addBundle(new $testBundle['namespace'], array_key_exists('priority', $testBundle) ? $testBundle['priority'] : -1000);
71+
$collection->addBundle(new $testBundle['namespace'](), array_key_exists('priority', $testBundle) ? $testBundle['priority'] : -1000);
6172
}
6273
}
6374
}
@@ -71,13 +82,11 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
7182
}
7283

7384
$loader->load(function (ContainerBuilder $container) {
74-
7585
$runtimeConfigDir = sprintf('%s/_etc', $_SERVER['TEST_BUNDLE_TEST_DIR']);
7686
$runtimeConfigDir = sprintf('%s/config/bundle/', $runtimeConfigDir);
7787

7888
$loader = new YamlFileLoader($container, new FileLocator([$runtimeConfigDir]));
7989
$loader->load($this->runtimeConfigFile);
80-
8190
});
8291
}
8392

src/Support/Constraint/ArrayContainsComparator.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This source file is available under two different licenses:
7+
* - GNU General Public License version 3 (GPLv3)
8+
* - DACHCOM Commercial License (DCL)
9+
* Full copyright and license information is available in
10+
* LICENSE.md which is distributed with this source code.
11+
*
12+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
13+
* @license GPLv3 and DCL
14+
*/
15+
516
namespace Dachcom\Codeception\Support\Constraint;
617

718
use function array_intersect;
@@ -40,6 +51,7 @@ private function arrayIntersectRecursive(mixed $arr1, mixed $arr2): bool|array|n
4051
if ($this->arrayIsSequential($arr1) && $this->arrayIsSequential($arr2)) {
4152
return $this->sequentialArrayIntersect($arr1, $arr2);
4253
}
54+
4355
return $this->associativeArrayIntersect($arr1, $arr2);
4456
}
4557

@@ -64,12 +76,14 @@ private function sequentialArrayIntersect(array $arr1, array $arr2): array
6476
if ($return !== false && $return == $value1) {
6577
$ret[$key1] = $return;
6678
$matchedKeys[$key2] = true;
79+
6780
break;
6881
}
6982

7083
if ($this->isEqualValue($value1, $value2)) {
7184
$ret[$key1] = $value1;
7285
$matchedKeys[$key2] = true;
86+
7387
break;
7488
}
7589
}
@@ -87,6 +101,7 @@ private function associativeArrayIntersect(array $arr1, array $arr2): bool|array
87101
$return = $this->arrayIntersectRecursive($arr1[$key], $arr2[$key]);
88102
if ($return !== false) {
89103
$ret[$key] = $return;
104+
90105
continue;
91106
}
92107
if ($this->isEqualValue($arr1[$key], $arr2[$key])) {
@@ -113,11 +128,11 @@ private function associativeArrayIntersect(array $arr1, array $arr2): bool|array
113128
private function isEqualValue($val1, $val2): bool
114129
{
115130
if (is_numeric($val1)) {
116-
$val1 = (string)$val1;
131+
$val1 = (string) $val1;
117132
}
118133

119134
if (is_numeric($val2)) {
120-
$val2 = (string)$val2;
135+
$val2 = (string) $val2;
121136
}
122137

123138
return $val1 === $val2;

src/Support/Constraint/JsonContains.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace Dachcom\Codeception\Support\Constraint;
415

16+
use InvalidArgumentException;
517
use PHPUnit\Framework\AssertionFailedError;
618
use PHPUnit\Framework\Constraint\Constraint;
719
use PHPUnit\Framework\ExpectationFailedException;
8-
use SebastianBergmann\Comparator\ComparisonFailure;
920
use SebastianBergmann\Comparator\ArrayComparator;
21+
use SebastianBergmann\Comparator\ComparisonFailure;
1022
use SebastianBergmann\Comparator\Factory;
11-
use InvalidArgumentException;
1223

1324
class JsonContains extends Constraint
1425
{
@@ -24,9 +35,9 @@ public function __construct(array $expected)
2435
* Evaluates the constraint for parameter $other. Returns true if the
2536
* constraint is met, false otherwise.
2637
*/
27-
protected function matches(mixed $other) : bool
38+
protected function matches(mixed $other): bool
2839
{
29-
if (!is_string($other)) {
40+
if (!is_string($other)) {
3041
throw new InvalidArgumentException('$jsonString param must be a string.');
3142
}
3243

@@ -41,7 +52,7 @@ protected function matches(mixed $other) : bool
4152
if (JSON_ERROR_NONE !== json_last_error()) {
4253
throw new InvalidArgumentException(
4354
sprintf(
44-
"Invalid json: %s. System message: %s.",
55+
'Invalid json: %s. System message: %s.',
4556
$other,
4657
json_last_error_msg()
4758
),
@@ -58,7 +69,8 @@ protected function matches(mixed $other) : bool
5869
}
5970

6071
$comparator = new ArrayComparator();
61-
$comparator->setFactory(new Factory);
72+
$comparator->setFactory(new Factory());
73+
6274
try {
6375
$comparator->assertEquals($this->expected, $this->jsonArray);
6476
} catch (ComparisonFailure $failure) {
@@ -76,12 +88,12 @@ public function containsArray(array $needle): bool
7688
return (new ArrayContainsComparator($this->jsonArray))->containsArray($needle);
7789
}
7890

79-
public function toString() : string
91+
public function toString(): string
8092
{
8193
return '';
8294
}
8395

84-
protected function failureDescription($other) : string
96+
protected function failureDescription($other): string
8597
{
8698
return '';
8799
}

src/Support/DependencyInjection/DisablePimcoreCsrfProtection.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace Dachcom\Codeception\Support\DependencyInjection;
415

516
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

src/Support/DependencyInjection/MakeServicesPublicPass.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace Dachcom\Codeception\Support\DependencyInjection;
415

516
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
@@ -16,7 +27,6 @@ public function process(ContainerBuilder $container): void
1627
});
1728

1829
foreach ($serviceIds as $serviceId) {
19-
2030
if ($container->hasAlias($serviceId)) {
2131
$container->getAlias($serviceId)->setPublic(true);
2232
}

src/Support/DependencyInjection/MonologChannelLoggerPass.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace Dachcom\Codeception\Support\DependencyInjection;
415

516
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

src/Support/FunctionalTester.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace Dachcom\Codeception\Support;
415

516
class FunctionalTester extends \Codeception\Actor

0 commit comments

Comments
 (0)