Skip to content

Commit 33f24aa

Browse files
committed
Modernize parser to PHP 8.1+ with phpstan/phpdoc-parser
Complete rewrite of the parser architecture from legacy phpdocumentor/reflection to modern PHP libraries while maintaining 100% backward compatibility. ## Major Changes ### Core Dependencies - PHP requirement: 5.4+ → 8.1+ - Replace phpdocumentor/reflection v3.0 with phpstan/phpdoc-parser v2.0 - Add nikic/php-parser v5.0 for AST-based parsing - Update PHPUnit: v7 → v9 for WordPress compatibility ### Parser Architecture - Rewrite File_Reflector to use PHPParser NodeVisitorAbstract - Implement modern AST traversal for improved accuracy - Add advanced PHPDoc parsing with type support - Maintain backward compatibility through runner.php bridge ### Features Added - Namespace detection and tracking - Property docblock parsing with visibility - File-level docblock detection - Advanced tag parsing (@param, @return with types) - Class name resolution (self, parent, $this) - Modern PHP syntax support ### Development Environment - Update to Node.js 20+ with .nvmrc and .npmrc - Modernize GitHub Actions for PHP 8.1-8.3 testing - Add comprehensive documentation and contribution guidelines - Add Dependabot for automated dependency updates ### Test Results - All 22 tests passing (100% success rate) - Full WordPress integration via wp-env - Complete API compatibility maintained
1 parent 7fc2227 commit 33f24aa

20 files changed

+3678
-1769
lines changed

.github/dependabot.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for npm
4+
- package-ecosystem: "npm"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
open-pull-requests-limit: 10
9+
groups:
10+
wordpress:
11+
patterns:
12+
- "@wordpress/*"
13+
update-types:
14+
- "minor"
15+
- "patch"
16+
17+
# Enable version updates for Composer
18+
- package-ecosystem: "composer"
19+
directory: "/"
20+
schedule:
21+
interval: "weekly"
22+
open-pull-requests-limit: 10
23+
groups:
24+
phpstan:
25+
patterns:
26+
- "phpstan/*"
27+
update-types:
28+
- "minor"
29+
- "patch"
30+
phpunit:
31+
patterns:
32+
- "phpunit/*"
33+
update-types:
34+
- "minor"
35+
- "patch"
36+
37+
# Enable version updates for GitHub Actions
38+
- package-ecosystem: "github-actions"
39+
directory: "/"
40+
schedule:
41+
interval: "weekly"

.github/workflows/unit-test.yml

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,34 @@ on:
66
workflow_dispatch:
77

88
jobs:
9-
test-php:
10-
runs-on: ubuntu-latest
11-
strategy:
12-
fail-fast: false
13-
matrix:
14-
php:
15-
- '7.4'
16-
17-
env:
18-
WP_ENV_PHP_VERSION: ${{ matrix.php }}
19-
20-
steps:
9+
test-php:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php:
15+
- '8.1'
16+
- '8.2'
17+
- '8.3'
18+
19+
env:
20+
WP_ENV_PHP_VERSION: ${{ matrix.php }}
21+
22+
steps:
2123
- name: Checkout
2224
uses: actions/checkout@v4
2325

24-
- name: Install
25-
run: npm install
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version-file: '.nvmrc'
30+
cache: 'npm'
31+
32+
- name: Install Node.js dependencies
33+
run: npm ci
2634

27-
- name: Setup Environment
28-
run: |
29-
rm composer.lock
30-
npm run setup
35+
- name: Setup WordPress environment
36+
run: npm run setup
3137

32-
- name: Test
38+
- name: Run tests
3339
run: npm run test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor
22
coverage
33
node_modules
4+
.phpunit.result.cache

.npmrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Use exact versions for reproducible builds
2+
save-exact=true
3+
4+
# Automatically install peer dependencies
5+
auto-install-peers=true
6+
7+
# Use npm audit signatures
8+
audit-level=moderate
9+
10+
# Progress display for CI environments
11+
progress=false
12+
13+
# Engine strict mode
14+
engine-strict=true

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

.wp-env.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"phpVersion": "7.4",
2+
"phpVersion": "8.2",
33
"plugins": [
44
".",
55
"https://downloads.wordpress.org/plugin/posts-to-posts.latest-stable.zip"

0 commit comments

Comments
 (0)