Repository: prettier/plugin-php
Pull request #2411 (2024-12-30 17:07:18)

chore(deps): 🤖 bump php-parser from 3.1.5 to 3.2.1
## Context
This PR bumps php-parser dependency from 3.1.5 to 3.2.1

- added test for php keyword after null safe lookup fixed at https://github.com/glayzzle/php-parser/releases/tag/3.2.0

shufo: Seems codecov step in GitHub action failed due to Rate limit but local test was passed.

```bash
[2024-12-30T17:07:51.826Z] ['error'] There was an error running the uploader: Error uploading to [https://codecov.io:](https://codecov.io/) Error: There was an error fetching the storage URL during POST: 429 - {"message":"Rate limit reached. Please upload with the Codecov repository upload token to resolve issue. Expected time to availability: 131s."}
```

```
$ yarn run test
yarn run v1.22.22
$ yarn test:node && yarn test:standalone
$ jest
 PASS   test-node  tests/nullsafepropertylookup/jsfmt.spec.mjs
 PASS   test-node  tests/bin/jsfmt.spec.mjs
 PASS   test-node  tests/insert-pragma/jsfmt.spec.mjs
 PASS   test-node  tests/array/jsfmt.spec.mjs
 PASS   test-node  tests/member_chain/jsfmt.spec.mjs
 PASS   test-node  tests/nowdoc/jsfmt.spec.mjs
 PASS   test-node  tests/encapsed/jsfmt.spec.mjs
 PASS   test-node  tests/declare/jsfmt.spec.mjs
 PASS   test-node  tests/class/jsfmt.spec.mjs
 PASS   test-node  tests/preserve_line/jsfmt.spec.mjs
 PASS   test-node  tests/require-pragma/jsfmt.spec.mjs
 PASS   test-node  tests/newline/jsfmt.spec.mjs
 PASS   test-node  tests/assign/jsfmt.spec.mjs
 PASS   test-node  tests/list/jsfmt.spec.mjs
 PASS   test-node  tests/case/jsfmt.spec.mjs
 PASS   test-node  tests/return/jsfmt.spec.mjs
 PASS   test-node  tests/staticlookup/jsfmt.spec.mjs
 PASS   test-node  tests/brace-style/jsfmt.spec.mjs
 PASS   test-node  tests/retif/jsfmt.spec.mjs
 PASS   test-node  tests/namespace/jsfmt.spec.mjs
 PASS   test-node  tests/inline/jsfmt.spec.mjs
 PASS   test-node  tests/functions/jsfmt.spec.mjs
 PASS   test-node  tests/new/jsfmt.spec.mjs
 PASS   test-node  tests/markdown/jsfmt.spec.mjs
 PASS   test-node  tests/program/jsfmt.spec.mjs
 PASS   test-node  tests/identifier-and-reference/jsfmt.spec.mjs
 PASS   test-node  tests/parameter/jsfmt.spec.mjs
 PASS   test-node  tests/variable/jsfmt.spec.mjs
 PASS   test-node  tests/call/jsfmt.spec.mjs
 PASS   test-node  tests/cast/jsfmt.spec.mjs
 PASS   test-node  tests/magic/jsfmt.spec.mjs
 PASS   test-node  tests/match/jsfmt.spec.mjs
 PASS   test-node  tests/print/jsfmt.spec.mjs
 PASS   test-node  tests/classconstant/jsfmt.spec.mjs
 PASS   test-node  tests/switch/jsfmt.spec.mjs
 PASS   test-node  tests/propertylookup/jsfmt.spec.mjs
 PASS   test-node  tests/number/jsfmt.spec.mjs
 PASS   test-node  tests/string/jsfmt.spec.mjs
 PASS   test-node  tests/echo/jsfmt.spec.mjs
 PASS   test-node  tests/static/jsfmt.spec.mjs
 PASS   test-node  tests/if/jsfmt.spec.mjs
 PASS   test-node  tests/closure/jsfmt.spec.mjs
 PASS   test-node  tests/kitchen_sink/jsfmt.spec.mjs
 PASS   test-node  tests/offsetlookup/jsfmt.spec.mjs
 PASS   test-node  tests/for/jsfmt.spec.mjs
 PASS   test-node  tests/yield/jsfmt.spec.mjs
 PASS   test-node  tests/traits/jsfmt.spec.mjs
 PASS   test-node  tests/attributes/jsfmt.spec.mjs
 PASS   test-node  tests/trailing_comma_func/jsfmt.spec.mjs
 PASS   test-node  tests/single-quote-api/jsfmt.spec.mjs
 PASS   test-node  tests/errors/jsfmt.spec.mjs
 PASS   test-node  tests/isset/jsfmt.spec.mjs
 PASS   test-node  tests/trailing_commas/jsfmt.spec.mjs
 PASS   test-node  tests/halt/jsfmt.spec.mjs
 PASS   test-node  tests/trailing_whitespace/jsfmt.spec.mjs
 PASS   test-node  tests/variadic/jsfmt.spec.mjs
 PASS   test-node  tests/ignore/jsfmt.spec.mjs
 PASS   test-node  tests/foreach/jsfmt.spec.mjs
 PASS   test-node  tests/syntax-error/jsfmt.spec.mjs
 PASS   test-node  tests/enum/jsfmt.spec.mjs
 PASS   test-node  tests/eval/jsfmt.spec.mjs
 PASS   test-node  tests/property/jsfmt.spec.mjs
 PASS   test-node  tests/silent/jsfmt.spec.mjs
 PASS   test-node  tests/sys/jsfmt.spec.mjs
 PASS   test-node  tests/assignref/jsfmt.spec.mjs
 PASS   test-node  tests/use/jsfmt.spec.mjs
 PASS   test-node  tests/shebang/jsfmt.spec.mjs
 PASS   test-node  tests/include/jsfmt.spec.mjs
 PASS   test-node  tests/method/jsfmt.spec.mjs
 PASS   test-node  tests/interface/jsfmt.spec.mjs
 PASS   test-node  tests/propertystatement/jsfmt.spec.mjs
 PASS   test-node  tests/namedarguments/jsfmt.spec.mjs
 PASS   test-node  tests/empty/jsfmt.spec.mjs
 PASS   test-node  tests/break/jsfmt.spec.mjs
 PASS   test-node  tests/attributes-trail-comma/jsfmt.spec.mjs
 PASS   test-node  tests/uniontypes/jsfmt.spec.mjs
 PASS   test-node  tests/traituse/jsfmt.spec.mjs
 PASS   test-node  tests/extensions/jsfmt.spec.mjs
 PASS   test-node  tests/boolean/jsfmt.spec.mjs
 PASS   test-node  tests/string-single-quote/jsfmt.spec.mjs
 PASS   test-node  tests/continue/jsfmt.spec.mjs
 PASS   test-node  tests/formatting/jsfmt.spec.mjs
 PASS   test-node  tests/while/jsfmt.spec.mjs
 PASS   test-node  tests/constant/jsfmt.spec.mjs
 PASS   test-node  tests/goto/jsfmt.spec.mjs
 PASS   test-node  tests/traitalias/jsfmt.spec.mjs
 PASS   test-node  tests/do/jsfmt.spec.mjs
 PASS   test-node  tests/exit/jsfmt.spec.mjs
 PASS   test-node  tests/clone/jsfmt.spec.mjs
 PASS   test-node  tests/global/jsfmt.spec.mjs
 PASS   test-node  tests/intersection-types/jsfmt.spec.mjs
 PASS   test-node  tests/block/jsfmt.spec.mjs
 PASS   test-node  tests/string-double-quote/jsfmt.spec.mjs
 PASS   test-node  tests/unset/jsfmt.spec.mjs
 PASS   test-node  tests/statement/jsfmt.spec.mjs
 PASS   test-node  tests/arrowfunc/jsfmt.spec.mjs
 PASS   test-node  tests/parens/jsfmt.spec.mjs
 PASS   test-node  tests/comments/jsfmt.spec.mjs

Test Suites: 98 passed, 98 total
Tests:       544 passed, 544 total
Snapshots:   542 passed, 542 total
Time:        1.238 s
Ran all test suites.
$ yarn run build && cross-env RUN_STANDALONE_TESTS=true yarn jest
$ rollup --config build/rollup.config.mjs

/home/shuhei/develop/plugin-php2/src/index.mjs → standalone.js...
Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
created standalone.js in 2.9s
$ /home/shuhei/develop/plugin-php2/node_modules/.bin/jest
 PASS   test-standalone  tests/list/jsfmt.spec.mjs
 PASS   test-standalone  tests/newline/jsfmt.spec.mjs
 PASS   test-standalone  tests/preserve_line/jsfmt.spec.mjs
 PASS   test-standalone  tests/brace-style/jsfmt.spec.mjs
 PASS   test-standalone  tests/member_chain/jsfmt.spec.mjs
 PASS   test-standalone  tests/array/jsfmt.spec.mjs
 PASS   test-standalone  tests/nowdoc/jsfmt.spec.mjs
 PASS   test-standalone  tests/declare/jsfmt.spec.mjs
 PASS   test-standalone  tests/new/jsfmt.spec.mjs
 PASS   test-standalone  tests/encapsed/jsfmt.spec.mjs
 PASS   test-standalone  tests/markdown/jsfmt.spec.mjs
 PASS   test-standalone  tests/call/jsfmt.spec.mjs
 PASS   test-standalone  tests/bin/jsfmt.spec.mjs
 PASS   test-standalone  tests/retif/jsfmt.spec.mjs
 PASS   test-standalone  tests/insert-pragma/jsfmt.spec.mjs
 PASS   test-standalone  tests/require-pragma/jsfmt.spec.mjs
 PASS   test-standalone  tests/staticlookup/jsfmt.spec.mjs
 PASS   test-standalone  tests/class/jsfmt.spec.mjs
 PASS   test-standalone  tests/nullsafepropertylookup/jsfmt.spec.mjs
 PASS   test-standalone  tests/echo/jsfmt.spec.mjs
 PASS   test-standalone  tests/identifier-and-reference/jsfmt.spec.mjs
 PASS   test-standalone  tests/return/jsfmt.spec.mjs
 PASS   test-standalone  tests/variable/jsfmt.spec.mjs
 PASS   test-standalone  tests/functions/jsfmt.spec.mjs
 PASS   test-standalone  tests/parameter/jsfmt.spec.mjs
 PASS   test-standalone  tests/namespace/jsfmt.spec.mjs
 PASS   test-standalone  tests/match/jsfmt.spec.mjs
 PASS   test-standalone  tests/string/jsfmt.spec.mjs
 PASS   test-standalone  tests/closure/jsfmt.spec.mjs
 PASS   test-standalone  tests/assign/jsfmt.spec.mjs
 PASS   test-standalone  tests/print/jsfmt.spec.mjs
 PASS   test-standalone  tests/cast/jsfmt.spec.mjs
 PASS   test-standalone  tests/syntax-error/jsfmt.spec.mjs
 PASS   test-standalone  tests/propertylookup/jsfmt.spec.mjs
 PASS   test-standalone  tests/case/jsfmt.spec.mjs
 PASS   test-standalone  tests/property/jsfmt.spec.mjs
 PASS   test-standalone  tests/number/jsfmt.spec.mjs
 PASS   test-standalone  tests/inline/jsfmt.spec.mjs
 PASS   test-standalone  tests/clone/jsfmt.spec.mjs
 PASS   test-standalone  tests/trailing_comma_func/jsfmt.spec.mjs
 PASS   test-standalone  tests/do/jsfmt.spec.mjs
 PASS   test-standalone  tests/attributes/jsfmt.spec.mjs
 PASS   test-standalone  tests/ignore/jsfmt.spec.mjs
 PASS   test-standalone  tests/variadic/jsfmt.spec.mjs
 PASS   test-standalone  tests/classconstant/jsfmt.spec.mjs
 PASS   test-standalone  tests/switch/jsfmt.spec.mjs
 PASS   test-standalone  tests/unset/jsfmt.spec.mjs
 PASS   test-standalone  tests/isset/jsfmt.spec.mjs
 PASS   test-standalone  tests/if/jsfmt.spec.mjs
 PASS   test-standalone  tests/eval/jsfmt.spec.mjs
 PASS   test-standalone  tests/halt/jsfmt.spec.mjs
 PASS   test-standalone  tests/include/jsfmt.spec.mjs
 PASS   test-standalone  tests/yield/jsfmt.spec.mjs
 PASS   test-standalone  tests/trailing_commas/jsfmt.spec.mjs
 PASS   test-standalone  tests/single-quote-api/jsfmt.spec.mjs
 PASS   test-standalone  tests/trailing_whitespace/jsfmt.spec.mjs
 PASS   test-standalone  tests/exit/jsfmt.spec.mjs
 PASS   test-standalone  tests/static/jsfmt.spec.mjs
 PASS   test-standalone  tests/use/jsfmt.spec.mjs
 PASS   test-standalone  tests/statement/jsfmt.spec.mjs
 PASS   test-standalone  tests/program/jsfmt.spec.mjs
 PASS   test-standalone  tests/propertystatement/jsfmt.spec.mjs
 PASS   test-standalone  tests/offsetlookup/jsfmt.spec.mjs
 PASS   test-standalone  tests/namedarguments/jsfmt.spec.mjs
 PASS   test-standalone  tests/errors/jsfmt.spec.mjs
 PASS   test-standalone  tests/enum/jsfmt.spec.mjs
 PASS   test-standalone  tests/constant/jsfmt.spec.mjs
 PASS   test-standalone  tests/sys/jsfmt.spec.mjs
 PASS   test-standalone  tests/for/jsfmt.spec.mjs
 PASS   test-standalone  tests/kitchen_sink/jsfmt.spec.mjs
 PASS   test-standalone  tests/assignref/jsfmt.spec.mjs
 PASS   test-standalone  tests/shebang/jsfmt.spec.mjs
 PASS   test-standalone  tests/silent/jsfmt.spec.mjs
 PASS   test-standalone  tests/foreach/jsfmt.spec.mjs
 PASS   test-standalone  tests/traits/jsfmt.spec.mjs
 PASS   test-standalone  tests/continue/jsfmt.spec.mjs
 PASS   test-standalone  tests/empty/jsfmt.spec.mjs
 PASS   test-standalone  tests/interface/jsfmt.spec.mjs
 PASS   test-standalone  tests/attributes-trail-comma/jsfmt.spec.mjs
 PASS   test-standalone  tests/arrowfunc/jsfmt.spec.mjs
 PASS   test-standalone  tests/uniontypes/jsfmt.spec.mjs
 PASS   test-standalone  tests/break/jsfmt.spec.mjs
 PASS   test-standalone  tests/string-single-quote/jsfmt.spec.mjs
 PASS   test-standalone  tests/extensions/jsfmt.spec.mjs
 PASS   test-standalone  tests/magic/jsfmt.spec.mjs
 PASS   test-standalone  tests/boolean/jsfmt.spec.mjs
 PASS   test-standalone  tests/block/jsfmt.spec.mjs
 PASS   test-standalone  tests/formatting/jsfmt.spec.mjs
 PASS   test-standalone  tests/method/jsfmt.spec.mjs
 PASS   test-standalone  tests/while/jsfmt.spec.mjs
 PASS   test-standalone  tests/traituse/jsfmt.spec.mjs
 PASS   test-standalone  tests/intersection-types/jsfmt.spec.mjs
 PASS   test-standalone  tests/traitalias/jsfmt.spec.mjs
 PASS   test-standalone  tests/goto/jsfmt.spec.mjs
 PASS   test-standalone  tests/global/jsfmt.spec.mjs
 PASS   test-standalone  tests/string-double-quote/jsfmt.spec.mjs
 PASS   test-standalone  tests/parens/jsfmt.spec.mjs
 PASS   test-standalone  tests/comments/jsfmt.spec.mjs

Test Suites: 98 passed, 98 total
Tests:       544 passed, 544 total
Snapshots:   542 passed, 542 total
Time:        1.319 s
Ran all test suites.
Done in 7.03s.

```
czosel: @shufo indeed, restarting some pipelines turned them green. LGTM, thanks for contributing!

