Skip to content

Commit 736635c

Browse files
authored
Merge pull request #215 from DigitalTimK/code_quality
Code quality
2 parents aaa7771 + 6210d7e commit 736635c

File tree

92 files changed

+1044
-1593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1044
-1593
lines changed

.php-cs-fixer.php

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,70 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
7+
*
8+
* Copyright (c) 2016-2024 BigBlueButton Inc. and by respective authors (see below).
9+
*
10+
* This program is free software; you can redistribute it and/or modify it under the
11+
* terms of the GNU Lesser General Public License as published by the Free Software
12+
* Foundation; either version 3.0 of the License, or (at your option) any later
13+
* version.
14+
*
15+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
16+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
17+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public License along
20+
* with BigBlueButton; if not, see <https://www.gnu.org/licenses/>.
21+
*/
22+
23+
use PhpCsFixer\Config;
24+
use PhpCsFixer\Finder;
25+
526
$header = <<<'EOF'
6-
BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
27+
BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
728
8-
Copyright (c) 2016-2023 BigBlueButton Inc. and by respective authors (see below).
29+
Copyright (c) 2016-2024 BigBlueButton Inc. and by respective authors (see below).
930
10-
This program is free software; you can redistribute it and/or modify it under the
11-
terms of the GNU Lesser General Public License as published by the Free Software
12-
Foundation; either version 3.0 of the License, or (at your option) any later
13-
version.
31+
This program is free software; you can redistribute it and/or modify it under the
32+
terms of the GNU Lesser General Public License as published by the Free Software
33+
Foundation; either version 3.0 of the License, or (at your option) any later
34+
version.
1435
15-
BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
16-
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
17-
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
36+
BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
37+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
38+
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
1839
19-
You should have received a copy of the GNU Lesser General Public License along
20-
with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
21-
EOF;
40+
You should have received a copy of the GNU Lesser General Public License along
41+
with BigBlueButton; if not, see <https://www.gnu.org/licenses/>.
42+
EOF;
2243

23-
$finder = PhpCsFixer\Finder::create()
44+
$finder = Finder::create()
2445
->files()
2546
->name(['*.php'])
2647
->in(__DIR__ . '/src')
27-
->in(__DIR__ . '/tests');
48+
->in(__DIR__ . '/tests')
49+
;
2850

29-
$config = new PhpCsFixer\Config();
51+
$config = new Config();
3052
$config
3153
->setRiskyAllowed(true)
3254
->setRules([
33-
'@PhpCsFixer' => true,
34-
'@PHP74Migration' => true,
55+
'@PhpCsFixer' => true,
56+
'@PHP74Migration' => true,
3557
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']], // one should use PHPUnit built-in method instead
36-
'header_comment' => ['header' => $header],
37-
'concat_space' => ['spacing' => 'one'],
38-
'function_declaration' => ['closure_function_spacing' => 'none'],
39-
'constant_case' => ['case' => 'lower'],
40-
'single_quote' => true,
41-
'mb_str_functions' => true,
42-
'array_syntax' => ['syntax' => 'short'],
43-
'binary_operator_spaces' => ['operators' =>
44-
['=>' => 'align_single_space_minimal', '=' => 'align_single_space_minimal']
58+
'header_comment' => ['header' => $header],
59+
'concat_space' => ['spacing' => 'one'],
60+
'function_declaration' => ['closure_function_spacing' => 'none'],
61+
'constant_case' => ['case' => 'lower'],
62+
'single_quote' => true,
63+
'mb_str_functions' => true,
64+
'array_syntax' => ['syntax' => 'short'],
65+
'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal', '=' => 'align_single_space_minimal'],
4566
],
4667
])
47-
->setFinder($finder);
68+
->setFinder($finder)
69+
;
4870

4971
return $config;

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,32 @@ install and usage example.
3131
Bugs and feature request are tracked on [GitHub](https://github.com/bigbluebutton/bigbluebutton-api-php/issues)
3232

3333
## Contributing guidelines
34-
### Code style
34+
### Code Quality 1: Style
3535

3636
Make sure the code style configuration is applied by running PHPCS-Fixer.
3737

38+
```bash
39+
# using an alias
40+
$ composer cs-fix
3841
```
39-
composer cs-fix
42+
43+
### Code Quality 2: Static code analysis
44+
PHPStan shall be used for static code analysis by running the command below:
45+
46+
```bash
47+
# using an alias
48+
$ composer code-check
49+
50+
# or the same w/o alias
51+
$ ./vendor/bin/phpstan analyse
4052
```
4153

42-
### Running tests
54+
### Code Quality 3: Tests
4355

4456
For every implemented feature add unit tests and check all is green by running the command below.
4557

4658
```bash
47-
composer test
59+
$ composer test
4860
```
4961

5062
To run a single test

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"ext-curl": "*",
2828
"ext-simplexml": "*",
2929
"ext-mbstring": "*",
30+
"ext-json": "*",
3031
"marc-mabe/php-enum": "^v4.7.0"
3132
},
3233
"require-dev": {
@@ -38,9 +39,12 @@
3839
"nunomaduro/phpinsights": "^v2.11.0",
3940
"bmitch/churn-php": "^1.7.1",
4041
"phpmetrics/phpmetrics": "^v2.8.2",
41-
"wapmorgan/php-deprecation-detector": "^2.0.33"
42+
"wapmorgan/php-deprecation-detector": "^2.0.33",
43+
"phpstan/phpstan": "^1.10",
44+
"tracy/tracy": "^2.10"
4245
},
4346
"scripts": {
47+
"code-check": "./vendor/bin/phpstan analyse",
4448
"test": "./vendor/bin/phpunit",
4549
"test-cov": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html coverage",
4650
"cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer fix --allow-risky yes",

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 8
3+
paths:
4+
- src/
5+
- tests/

phpunit.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@
1818
</testsuite>
1919
</testsuites>
2020
</phpunit>
21-

0 commit comments

Comments
 (0)