Skip to content

Commit bddde31

Browse files
author
Южаков Георгий
committed
Add code style fix. Add code sniffer
1 parent 4100a9b commit bddde31

File tree

4 files changed

+2020
-162
lines changed

4 files changed

+2020
-162
lines changed

Diff for: .php_cs.dist

+232
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude('vendor')
5+
->in(__DIR__);
6+
7+
return PhpCsFixer\Config::create()
8+
->setRiskyAllowed(true)
9+
->setFinder($finder)
10+
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer' . preg_replace('~\W~', '-', __DIR__))
11+
->setRules([
12+
'align_multiline_comment' => true,
13+
'array_indentation' => true,
14+
'array_syntax' => ['syntax' => 'short'],
15+
'backtick_to_shell_exec' => true,
16+
'binary_operator_spaces' => true,
17+
'blank_line_after_namespace' => true,
18+
'blank_line_after_opening_tag' => true,
19+
'blank_line_before_return' => false, // Deprecated
20+
'blank_line_before_statement' => true,
21+
'braces' => true,
22+
'cast_spaces' => true,
23+
'class_attributes_separation' => ['elements' => ['method', 'property']], // const are often grouped with other related const
24+
'class_definition' => true,
25+
'class_keyword_remove' => false, // ::class keyword gives us better support in IDE
26+
'combine_consecutive_issets' => true,
27+
'combine_consecutive_unsets' => true,
28+
'combine_nested_dirname' => true,
29+
'comment_to_phpdoc' => true,
30+
'compact_nullable_typehint' => true,
31+
'concat_space' => ['spacing' => 'one'],
32+
'constant_case' => true,
33+
'date_time_immutable' => false, // Break our unit tests
34+
'declare_equal_normalize' => true,
35+
'declare_strict_types' => false, // Too early to adopt strict types
36+
'dir_constant' => true,
37+
'doctrine_annotation_array_assignment' => true,
38+
'doctrine_annotation_braces' => true,
39+
'doctrine_annotation_indentation' => true,
40+
'doctrine_annotation_spaces' => true,
41+
'elseif' => true,
42+
'encoding' => true,
43+
'ereg_to_preg' => true,
44+
'error_suppression' => true,
45+
'escape_implicit_backslashes' => true,
46+
'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read
47+
'explicit_string_variable' => false, // I feel it makes the code actually harder to read
48+
'final_class' => false, // We need non-final classes
49+
'final_internal_class' => true,
50+
'final_public_method_for_abstract_class' => false, // We need non-final methods
51+
'final_static_access' => true,
52+
'fopen_flag_order' => true,
53+
'fopen_flags' => true,
54+
'full_opening_tag' => true,
55+
'fully_qualified_strict_types' => true,
56+
'function_declaration' => true,
57+
'function_to_constant' => true,
58+
'function_typehint_space' => true,
59+
'general_phpdoc_annotation_remove' => ['access', 'category', 'copyright', 'method', 'throws'],
60+
'global_namespace_import' => true,
61+
'hash_to_slash_comment' => false, // Deprecated
62+
'header_comment' => false, // We don't use common header in all our files
63+
'heredoc_indentation' => false, // Requires PHP >= 7.3
64+
'heredoc_to_nowdoc' => false, // Not sure about this one
65+
'implode_call' => true,
66+
'include' => true,
67+
'increment_style' => true,
68+
'indentation_type' => true,
69+
'is_null' => true,
70+
'line_ending' => true,
71+
'linebreak_after_opening_tag' => true,
72+
'list_syntax' => ['syntax' => 'short'],
73+
'logical_operators' => true,
74+
'lowercase_cast' => true,
75+
'lowercase_constants' => false, // Deprecated
76+
'lowercase_keywords' => true,
77+
'lowercase_static_reference' => true,
78+
'magic_constant_casing' => true,
79+
'magic_method_casing' => true,
80+
'mb_str_functions' => false, // No, too dangerous to change that
81+
'method_argument_space' => true,
82+
'method_chaining_indentation' => true,
83+
'method_separation' => false, // Deprecated
84+
'modernize_types_casting' => true,
85+
'multiline_comment_opening_closing' => true,
86+
'multiline_whitespace_before_semicolons' => true,
87+
'native_constant_invocation' => false, // Micro optimization that look messy
88+
'native_function_casing' => true,
89+
'native_function_invocation' => false, // I suppose this would be best, but I am still unconvinced about the visual aspect of it
90+
'native_function_type_declaration_casing' => true,
91+
'new_with_braces' => true,
92+
'no_alias_functions' => true,
93+
'no_alternative_syntax' => true,
94+
'no_binary_string' => true,
95+
'no_blank_lines_after_class_opening' => true,
96+
'no_blank_lines_after_phpdoc' => true,
97+
'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
98+
'no_break_comment' => true,
99+
'no_closing_tag' => true,
100+
'no_empty_comment' => true,
101+
'no_empty_phpdoc' => true,
102+
'no_empty_statement' => true,
103+
'no_extra_blank_lines' => true,
104+
'no_extra_consecutive_blank_lines' => false, // Deprecated
105+
'no_homoglyph_names' => true,
106+
'no_leading_import_slash' => true,
107+
'no_leading_namespace_whitespace' => true,
108+
'no_mixed_echo_print' => true,
109+
'no_multiline_whitespace_around_double_arrow' => true,
110+
'no_multiline_whitespace_before_semicolons' => false, // Deprecated
111+
'no_null_property_initialization' => true,
112+
'no_php4_constructor' => true,
113+
'no_short_bool_cast' => true,
114+
'no_short_echo_tag' => true,
115+
'no_singleline_whitespace_before_semicolons' => true,
116+
'no_spaces_after_function_name' => true,
117+
'no_spaces_around_offset' => true,
118+
'no_spaces_inside_parenthesis' => true,
119+
'no_superfluous_elseif' => false, // Might be risky on a huge code base
120+
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
121+
'no_trailing_comma_in_list_call' => true,
122+
'no_trailing_comma_in_singleline_array' => true,
123+
'no_trailing_whitespace' => true,
124+
'no_trailing_whitespace_in_comment' => true,
125+
'no_unneeded_control_parentheses' => true,
126+
'no_unneeded_curly_braces' => true,
127+
'no_unneeded_final_method' => true,
128+
'no_unreachable_default_argument_value' => true,
129+
'no_unset_cast' => true,
130+
'no_unset_on_property' => true,
131+
'no_unused_imports' => true,
132+
'no_useless_else' => true,
133+
'no_useless_return' => true,
134+
'no_whitespace_before_comma_in_array' => true,
135+
'no_whitespace_in_blank_line' => true,
136+
'non_printable_character' => true,
137+
'normalize_index_brace' => true,
138+
'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
139+
'not_operator_with_successor_space' => false, // idem
140+
'nullable_type_declaration_for_default_null_value' => true,
141+
'object_operator_without_whitespace' => true,
142+
'ordered_class_elements' => false, // We prefer to keep some freedom
143+
'ordered_imports' => true,
144+
'ordered_interfaces' => true,
145+
'php_unit_construct' => true,
146+
'php_unit_dedicate_assert' => true,
147+
'php_unit_dedicate_assert_internal_type' => true,
148+
'php_unit_expectation' => true,
149+
'php_unit_fqcn_annotation' => true,
150+
'php_unit_internal_class' => false, // Because tests are excluded from package
151+
'php_unit_method_casing' => true,
152+
'php_unit_mock' => true,
153+
'php_unit_mock_short_will_return' => true,
154+
'php_unit_namespaced' => true,
155+
'php_unit_no_expectation_annotation' => true,
156+
'php_unit_ordered_covers' => true,
157+
'php_unit_set_up_tear_down_visibility' => true,
158+
'php_unit_size_class' => false, // That seems extra work to maintain for little benefits
159+
'php_unit_strict' => false, // We sometime actually need assertEquals
160+
'php_unit_test_annotation' => true,
161+
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
162+
'php_unit_test_class_requires_covers' => false, // We don't care as much as we should about coverage
163+
'phpdoc_add_missing_param_annotation' => true,
164+
'phpdoc_align' => false, // Waste of time
165+
'phpdoc_annotation_without_dot' => true,
166+
'phpdoc_indent' => true,
167+
'phpdoc_inline_tag' => true,
168+
'phpdoc_line_span' => false, // Unfortunately our old comments turn even uglier with this
169+
'phpdoc_no_access' => true,
170+
'phpdoc_no_alias_tag' => true,
171+
'phpdoc_no_empty_return' => true,
172+
'phpdoc_no_package' => true,
173+
'phpdoc_no_useless_inheritdoc' => true,
174+
'phpdoc_order' => true,
175+
'phpdoc_return_self_reference' => true,
176+
'phpdoc_scalar' => true,
177+
'phpdoc_separation' => true,
178+
'phpdoc_single_line_var_spacing' => true,
179+
'phpdoc_summary' => true,
180+
'phpdoc_to_comment' => true,
181+
'phpdoc_to_param_type' => false, // Because experimental, but interesting for one shot use
182+
'phpdoc_to_return_type' => false, // idem
183+
'phpdoc_trim' => true,
184+
'phpdoc_trim_consecutive_blank_line_separation' => true,
185+
'phpdoc_types' => true,
186+
'phpdoc_types_order' => true,
187+
'phpdoc_var_annotation_correct_order' => true,
188+
'phpdoc_var_without_name' => true,
189+
'pow_to_exponentiation' => true,
190+
'pre_increment' => false, // Deprecated
191+
'protected_to_private' => true,
192+
'psr0' => true,
193+
'psr4' => true,
194+
'random_api_migration' => true,
195+
'return_assignment' => false, // Sometimes useful for clarity or debug
196+
'return_type_declaration' => true,
197+
'self_accessor' => true,
198+
'self_static_accessor' => true,
199+
'semicolon_after_instruction' => false, // Buggy in `samples/index.php`
200+
'set_type_to_cast' => true,
201+
'short_scalar_cast' => true,
202+
'silenced_deprecation_error' => false, // Deprecated
203+
'simple_to_complex_string_variable' => false, // Would differ from TypeScript without obvious advantages
204+
'simplified_null_return' => false, // Even if technically correct we prefer to be explicit
205+
'single_blank_line_at_eof' => true,
206+
'single_blank_line_before_namespace' => true,
207+
'single_class_element_per_statement' => true,
208+
'single_import_per_statement' => true,
209+
'single_line_after_imports' => true,
210+
'single_line_comment_style' => true,
211+
'single_line_throw' => false, // I don't see any reason for having a special case for Exception
212+
'single_quote' => true,
213+
'single_trait_insert_per_statement' => true,
214+
'space_after_semicolon' => true,
215+
'standardize_increment' => true,
216+
'standardize_not_equals' => true,
217+
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
218+
'strict_comparison' => false, // No, too dangerous to change that
219+
'strict_param' => false, // No, too dangerous to change that
220+
'string_line_ending' => true,
221+
'switch_case_semicolon_to_colon' => true,
222+
'switch_case_space' => true,
223+
'ternary_operator_spaces' => true,
224+
'ternary_to_null_coalescing' => true,
225+
'trailing_comma_in_multiline_array' => true,
226+
'trim_array_spaces' => true,
227+
'unary_operator_spaces' => true,
228+
'visibility_required' => true,
229+
'void_return' => true,
230+
'whitespace_after_comma_in_array' => true,
231+
'yoda_style' => false,
232+
]);

