Skip to content

Commit f059831

Browse files
authored
2.x (#1)
* chore: add github actions * chore: upgrade phpunit to 9 * chore: add php-cs-fixer * chore: fix phpunit.xml * fix: weird i character * feat: allow chaining methods * fix: cast tr_strtoupper and tr_strtolower to string
1 parent 8ba4def commit f059831

File tree

13 files changed

+3578
-709
lines changed

13 files changed

+3578
-709
lines changed

.github/workflows/main.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: run-tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
os: [ubuntu-latest]
12+
php: [8.0, 7.4]
13+
dependency-version: [prefer-stable]
14+
15+
name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v2
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
26+
coverage: none
27+
28+
- name: Setup Problem Matches
29+
run: |
30+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
31+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
32+
33+
- name: Install dependencies
34+
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
35+
36+
- name: Execute tests
37+
run: vendor/bin/phpunit

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
/vendor
1+
# Composer dependencies
2+
/vendor
3+
4+
# Cache
5+
.php_cs.cache
6+
.phpunit.result.cache

.php_cs

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?php
2+
3+
use PhpCsFixer\Config;
4+
use PhpCsFixer\Finder;
5+
6+
$rules = [
7+
'array_syntax' => ['syntax' => 'short'],
8+
'binary_operator_spaces' => [
9+
'default' => 'single_space',
10+
'operators' => ['=>' => null],
11+
],
12+
'blank_line_after_namespace' => true,
13+
'blank_line_after_opening_tag' => true,
14+
'blank_line_before_statement' => [
15+
'statements' => ['return'],
16+
],
17+
'braces' => true,
18+
'cast_spaces' => true,
19+
'class_attributes_separation' => [
20+
'elements' => ['method'],
21+
],
22+
'class_definition' => true,
23+
'concat_space' => [
24+
'spacing' => 'one',
25+
],
26+
'declare_equal_normalize' => true,
27+
'elseif' => true,
28+
'encoding' => true,
29+
'full_opening_tag' => true,
30+
'fully_qualified_strict_types' => true, // added by Shift
31+
'function_declaration' => true,
32+
'function_typehint_space' => true,
33+
'heredoc_to_nowdoc' => true,
34+
'include' => true,
35+
'increment_style' => ['style' => 'post'],
36+
'indentation_type' => true,
37+
'linebreak_after_opening_tag' => true,
38+
'line_ending' => true,
39+
'lowercase_cast' => true,
40+
'lowercase_constants' => true,
41+
'lowercase_keywords' => true,
42+
'lowercase_static_reference' => true, // added from Symfony
43+
'magic_method_casing' => true, // added from Symfony
44+
'magic_constant_casing' => true,
45+
'method_argument_space' => true,
46+
'native_function_casing' => true,
47+
'no_alias_functions' => true,
48+
'no_extra_blank_lines' => [
49+
'tokens' => [
50+
'extra',
51+
'throw',
52+
'use',
53+
'use_trait',
54+
],
55+
],
56+
'no_blank_lines_after_class_opening' => true,
57+
'no_blank_lines_after_phpdoc' => true,
58+
'no_closing_tag' => true,
59+
'no_empty_phpdoc' => true,
60+
'no_empty_statement' => true,
61+
'no_leading_import_slash' => true,
62+
'no_leading_namespace_whitespace' => true,
63+
'no_mixed_echo_print' => [
64+
'use' => 'echo',
65+
],
66+
'no_multiline_whitespace_around_double_arrow' => true,
67+
'multiline_whitespace_before_semicolons' => [
68+
'strategy' => 'no_multi_line',
69+
],
70+
'no_short_bool_cast' => true,
71+
'no_singleline_whitespace_before_semicolons' => true,
72+
'no_spaces_after_function_name' => true,
73+
'no_spaces_around_offset' => true,
74+
'no_spaces_inside_parenthesis' => true,
75+
'no_trailing_comma_in_list_call' => true,
76+
'no_trailing_comma_in_singleline_array' => true,
77+
'no_trailing_whitespace' => true,
78+
'no_trailing_whitespace_in_comment' => true,
79+
'no_unneeded_control_parentheses' => true,
80+
'no_unreachable_default_argument_value' => true,
81+
'no_useless_return' => true,
82+
'no_whitespace_before_comma_in_array' => true,
83+
'no_whitespace_in_blank_line' => true,
84+
'normalize_index_brace' => true,
85+
'not_operator_with_successor_space' => true,
86+
'object_operator_without_whitespace' => true,
87+
'ordered_imports' => ['sortAlgorithm' => 'length'],
88+
'phpdoc_indent' => true,
89+
'phpdoc_inline_tag' => true,
90+
'phpdoc_no_access' => true,
91+
'phpdoc_no_package' => true,
92+
'phpdoc_no_useless_inheritdoc' => true,
93+
'phpdoc_scalar' => true,
94+
'phpdoc_single_line_var_spacing' => true,
95+
'phpdoc_summary' => true,
96+
'phpdoc_to_comment' => true,
97+
'phpdoc_trim' => true,
98+
'phpdoc_types' => true,
99+
'phpdoc_var_without_name' => true,
100+
'psr4' => true,
101+
'self_accessor' => true,
102+
'short_scalar_cast' => true,
103+
'simplified_null_return' => true,
104+
'single_blank_line_at_eof' => true,
105+
'single_blank_line_before_namespace' => true,
106+
'single_class_element_per_statement' => true,
107+
'single_import_per_statement' => true,
108+
'single_line_after_imports' => true,
109+
'single_line_comment_style' => [
110+
'comment_types' => ['hash'],
111+
],
112+
'single_quote' => true,
113+
'space_after_semicolon' => true,
114+
'standardize_not_equals' => true,
115+
'switch_case_semicolon_to_colon' => true,
116+
'switch_case_space' => true,
117+
'ternary_operator_spaces' => true,
118+
'trailing_comma_in_multiline_array' => true,
119+
'trim_array_spaces' => true,
120+
'unary_operator_spaces' => true,
121+
'visibility_required' => [
122+
'elements' => ['method', 'property'],
123+
],
124+
'whitespace_after_comma_in_array' => true,
125+
'no_unused_imports' => true,
126+
];
127+
128+
$finder = Finder::create()
129+
->notPath('vendor')
130+
->in(getcwd())
131+
->name('*.php')
132+
->ignoreDotFiles(true)
133+
->ignoreVCS(true);
134+
135+
return Config::create()
136+
->setFinder($finder)
137+
->setRules($rules)
138+
->setRiskyAllowed(true)
139+
->setUsingCache(true);

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
}
1111
],
1212
"require-dev": {
13-
"phpunit/phpunit": "^7.1"
13+
"phpunit/phpunit": "^9.0",
14+
"friendsofphp/php-cs-fixer": "^2.18"
1415
},
1516
"autoload": {
1617
"psr-4": {

0 commit comments

Comments
 (0)