Skip to content

Commit b3a4b55

Browse files
committed
csfix
1 parent 2d3c47e commit b3a4b55

File tree

5 files changed

+71
-144
lines changed

5 files changed

+71
-144
lines changed

.php-cs-fixer.php

+3-71
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,9 @@
11
<?php
2-
3-
use PhpCsFixer\Config;
4-
5-
final class Php73 extends Config {
6-
public function __construct() {
7-
parent::__construct('KRNStyle');
8-
$this->setRiskyAllowed(true);
9-
}
10-
11-
public function getRules(): array {
12-
$rules = [
13-
'@Symfony' => true,
14-
'array_syntax' => [
15-
'syntax' => 'short',
16-
],
17-
'binary_operator_spaces' => [
18-
],
19-
'blank_line_after_namespace' => true,
20-
'blank_line_after_opening_tag' => true,
21-
'braces' => [
22-
'position_after_functions_and_oop_constructs' => 'same',
23-
],
24-
'blank_line_before_statement' => ['statements' => ['return']],
25-
'concat_space' => ['spacing' => 'one'],
26-
'function_typehint_space' => true,
27-
'lowercase_cast' => true,
28-
'native_function_casing' => true,
29-
'new_with_braces' => true,
30-
'no_empty_comment' => true,
31-
'no_empty_phpdoc' => true,
32-
'no_empty_statement' => true,
33-
'no_leading_import_slash' => true,
34-
'no_leading_namespace_whitespace' => true,
35-
'no_multiline_whitespace_around_double_arrow' => true,
36-
'no_short_bool_cast' => true,
37-
'no_singleline_whitespace_before_semicolons' => true,
38-
'no_trailing_comma_in_singleline_array' => true,
39-
'no_unneeded_control_parentheses' => true,
40-
'no_unused_imports' => true,
41-
'no_whitespace_before_comma_in_array' => true,
42-
'no_whitespace_in_blank_line' => true,
43-
'normalize_index_brace' => true,
44-
'not_operator_with_successor_space' => true,
45-
'object_operator_without_whitespace' => true,
46-
'ordered_imports' => true,
47-
'php_unit_construct' => true,
48-
'php_unit_dedicate_assert' => true,
49-
'php_unit_method_casing' => false,
50-
'phpdoc_single_line_var_spacing' => true,
51-
'phpdoc_trim' => true,
52-
'random_api_migration' => true,
53-
'self_accessor' => true,
54-
'short_scalar_cast' => true,
55-
'single_blank_line_before_namespace' => true,
56-
'single_class_element_per_statement' => true,
57-
'single_quote' => true,
58-
'space_after_semicolon' => true,
59-
'standardize_not_equals' => true,
60-
'ternary_operator_spaces' => true,
61-
'trim_array_spaces' => true,
62-
'unary_operator_spaces' => true,
63-
'whitespace_after_comma_in_array' => true,
64-
];
65-
66-
return $rules;
67-
}
68-
}
69-
70-
$config = new Php73();
2+
$config = new KRN\CS\Php73;
713
$finder = $config->getFinder();
724
$finder->in([
735
'src',
74-
'tests',
6+
'tests'
757
]);
76-
778
return $config;
9+

composer.json

+45-42
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,47 @@
11
{
2-
"name": "wordpress/plugin-hacks",
3-
"type": "wordpress-muplugin",
4-
"support": {
5-
"src": "http://gitlab.krone.at/WordPress/plugin-hacks.git"
6-
},
7-
"extra": {
8-
"installer-name": "kmm-hacks"
9-
},
10-
"repositories": [
11-
{
12-
"type": "gitlab",
13-
"url": "http://gitlab.krone.at/KRN/phpcs.git"
2+
"name": "wordpress/plugin-hacks",
3+
"type": "wordpress-muplugin",
4+
"support": {
5+
"src": "http://gitlab.krone.at/WordPress/plugin-hacks.git"
6+
},
7+
"extra": {
8+
"installer-name": "kmm-hacks"
9+
},
10+
"repositories": [
11+
{
12+
"type": "gitlab",
13+
"url": "http://gitlab.krone.at/KRN/phpcs.git"
14+
}
15+
],
16+
"require": {
17+
"php": ">=7.0.0",
18+
"composer/installers": "~1.0",
19+
"yoast/phpunit-polyfills": "^1.0"
20+
},
21+
"autoload": {
22+
"classmap": [
23+
"src/"
24+
]
25+
},
26+
"scripts": {
27+
"cs-check": "vendor/bin/php-cs-fixer fix --verbose --diff --dry-run",
28+
"cs-fix": "vendor/bin/php-cs-fixer fix --verbose --diff"
29+
},
30+
"config": {
31+
"gitlab-domains": [
32+
"gitlab.krone.at"
33+
],
34+
"github-protocols": [
35+
"https"
36+
],
37+
"secure-http": false,
38+
"allow-plugins": {
39+
"composer/installers": true
40+
}
41+
},
42+
"require-dev": {
43+
"krn/php-cs-style": "*",
44+
"php-mock/php-mock": "^2.1",
45+
"phpunit/phpunit": ">=8.5.23"
1446
}
15-
],
16-
"require": {
17-
"php": ">=7.0.0",
18-
"composer/installers": "~1.0",
19-
"yoast/phpunit-polyfills": "^1.0"
20-
},
21-
"autoload": {
22-
"classmap": [
23-
"src/"
24-
]
25-
},
26-
"scripts": {
27-
"cs-check": "vendor/bin/php-cs-fixer fix --verbose --diff --dry-run",
28-
"cs-fix": "vendor/bin/php-cs-fixer fix --verbose --diff"
29-
},
30-
"config": {
31-
"gitlab-domains": ["gitlab.krone.at"],
32-
"github-protocols": ["https"],
33-
"secure-http": false,
34-
"allow-plugins": {
35-
"composer/installers": true
36-
}
37-
},
38-
"require-dev": {
39-
"krn/php-cs-style": "*",
40-
"php-mock/php-mock": "^2.0",
41-
"friendsofphp/php-cs-fixer": "^3.8",
42-
"phpunit/phpunit": ">=8.5.23"
43-
}
44-
}
47+
}

