Skip to content

Commit

Permalink
Merge branch 'cleanup'
Browse files Browse the repository at this point in the history
  • Loading branch information
lkrms committed Jan 8, 2025
2 parents 8fc16d9 + f75c1dc commit af5e85f
Show file tree
Hide file tree
Showing 83 changed files with 3,068 additions and 2,625 deletions.
96 changes: 72 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
check-ci-runs:
name: Check previous runs
if: ${{ github.event_name != 'workflow_call' }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
outputs:
ci_required: ${{ steps.check-ci-runs.outputs.ci_required }}
steps:
Expand All @@ -34,7 +34,7 @@ jobs:
needs:
- check-ci-runs
if: ${{ (github.event_name == 'workflow_call' || needs.check-ci-runs.outputs.ci_required == 1) && !cancelled() && !failure() }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Checkout
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
- "8.4"
- "7.4"

runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Checkout
Expand Down Expand Up @@ -124,21 +124,21 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu-latest
- ubuntu-24.04
- windows-latest
- macos-latest
php-version:
- "8.4"
include:
- os: ubuntu-latest
- os: ubuntu-24.04
php-version: "8.3"
- os: ubuntu-latest
- os: ubuntu-24.04
php-version: "8.2"
- os: ubuntu-latest
- os: ubuntu-24.04
php-version: "8.1"
- os: ubuntu-latest
- os: ubuntu-24.04
php-version: "8.0"
- os: ubuntu-latest
- os: ubuntu-24.04
php-version: "7.4"

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -197,7 +197,7 @@ jobs:
- phpstan
- unit-tests
if: ${{ (github.event_name == 'workflow_call' || needs.check-ci-runs.outputs.ci_required == 1) && !cancelled() && !failure() }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
outputs:
artifact_name: ${{ steps.run-build-script.outputs.artifact_name }}
artifact_path: ${{ steps.run-build-script.outputs.artifact_path }}
Expand Down Expand Up @@ -268,21 +268,21 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu-latest
- ubuntu-24.04
- windows-latest
- macos-latest
php-version:
- "8.4"
include:
- os: ubuntu-latest
- os: ubuntu-24.04
php-version: "8.3"
- os: ubuntu-latest
- os: ubuntu-24.04
php-version: "8.2"
- os: ubuntu-latest
- os: ubuntu-24.04
php-version: "8.1"
- os: ubuntu-latest
- os: ubuntu-24.04
php-version: "8.0"
- os: ubuntu-latest
- os: ubuntu-24.04
php-version: "7.4"

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -314,25 +314,29 @@ jobs:
needs:
- check-ci-runs
- build
- test-phar
if: ${{ (github.event_name == 'workflow_call' || needs.check-ci-runs.outputs.ci_required == 1) && !cancelled() && !failure() }}

strategy:
fail-fast: false
matrix:
repository:
- laravel/framework
args:
config:
- --include-if-php --preset laravel src tests bin
args:
- --quiet --timers
include:
- repository: drupal/drupal
args: --exclude '/\/(\.git|\.hg|\.svn|_?build|dist|vendor|core\/lib\/Drupal\/Component\/Transliteration\/data)\/$/' --include-if-php=/./ --preset drupal .
config: --exclude '/\/(\.git|\.hg|\.svn|_?build|dist|vendor|core\/lib\/Drupal\/Component\/Transliteration\/data)\/$/' --include-if-php=/./ --preset drupal .
args: --quiet --timers
- repository: symfony/symfony
args: --include-if-php --preset symfony .
config: --include-if-php --preset symfony .
args: --quiet --timers
- repository: WordPress/WordPress
args: --include-if-php --preset wordpress .
config: --include-if-php --preset wordpress .
args: --quiet --timers --no-problems

runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Checkout ${{ matrix.repository }}
Expand All @@ -344,10 +348,54 @@ jobs:
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.artifact_name }}
path: ~/

- name: Run pretty-php
id: run-pretty-php
shell: bash
env:
artifact_path: ${{ needs.build.outputs.artifact_path }}
repository: ${{ matrix.repository }}
run: |
php "$artifact_path" --print-config ${{ matrix.args }} | tee .prettyphp
php "$artifact_path" --quiet --timers || { status=$? && [[ $status -eq 4 ]] || (exit $status); }
check_status() {
local s=$?
((s == 4)) || return $s
}
set -o pipefail
shopt -s dotglob extglob
artifact_path=~/$artifact_path
php "$artifact_path" --print-config ${{ matrix.config }} | tee .prettyphp
php "$artifact_path" ${{ matrix.args }} || check_status
echo
echo "Downloading latest release to format $repository for comparison"
latest_path=~/pretty-php-latest.phar
latest_url=https://github.com/lkrms/pretty-php/releases/latest/download/pretty-php.phar
diff_path=~/${repository%/*}.diff
: >"$diff_path"
# Stage changes in the background
git add !(.prettyphp) &
# Download latest release in the foreground
curl -fLo "$latest_path" "$latest_url" &&
# Wait for background command to finish
wait $! &&
# Keep index and restore working tree to HEAD
git restore -s HEAD . &&
{ php "$latest_path" --fast ${{ matrix.args }} || check_status; } &&
echo &&
# Swap inputs so diff is from working tree to index
git diff -U5 -R --exit-code | tee "$diff_path" &&
echo "No differences found" || true
printf 'diff_name=%s\n' "${diff_path##*/}" >>"$GITHUB_OUTPUT"
printf 'diff_path=%s\n' "$([[ ! -s $diff_path ]] || printf '%s\n' "$diff_path")" >>"$GITHUB_OUTPUT"
- name: Upload diff artifact
if: ${{ !cancelled() && !failure() && steps.run-pretty-php.outputs.diff_path != '' }}
uses: actions/upload-artifact@v4
with:
name: ${{ steps.run-pretty-php.outputs.diff_name }}
path: ${{ steps.run-pretty-php.outputs.diff_path }}
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:
jobs:
build:
name: Build
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Checkout
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Deploy to GitHub Pages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ on:
jobs:
delete-runs:
name: Delete workflow runs
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

permissions:
actions: write
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
homebrew:
name: Update Homebrew formula
if: ${{ github.event_name != 'workflow_dispatch' || inputs.update-homebrew }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Bump Homebrew formula and push to lkrms/misc tap
Expand All @@ -52,7 +52,7 @@ jobs:
aur:
name: Update AUR package
if: ${{ github.event_name != 'workflow_dispatch' || inputs.update-aur }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Checkout
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
vscode:
name: Update VS Code extension
if: ${{ github.event_name != 'workflow_dispatch' || inputs.update-vscode }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
check-ci-runs:
name: Check CI workflow runs
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
outputs:
ci_required: ${{ steps.check-ci-runs.outputs.ci_required }}
steps:
Expand All @@ -32,7 +32,7 @@ jobs:
needs:
- ci
if: ${{ !cancelled() && !failure() }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'T_PUBLIC_SET',
'T_PROPERTY_C',
'T_ATTRIBUTE_COMMENT',
'T_END_ALT_SYNTAX',
'T_CLOSE_ALT',
'T_NULL',
'T_OPEN_UNENCLOSED',
'T_CLOSE_UNENCLOSED',
Expand Down
4 changes: 2 additions & 2 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'T_PROPERTY_C' => false,
// Custom
'T_ATTRIBUTE_COMMENT' => false,
'T_END_ALT_SYNTAX' => false,
'T_CLOSE_ALT' => false,
'T_NULL' => false,
'T_OPEN_UNENCLOSED' => false,
'T_CLOSE_UNENCLOSED' => false,
Expand Down Expand Up @@ -80,7 +80,7 @@
// Define custom tokens
$id = 20000;
defined('T_ATTRIBUTE_COMMENT') || define('T_ATTRIBUTE_COMMENT', $getNextId());
defined('T_END_ALT_SYNTAX') || define('T_END_ALT_SYNTAX', $getNextId());
defined('T_CLOSE_ALT') || define('T_CLOSE_ALT', $getNextId());
defined('T_NULL') || define('T_NULL', $getNextId());
defined('T_OPEN_UNENCLOSED') || define('T_OPEN_UNENCLOSED', $getNextId());
defined('T_CLOSE_UNENCLOSED') || define('T_CLOSE_UNENCLOSED', $getNextId());
Expand Down
14 changes: 7 additions & 7 deletions docs/Flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
| 1, 2 | 6 | `SHELL_COMMENT` ("#") | `Parser` |
| 0, 3 | 9 | `C_COMMENT` ("/\*") | `Parser` |
| 1, 3 | 10 | `DOC_COMMENT` ("/\*\*") | `Parser` |
| 4 | 16 | `INFORMAL_DOC_COMMENT` | `Parser` |
| 4 | 16 | `C_DOC_COMMENT` | `Parser` |
| 5 | 32 | `COLLAPSIBLE_COMMENT` | `NormaliseComments` |
| 6 | 64 | `CODE` | `Parser` |
| 7 | 128 | `STATEMENT_TERMINATOR` | `Parser` |
| 7 | 128 | `TERMINATOR` | `Parser` |
| 8 | 256 | `STRUCTURAL_BRACE` | `Parser` |
| 9 | 512 | `TERNARY_OPERATOR` | `Parser` |
| 9 | 512 | `TERNARY` | `Parser` |
| 10 | 1024 | `FN_DOUBLE_ARROW` | `Parser` |
| 11 | 2048 | `NAMED_DECLARATION` | `Parser` |
| 12 | 4096 | `LIST_PARENT` | `Formatter` |
| 13 | 8192 | `LIST_ITEM` | `Formatter` |
| 14 | 16384 | `UNENCLOSED_PARENT` | `Parser` |
| 11 | 2048 | `DECLARATION` | `Parser` |
| 12 | 4096 | `UNENCLOSED_PARENT` | `Parser` |
| 13 | 8192 | `LIST_PARENT` | `Formatter` |
| 14 | 16384 | `LIST_ITEM` | `Formatter` |

## `Token::$Whitespace`

Expand Down
Loading

0 comments on commit af5e85f

Please sign in to comment.