Skip to content

Commit

Permalink
Merge pull request #1060 from phpmd/3.x-update
Browse files Browse the repository at this point in the history
Reset 3.x to current master state
  • Loading branch information
kylekatarnls committed Jan 17, 2024
2 parents da5d298 + efbdcdf commit 8dae244
Show file tree
Hide file tree
Showing 486 changed files with 18,002 additions and 3,254 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

/src/test export-ignore
/src/site export-ignore
/src/phar export-ignore
/vendor/squizlabs export-ignore
.gitattributes export-ignore
.github export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.travis.yml export-ignore
Expand Down
13 changes: 7 additions & 6 deletions CONTRIBUTING.md → .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ The PHPMD project welcomes your contribution. There are several ways to help out
if you have found a bug or have an idea for a feature
* Write test cases for open bug issues
* Write patches for open bug/feature issues
* Participate on the PHPMD IRC Channel
* Participate on the PHPMD Gitter Channel

There are a few guidelines that we need contributors to follow, so that we have a
chance of keeping on top of things.

* The code must follow the [PSR-2 coding standard](http://www.php-fig.org/psr/psr-2/).
* The code must follow the [coding standard](https://github.com/phpmd/phpmd/blob/master/phpcs.xml.dist), that is based on [PSR-2 coding standard](http://www.php-fig.org/psr/psr-2/) with additional rules.
* All code changes should be covered by unit tests

Issues
Expand All @@ -22,19 +22,20 @@ Issues
* Make sure it does not already exist.
* Clearly describe the issue including steps to reproduce, when it is a bug.
* Make sure you note the PHPMD version you use.
* Use one of the issue templates.

Coding Standard
---------------

Make sure your code changes comply with the PSR-2 coding standard by
Make sure your code changes comply with the [coding standard](https://github.com/phpmd/phpmd/blob/master/phpcs.xml.dist) by
using [PHP Codesniffer](https://github.com/squizlabs/PHP_CodeSniffer)
from within your PHPMD folder:

vendor/bin/phpcs -p --extensions=php --standard=PSR2 src > phpcs.txt
vendor/bin/phpcs -p --extensions=php src > phpcs.txt

Linux / OS X users may extend this command to exclude files, that are not part of a commit:

vendor/bin/phpcs -p --extensions=php --standard=PSR2 --ignore=src/tests/resources $(git ls-files -om --exclude-standard | grep '\.php$') > phpcs.txt
vendor/bin/phpcs -p --extensions=php --ignore=src/tests/resources $(git ls-files -om --exclude-standard | grep '\.php$') > phpcs.txt

Check the ``phpcs.txt`` once it finished.

Expand All @@ -44,4 +45,4 @@ Additional Resources
* [Existing issues](https://github.com/phpmd/phpmd/issues/)
* [General GitHub documentation](https://help.github.com/)
* [GitHub pull request documentation](https://help.github.com/articles/creating-a-pull-request/)
* [PHPMD IRC Channel on freenode.org](http://webchat.freenode.net/?channels=phpmd)
* [PHPMD Gitter Channel](https://gitter.im/phpmd/community)
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tidelift: "packagist/phpmd/phpmd"
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/1_Bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: "Bug"
about: 'Report a problem with PHPMD'
---

- PHPMD version: #.#.#
- PHP Version: #.#.#
- Installation type: (phar file/ composer)
- Operating System / Distribution & Version: (Windows 10 / CentOS 7.6 / ...)

### Current Behavior
Explain the result that you get.

### Expected Behavior
Explain the result that you expected.

### Steps To Reproduce:
Explain **all** the steps you did to create this bug so we can reproduce it.

## Checks before submitting
* [ ] Be sure that there isn't already an issue about this. See: [Issues list](https://github.com/phpmd/phpmd/issues)
* [ ] Be sure that there isn't already a pull request about this. See: [Pull requests](https://github.com/phpmd/phpmd/pulls)
* [ ] I have added every step to reproduce the bug.
* [ ] If possible I added relevant code examples.
* [ ] This issue is about 1 bug and nothing more.
* [ ] The issue has a descriptive title. For example: "JSON rendering failed on Windows for filenames with space".
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/2_Feature_Proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: "Feature Proposal"
about: 'Propose a new feature'

---

## Description
Describe the proposal, explain what it does and why.
Try to describe the benefits but also the consequences of the proposal.

## Checks before submitting
* [ ] Be sure that there isn't already an issue about this. See: [Issues list](https://github.com/phpmd/phpmd/issues)
* [ ] Be sure that there isn't already a pull request about this. See: [Pull requests](https://github.com/phpmd/phpmd/pulls)
* [ ] Tell if you have the option to provide the code for this proposal.
* [ ] This issue is about 1 feature proposal and nothing more.
* [ ] The issue has a descriptive title. For example: "Add JSON render option".
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/3_Question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: "Question"
about: 'This repository is for bugs and feature proposals only. If you have any question please visit or community on Gitter to ask the questions: https://gitter.im/phpmd/community'
---

This repository is only for bugs and feature proposals.

If you have any question or need support please visit our Gitter channel: https://gitter.im/phpmd/community

Thank you!
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/4_Documentation_and_Website_Issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: "Documentation & Website Issue"
about: 'Do you see something incorrect or do you miss some information in the documentation or the website. Tell us.'
---

## Description
Describe what you miss or is incorrect on the [website](https://phpmd.org/) or in the documentation. Be as explicit as possible.
If possible add a URL to the incorrect web page/documentation.


## Checks before submitting
* [ ] Be sure that there isn't already an issue about this. See: [Issues list](https://github.com/phpmd/phpmd/issues)
* [ ] Be sure that there isn't already a pull request about this. See: [Pull requests](https://github.com/phpmd/phpmd/pulls)
* [ ] Tell if you have the possibility to create a Pull Request to solve this issue.
* [ ] If possible add a URL to the incorrect website page or documentation file.
* [ ] This issue is about 1 documentation or website issue and nothing more.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Gitter
url: https://gitter.im/phpmd/community
about: Chat with us on Gitter
36 changes: 36 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Type: (bugfix / feature / refactoring / documentation update)
Issue: Resolves #.. the corresponding issue for this PR (if exist)
Breaking change: yes/no (if yes explain why)

<!--
Explain what the PR does and also why. If you have parts you are not sure about, please explain.
Please check this points before submitting your PR.
- Add test to cover the changes you made on the code.
- If you have a change on the documentation, please link to the page that you change.
- If you add a new feature please update the documentation in the same PR.
- If you really need to add a breaking change, explain why it is needed. Understand that this result in a lower change to get the PR accepted.
- Any PR need 2 approvals before it get merged, sometimes this can take some time. Please be patient.
## Adding a New Rule
- Add the new rule to the matching rule set XML, e.g. ``src/main/resources/rulesets/naming.xml``
- Add documentation for the new rule, e.g. ``src/site/rst/rules/naming.rst``
- Implement the new rule, e.g. ``src/main/php/PHPMD/Rule/Naming/LongVariable.php``
- Cover cases for the new rule in the rule test, e.g. ``src/test/php/PHPMD/Rule/Naming/LongVariableTest.php``
-- Cover the case when the new rule *should* apply
-- Cover the case when the new rule *should not* apply
-- Cover edge cases of the new rule
## Adding a New Rule Property
- Add the new property to rule set XML, e.g. ``src/main/resources/rulesets/naming.xml``
- Add documentation for the new property, e.g. ``src/site/rst/rules/naming.rst``
- Implement new property in rule, e.g. ``src/main/php/PHPMD/Rule/Naming/LongVariable.php``
- Cover cases for the new property in rule test, e.g. ``src/test/php/PHPMD/Rule/Naming/LongVariableTest.php``
-- Cover the case when the new property is not set and the rule *should not* apply
-- Cover the case when the new property is not set and the rule *should* apply
-- Cover case when the new property is set and the rule *should not* apply
-- Cover case when the new property is set and the rule *should* apply
-- Cover edge cases of the new property, if any
-->
5 changes: 5 additions & 0 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Security contact information

To report a security vulnerability, please use the
[Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.
64 changes: 64 additions & 0 deletions .github/workflows/build_site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build website

on:
push:
branches:
- "master"

jobs:
php-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
COMPOSER_NO_INTERACTION: 1

strategy:
matrix:
php: [7.4]
dependency-version: [prefer-stable]

name: Build website

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.dependency-version }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.dependency-version }}
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Copy files
run: cp src/site/rst/* src/site/resources/web/ -r

- name: Build website
run: composer build-website
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CNAME: phpmd.org

- name: Archive generated website
uses: actions/upload-artifact@v3
with:
name: Website
path: dist/website/*

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist/website/
59 changes: 59 additions & 0 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Codestyle

on:
push:
branches:
- "*"
paths:
- '**.php'
- 'composer.json'
- 'phpcs.xml.dist'
- '.github/workflows/codestyle.yml'
pull_request:
branches:
- "*"
paths:
- '**.php'
- 'composer.json'
- 'phpcs.xml.dist'
- '.github/workflows/codestyle.yml'

jobs:
php-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
COMPOSER_NO_INTERACTION: 1

strategy:
matrix:
php: [7.4]
dependency-version: [prefer-stable]

name: Codestyle check

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.dependency-version }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.dependency-version }}
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run PHPCS for the codestyle
run: vendor/bin/phpcs
74 changes: 74 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Coverage

on:
push:
branches:
- "*"
pull_request:
branches:
- "*"

jobs:
php-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
COMPOSER_NO_INTERACTION: 1

strategy:
matrix:
php: [8.3]
dependency-version: [prefer-stable]

name: PHP ${{ matrix.php }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: xdebug

- name: Cache library packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-coverage-${{ matrix.php }}-${{ hashFiles('composer.json') }}
restore-keys: ${{ runner.os }}-coverage-${{ matrix.php }}-

- name: Cache test packages
id: composer-test-cache
uses: actions/cache@v3
with:
path: src/test/vendor
key: ${{ runner.os }}-coverage-test-${{ matrix.php }}-${{ hashFiles('src/test/composer.json') }}
restore-keys: ${{ runner.os }}-coverage-test-${{ matrix.php }}-

- name: Upgrade PHPUnit
run: |
composer require symfony/config:^6.4 --no-update --no-interaction --dev
cd src/test && composer require phpunit/phpunit:^5.7.27 --no-update --no-interaction --dev
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer update --no-progress --prefer-stable --prefer-dist --no-progress --ignore-platform-req=php+

- name: Install test dependencies
if: steps.composer-test-cache.outputs.cache-hit != 'true'
run: cd src/test && composer update --no-progress --prefer-dist --prefer-stable --ignore-platform-req=php+

- name: Fix PHP compatibility
run: php src/test/php/fix-php-compatibility.php

- name: Execute Unit Tests
run: src/test/vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml

- name: Archive code coverage results
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml

0 comments on commit 8dae244

Please sign in to comment.