Skip to content

Commit

Permalink
Addes support for final class const (#2186)
Browse files Browse the repository at this point in the history
* Addes support for final class const

Fixes #2183

* Update snapshots

* chore: update parser to 3.1.5

---------

Co-authored-by: Christian Zosel <[email protected]>
  • Loading branch information
cseufert and czosel authored Jun 11, 2023
1 parent 39c4d52 commit 29f3706
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"linguist-languages": "^7.21.0",
"mem": "^8.0.0",
"php-parser": "^3.1.3"
"php-parser": "^3.1.5"
},
"devDependencies": {
"@babel/preset-env": "^7.19.4",
Expand Down
1 change: 1 addition & 0 deletions src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2377,6 +2377,7 @@ function printNode(path, options, print) {

return group([
...attrs,
node.final ? "final " : "",
node.visibility ? [node.visibility, " "] : "",
"const",
firstVariable ? [" ", firstVariable] : "",
Expand Down
7 changes: 7 additions & 0 deletions tests/class/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,8 @@ readonly class ReadOnlyCls {
public string $myValue;
}
class FinalCost { final public const FOO = 'foo'; }
=====================================output=====================================
<?php
Expand Down Expand Up @@ -1466,5 +1468,10 @@ readonly class ReadOnlyCls
public string $myValue;
}
class FinalCost
{
final public const FOO = "foo";
}
================================================================================
`;
2 changes: 2 additions & 0 deletions tests/class/class.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,5 @@ public function __construct( public int $a, private float $b, protected stri
readonly class ReadOnlyCls {
public string $myValue;
}

class FinalCost { final public const FOO = 'foo'; }
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4276,10 +4276,10 @@ path-type@^4.0.0:
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==

php-parser@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/php-parser/-/php-parser-3.1.3.tgz#7a2aac2eb88a5a6c5aa75e6170a256bee5a30e6b"
integrity sha512-hPvBmnRYPqWEtMfIFOlyjQv1q75UUtxt4U+YscKIQViGmEE2Xa4BuS1B1/cZdjy7MVcwtnr0WkEsr915LgRKOw==
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==

picocolors@^1.0.0:
version "1.0.0"
Expand Down

0 comments on commit 29f3706

Please sign in to comment.