Skip to content
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
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ fix(action): wire composite action outputs

### Changed

- ci(GitHub): bump actions/checkout to v7 and actions/cache to v5
- docs(README): add PHPCS customization examples, common standards guidance, and troubleshooting notes
- ci(GitHub): bump actions/checkout to v7 and actions/cache to v6
- docs(readme): add PHPCS customization examples, common standards guidance, and troubleshooting notes
- shorten subject to fit most 80 characters
- Clarify the maintained PHPCS Composer package and cache reuse behavior, and rename the installation step to reflect cache misses.

### Fixed

- fix(action): wire composite action outputs `branch-name` and `changed-files` to step outputs
- Correct README action terminology, commit-message defaults, fallback ruleset and failure descriptions, and maintained documentation links.
- Correct readme action terminology, commit-message defaults, fallback ruleset and failure descriptions, and maintained documentation links.

## [1.0.4] - 2025-10-23

Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ permissions:
| Input | Description | Type | Default |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `commit-changes` | If set to `true`, the action will commit changes to the current branch; otherwise a new branch is created for manual review. | Boolean | `false` |
| `commit-message` | Commit message prefix; the action appends a UTC timestamp (`on YYYY-MM-DD HH:MM:SS UTC`). | String | `"chore(phpcf): apply PHP Code Beautifier fixes"` |
| `commit-message` | Commit message prefix; the action appends a UTC timestamp (`on YYYY-MM-DD HH:MM:SS UTC`). | String | `"chore(phpcf): apply PHP Code Beautifier fixes"` |
| `debug` | Enable extra debug output (list of branches). | Boolean | `false` |
| `extensions` | Comma-delimited list of file extensions to be sniffed. Note: an empty value will disable checking. | String | `"php"` (defaults to PHP only; other file types must be specified) |
| `ignore` | Ignore files based on a comma-separated list of patterns matching files and/or directories. | String | `vendor/` |
Expand Down Expand Up @@ -69,9 +69,9 @@ jobs:
uses: WorkOfStan/phpcs-fix@v1
with:
commit-changes: true
extensions: 'php,phtml,inc'
ignore: 'vendor/*,storage/*,bootstrap/cache/*'
standard: 'PSR12'
extensions: "php,phtml,inc"
ignore: "vendor/*,storage/*,bootstrap/cache/*"
standard: "PSR12"
```

Examples by input:
Expand Down Expand Up @@ -101,20 +101,20 @@ Select it explicitly in the workflow step:
- name: Run PHPCS fix with a custom ruleset
uses: WorkOfStan/phpcs-fix@v1
with:
standard: '.phpcs.xml'
standard: ".phpcs.xml"
```

This example keeps PSR12 checks except the line-length sniff. Use `vendor/bin/phpcs -s` locally with your ruleset to see sniff codes in reports. See the [annotated ruleset reference](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-Ruleset) for more exclusion options.

### Common Standards

| Standard | When to use it | Documentation |
| -------- | -------------- | ------------- |
| `PSR12` | A good default for modern PHP applications and libraries. | [PSR-12 specification](https://www.php-fig.org/psr/psr-12/) |
| `PEAR` | Useful for projects that already follow PEAR-style conventions or need compatibility with older codebases. | [PEAR Coding Standards](https://pear.php.net/manual/en/standards.php) |
| `Squiz` | Stricter built-in PHPCS standard with broader formatting and consistency checks than PSR-12. | [PHPCS usage and installed standards](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage#printing-a-list-of-installed-coding-standards) |
| `Zend` | Helpful for legacy Zend Framework style codebases that already align with that convention. | [PHPCS usage and installed standards](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage#printing-a-list-of-installed-coding-standards) |
| Custom ruleset | Best when your team needs project-specific sniffs, exclusions, or severity overrides. | [Annotated ruleset reference](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-Ruleset) |
| Standard | When to use it | Documentation |
| -------------- | ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PSR12` | A good default for modern PHP applications and libraries. | [PSR-12 specification](https://www.php-fig.org/psr/psr-12/) |
| `PEAR` | Useful for projects that already follow PEAR-style conventions or need compatibility with older codebases. | [PEAR Coding Standards](https://pear.php.net/manual/en/standards.php) |
| `Squiz` | Stricter built-in PHPCS standard with broader formatting and consistency checks than PSR-12. | [PHPCS usage and installed standards](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage#printing-a-list-of-installed-coding-standards) |
| `Zend` | Helpful for legacy Zend Framework style codebases that already align with that convention. | [PHPCS usage and installed standards](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage#printing-a-list-of-installed-coding-standards) |
| Custom ruleset | Best when your team needs project-specific sniffs, exclusions, or severity overrides. | [Annotated ruleset reference](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-Ruleset) |

If you are not sure where to start, try `standard: 'PSR12'` first and move to a project-local ruleset when you need exceptions or additional sniffs.

Expand Down
14 changes: 9 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ inputs:
description: "Comma delimited list of extensions to be sniffed"
required: false
type: string
default: "php" # "php,inc,lib"
# "php,inc,lib"
default: "php"
ignore:
description: "Ignore files based on a comma-separated list of patterns matching files and/or directories."
required: false
Expand All @@ -48,7 +49,8 @@ inputs:
description: "The name of, or the path to, the coding standard to use. Can be a comma-separated list specifying multiple standards."
required: false
type: string
default: "" # if left empty, .github/linters/phpcs.xml or https://github.com/super-linter/super-linter/blob/main/TEMPLATES/phpcs.xml will be used
# if left empty, .github/linters/phpcs.xml or https://github.com/super-linter/super-linter/blob/main/TEMPLATES/phpcs.xml will be used
default: ""
stop-on-manual-fix:
description: "If true, the execution will stop when manual fixes are necessary."
type: boolean
Expand All @@ -72,8 +74,10 @@ runs:
- name: Checkout code
uses: actions/checkout@v7
with:
ref: ${{ github.ref }} # Fetch latest changes (even by previous job)
fetch-depth: 0 # Fetch all history for all branches and tags. Otherwise github.event.pull_request.base.ref SHA isn't found.
# Fetch latest changes (even by previous job)
ref: ${{ github.ref }}
# Fetch all history for all branches and tags. Otherwise github.event.pull_request.base.ref SHA isn't found.
fetch-depth: 0

# Fetch latest changes (even by previous job)
- name: Fetch latest changes
Expand All @@ -90,7 +94,7 @@ runs:
# A repository can have up to 10 GB of caches. Once the 10 GB limit is reached, older caches will be evicted based on when the cache was last accessed.
# Caches that are not accessed within the last week will also be evicted.
- name: Cache composer dependencies
uses: actions/cache@v5
uses: actions/cache@v6
id: vendor-cache
with:
# path to Checkout working directory is /home/runner/work/repo-name/repo-name , so just add /vendor/
Expand Down
Loading