Diff for: README.md

+7-16
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PHPoAuthLib
22
===========
33
**NOTE: I'm looking for someone who could help to maintain this package alongside me, just because I don't have a ton of time to devote to it. However, I'm still going to keep trying to pay attention to PRs, etc.**
44

5-
PHPoAuthLib provides oAuth support in PHP 5.3+ and is very easy to integrate with any project which requires an oAuth client.
5+
PHPoAuthLib provides oAuth support in PHP 7.2+ and is very easy to integrate with any project which requires an oAuth client.
66

77
[![Build Status](https://travis-ci.org/Lusitanian/PHPoAuthLib.png?branch=master)](https://travis-ci.org/Lusitanian/PHPoAuthLib)
88
[![Code Coverage](https://scrutinizer-ci.com/g/Lusitanian/PHPoAuthLib/badges/coverage.png?s=a0a15bebfda49e79f9ce289b00c6dfebd18fc98e)](https://scrutinizer-ci.com/g/Lusitanian/PHPoAuthLib/)
@@ -15,26 +15,14 @@ Installation
1515
This library can be found on [Packagist](https://packagist.org/packages/lusitanian/oauth).
1616
The recommended way to install this is through [composer](http://getcomposer.org).
1717

18-
Edit your `composer.json` and add:
19-
20-
```json
21-
{
22-
"require": {
23-
"lusitanian/oauth": "~0.3"
24-
}
25-
}
26-
```
27-
28-
And install dependencies:
2918

3019
```bash
31-
$ curl -sS https://getcomposer.org/installer | php
32-
$ php composer.phar install
20+
composer require lusitanian/oauth
3321
```
3422

3523
Features
3624
--------
37-
- PSR-0 compliant for easy interoperability
25+
- PSR-4
3826
- Fully extensible in every facet.
3927
- You can implement any service with any custom requirements by extending the protocol version's `AbstractService` implementation.
4028
- You can use any HTTP client you desire, just create a class utilizing it which implements `OAuth\Common\Http\ClientInterface` (two implementations are included)
@@ -123,4 +111,7 @@ Extensions
123111

124112
Tests
125113
------
126-
To run the tests, you must install dependencies with `composer install --dev`
114+
To run the tests, run the command
115+
```bash
116+
composer tests
117+
```

Diff for: composer.json

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lusitanian/oauth",
3-
"description": "PHP 5.3+ oAuth 1/2 Library",
3+
"description": "PHP 7.2 oAuth 1/2 Library",
44
"keywords": ["oauth", "authentication", "authorization", "security"],
55
"license": "MIT",
66
"authors": [
@@ -17,6 +17,18 @@
1717
"email": "[email protected]"
1818
}
1919
],
20+
"scripts" : {
21+
"tests" : [
22+
"./vendor/bin/phpunit"
23+
],
24+
"check" : [
25+
"./vendor/bin/php-cs-fixer fix --ansi --dry-run --diff",
26+
"./vendor/bin/phpunit --color=always"
27+
],
28+
"fix": [
29+
"./vendor/bin/php-cs-fixer fix --ansi"
30+
]
31+
},
2032
"require": {
2133
"php": "^7.2"
2234
},
@@ -26,8 +38,9 @@
2638
"ext-json": "*",
2739
"symfony/http-foundation": "~2.1",
2840
"predis/predis": "0.8.*@dev",
29-
"squizlabs/php_codesniffer": "2.*",
30-
"phpunit/phpunit": "8.5"
41+
"phpunit/phpunit": "8.5",
42+
"squizlabs/php_codesniffer": "^3.5",
43+
"friendsofphp/php-cs-fixer": "^2.16"
3144
},
3245
"suggest": {
3346
"symfony/http-foundation": "Allows using the Symfony Session storage backend.",

0 commit comments

Comments
 (0)