Patch:
diff --git a/yarn.lock b/yarn.lock
index 0ea9d0b..d72c9f3 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5008,9 +5008,9 @@ path-type@^4.0.0:
   integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
 
 php-parser@^3.1.5:
-  version "3.1.5"
-  resolved "https://registry.yarnpkg.com/php-parser/-/php-parser-3.1.5.tgz#84500e5b5c6a0907e32c38b931bb4e7d3f275026"
-  integrity sha512-jEY2DcbgCm5aclzBdfW86GM6VEIWcSlhTBSHN1qhJguVePlYe28GhwS0yoeLYXpM2K8y6wzLwrbq814n2PHSoQ==
+  version "3.2.1"
+  resolved "https://registry.yarnpkg.com/php-parser/-/php-parser-3.2.1.tgz#960916dc03e4979a59435f9dd9eb03f2e86d8126"
+  integrity sha512-WT5AMqe39ZdqAxp9Yp7uR6e3clBWlT1dxHHs49GmnDx2d+975NEiLSVy2tRGLdSC9tgdQOLiN1Yz54g1d2cZDQ==
 
 picocolors@^1.0.0:
   version "1.0.0"


Test patch:
diff --git a/tests/nullsafepropertylookup/__snapshots__/jsfmt.spec.mjs.snap b/tests/nullsafepropertylookup/__snapshots__/jsfmt.spec.mjs.snap
index 277db0f..2d90ad7 100644
--- a/tests/nullsafepropertylookup/__snapshots__/jsfmt.spec.mjs.snap
+++ b/tests/nullsafepropertylookup/__snapshots__/jsfmt.spec.mjs.snap
@@ -76,3 +76,31 @@ $obj->aaaaaaaaaaaaaaaaaaaaaaaa()
 
 ================================================================================
 `;
+
+exports[`reserved-keyword.php 1`] = `
+====================================options=====================================
+parsers: ["php"]
+phpVersion: "8.0"
+printWidth: 80
+                                                                                | printWidth
+=====================================input======================================
+<?php
+
+// keyword: abstract
+echo $post->metaData?->abstract;
+
+// keyword: class
+echo $record->learner->currentEnrollment?->class->grade->code;
+
+
+=====================================output=====================================
+<?php
+
+// keyword: abstract
+echo $post->metaData?->abstract;
+
+// keyword: class
+echo $record->learner->currentEnrollment?->class->grade->code;
+
+================================================================================
+`;
diff --git a/tests/nullsafepropertylookup/reserved-keyword.php b/tests/nullsafepropertylookup/reserved-keyword.php
new file mode 100644
index 0000000..a12045b
--- /dev/null
+++ b/tests/nullsafepropertylookup/reserved-keyword.php
@@ -0,0 +1,8 @@
+<?php
+
+// keyword: abstract
+echo $post->metaData?->abstract;
+
+// keyword: class
+echo $record->learner->currentEnrollment?->class->grade->code;
+