Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize PHP code #1

Merged
merged 14 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .coveralls.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/build export-ignore
/examples export-ignore
/tests export-ignore
/.coveralls.yml export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/CONTRIBUTING.md export-ignore
Expand Down
20 changes: 7 additions & 13 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,10 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1]
php: [8.1, 8.2, 8.3]
ocular: [^1.9]
experimental: [false]
composer-extra: ['']
include:
- php: 5.6
experimental: false
ocular: ~1.8.1
- php: 8.2
experimental: true
ocular: ^1.9
composer-extra: '--ignore-platform-req=php+'
env:
PHP_VERSION: ${{ matrix.php }}
name: PHP ${{ matrix.php }}
Expand All @@ -43,7 +35,7 @@ jobs:

- name: Validate composer.json
run: composer validate

- name: Cache composer files
uses: actions/cache@v3
with:
Expand All @@ -56,8 +48,10 @@ jobs:
- name: PHP CodeStyle
run: |
mkdir -p build/logs
vendor/bin/phpcs src tests --extensions=php --ignore=bootstrap --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=build/config/phpcs.xml -v
vendor/bin/phpmd src,tests xml build/config/phpmd.xml
composer phpcs

- name: Run PHPStan
run: composer phpstan

- name: Run PHPUnit
run: vendor/bin/phpunit -c phpunit.xml --verbose
run: composer phpunit
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

/.buildpath
/.project
/.settings/*
vendor
/.idea
.phpunit.result.cache
composer.lock
composer.phar
coverage/
!build/logs/.gitkeep
build/logs/
test.php
*.iml
/remotes/
15 changes: 6 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,30 @@ Contributions are **welcome** and will be fully **credited**.
## Pull Requests

- **Document any change in behavior** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Create feature branches** - Don't ask us to pull from your master branch.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

## Coding Standard

- The **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** is to be used for all code.
- **[PHPMD](http://phpmd.org/)** is used to help keep the code clean but exceptions can exist.

- **[PHPStan](https://phpstan.org/)** is used to help keep the code clean. At the moment, PHPStan level 5 is enforced.
- Use the following commands to check your code before committing it:

```sh
$ vendor/bin/phpcs src tests --extensions=php --ignore=bootstrap --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=build/config/phpcs.xml -v
$ vendor/bin/phpmd src,tests xml build/config/phpmd.xml
$ composer phpcs
$ composer phpstan
```

## Tests

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
- Use the following command to run the tests:

- Run tests by calling `phpunit`
```sh
$ vendor/bin/phpunit
$ composer phpunit
```

The coding standard, mess detection and tests are validated by [GitHub Actions](.github).
The code quality is validated by [GitHub Actions](.github).

# Can't Contribute?

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GameQ is a PHP library that allows you to query multiple types of multiplayer ga
This repository is a maintained fork of [Austinb/GameQ](https://github.com/Austinb/GameQ).

## Requirements
* PHP 5.6.40+ - [Tested](https://github.com/KrymoSoftware/GameQ/actions/workflows/Tests.yml) in PHP 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1 & 8.2-dev
* PHP 8.1+ - [Tested](https://github.com/KrymoSoftware/GameQ/actions/workflows/Tests.yml) in PHP 8.1, 8.2 and 8.3
* [Bzip2](http://www.php.net/manual/en/book.bzip2.php) - Used for A2S compressed responses

## Installation
Expand Down
63 changes: 0 additions & 63 deletions build/config/phpmd.xml

This file was deleted.

Empty file added build/logs/.gitkeep
Empty file.
39 changes: 24 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,21 @@
"wiki": "https://github.com/Austinb/GameQ/wiki"
},
"require": {
"php": ">=5.6.40",
"php": ">=8.1",
"ext-bz2": "*",
"ext-xml": "*"
"ext-xml": "*",
"ext-simplexml": "*"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^5.7 | ^6.0 | ^7.0 | ^8.0 | ^9.0",
"phpunit/phpunit": "^9.0",
"phpunit/php-invoker": "*",
"phpmd/phpmd": "@stable",
"squizlabs/php_codesniffer": "3.*@stable",
"corneltek/getoptionkit": "~2"
"corneltek/getoptionkit": "~2",
"phpstan/phpstan": "^1.12",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan-deprecation-rules": "^1.2",
"phpstan/phpstan-phpunit": "^1.4"
},
"autoload": {
"psr-4": {
Expand All @@ -84,18 +88,23 @@
},
"scripts": {
"test": [
"@test-phpcs",
"@test-phpmd",
"@test-php"
"@phpcs",
"@phpstan",
"@phpunit"
],
"test-php": "vendor/bin/phpunit",
"test-phpcs": "vendor/bin/phpcs src tests --extensions=php --ignore=bootstrap --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=build/config/phpcs.xml -v",
"test-phpmd": "vendor/bin/phpmd src,tests xml build/config/phpmd.xml"
"phpcs": "vendor/bin/phpcs src tests --extensions=php --ignore=bootstrap --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=build/config/phpcs.xml -v",
"phpstan": "vendor/bin/phpstan analyse src",
"phpunit": "vendor/bin/phpunit"
},
"scripts-descriptions": {
"test": "Run all tests!",
"test-php": "Run phpunit tests",
"test-phpcs": "Run PHP Code Style checks",
"test-phpmd": "Run PHP Mess Detector checks"
"test": "Run all tests and checks",
"phpcs": "Run PHP Code Style checks",
"phpstan": "Run PHPStan checks",
"phpunit": "Run PHPUnit tests"
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
}
}
4 changes: 4 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 5
paths:
- src
4 changes: 1 addition & 3 deletions src/GameQ/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
* i.e. require_once('/path/to/src/GameQ/Autoloader.php');
*
* See: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
*
* @codeCoverageIgnore
*/
spl_autoload_register(function ($class) {
spl_autoload_register(static function ($class) {

// project-specific namespace prefix
$prefix = 'GameQ\\';
Expand Down
Loading
Loading