phpunit.xml.dist

+11-19
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
bootstrap="tests/phpunit/bootstrap.php"
4-
backupGlobals="false"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
10-
>
11-
<testsuites>
12-
<testsuite name="unit">
13-
<directory prefix="test-" suffix=".php">./tests/</directory>
14-
</testsuite>
15-
</testsuites>
16-
<filter>
17-
<whitelist>
18-
<directory>./src</directory>
19-
</whitelist>
20-
</filter>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/phpunit/bootstrap.php" backupGlobals="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory>./src</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="unit">
10+
<directory prefix="test-" suffix=".php">./tests/</directory>
11+
</testsuite>
12+
</testsuites>
2113
</phpunit>

tests/phpunit/PrettyPrinter.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ protected function formatExceptionMsg($exceptionMessage) {
2626
protected function printDefectTrace(\PHPUnit\Framework\TestFailure $defect): void {
2727
$this->write($this->formatExceptionMsg($defect->getExceptionAsString()));
2828
$trace = \PHPUnit\Util\Filter::getFilteredStacktrace(
29-
$defect->thrownException()
29+
$defect->thrownException()
3030
);
3131
if (! empty($trace)) {
3232
$this->write("\n" . $trace);
3333
}
3434
$e = $defect->thrownException()->getPrevious();
3535
while ($e) {
3636
$this->write(
37-
"\nCaused by\n" .
38-
\PHPUnit\Framework_TestFailure::exceptionToString($e) . "\n" .
39-
\PHPUnit\Util_Filter::getFilteredStacktrace($e)
40-
);
37+
"\nCaused by\n" .
38+
\PHPUnit\Framework_TestFailure::exceptionToString($e) . "\n" .
39+
\PHPUnit\Util_Filter::getFilteredStacktrace($e)
40+
);
4141
$e = $e->getPrevious();
4242
}
4343
}
@@ -48,7 +48,7 @@ protected function printDefectTrace(\PHPUnit\Framework\TestFailure $defect): voi
4848
* @param string $message to print
4949
* @param string $color optional color (if supported by console)
5050
*/
51-
private function out($message, $color='', $linebreak=false) {
51+
private function out($message, $color = '', $linebreak = false) {
5252
echo($color ? $this->formatWithColor($color, $message) : $message) . ($linebreak ? "\n" : '');
5353
}
5454

@@ -101,9 +101,9 @@ public function startTestSuite(\PHPUnit\Framework\TestSuite $suite): void {
101101
if (! $this->headerPrinted) {
102102
$header = '██████╗ ██╗ ██╗██████╗ ██╗ ██╗███╗ ██╗██╗████████╗
103103
██╔══██╗██║ ██║██╔══██╗██║ ██║████╗ ██║██║╚══██╔══╝
104-
██████╔╝███████║██████╔╝██║ ██║██╔██╗ ██║██║ ██║
105-
██╔═══╝ ██╔══██║██╔═══╝ ██║ ██║██║╚██╗██║██║ ██║
106-
██║ ██║ ██║██║ ╚██████╔╝██║ ╚████║██║ ██║
104+
██████╔╝███████║██████╔╝██║ ██║██╔██╗ ██║██║ ██║
105+
██╔═══╝ ██╔══██║██╔═══╝ ██║ ██║██║╚██╗██║██║ ██║
106+
██║ ██║ ██║██║ ╚██████╔╝██║ ╚████║██║ ██║
107107
╚═╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ ';
108108
$this->out($header, 'fg-blue', true);
109109
$this->out(' - - - - T E S T A L L T H E T H I N G S - - - - ', 'fg-blue', true);

tests/phpunit/bootstrap.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
namespace UNT;
77

88
require_once __DIR__ . '/../../vendor/autoload.php';
9-
// Fake ENV
9+
1010
define('KRN_HOST_API', 'test-api.krone.at');
1111
define('WP_HOME', 'test-www.krone.at');
1212
define('KRN_HOST_MOBIL', 'test-mobil.krone.at');
1313
define('KRN_IS_TESTING', 1);
1414

15-
class UNTBootstrap {
15+
class bootstrap {
1616
public function __construct() {
1717
$_tests_dir = getenv('WP_TESTS_DIR');
1818
if (! $_tests_dir) {
@@ -37,4 +37,4 @@ public function _manually_load_plugin() {
3737

3838
// Start up the WP testing environment.
3939

40-
$unt = new UNTBootstrap();
40+
$unt = new bootstrap();

0 commit comments

Comments
 (0)