Skip to content

Commit 29f3706

Browse files
cseufertczosel
andauthored
Addes support for final class const (#2186)
* Addes support for final class const Fixes #2183 * Update snapshots * chore: update parser to 3.1.5 --------- Co-authored-by: Christian Zosel <christian@zosel.ch>
1 parent 39c4d52 commit 29f3706

5 files changed

Lines changed: 15 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dependencies": {
1414
"linguist-languages": "^7.21.0",
1515
"mem": "^8.0.0",
16-
"php-parser": "^3.1.3"
16+
"php-parser": "^3.1.5"
1717
},
1818
"devDependencies": {
1919
"@babel/preset-env": "^7.19.4",

src/printer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,6 +2377,7 @@ function printNode(path, options, print) {
23772377

23782378
return group([
23792379
...attrs,
2380+
node.final ? "final " : "",
23802381
node.visibility ? [node.visibility, " "] : "",
23812382
"const",
23822383
firstVariable ? [" ", firstVariable] : "",

tests/class/__snapshots__/jsfmt.spec.js.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,8 @@ readonly class ReadOnlyCls {
940940
public string $myValue;
941941
}
942942
943+
class FinalCost { final public const FOO = 'foo'; }
944+
943945
=====================================output=====================================
944946
<?php
945947
@@ -1466,5 +1468,10 @@ readonly class ReadOnlyCls
14661468
public string $myValue;
14671469
}
14681470
1471+
class FinalCost
1472+
{
1473+
final public const FOO = "foo";
1474+
}
1475+
14691476
================================================================================
14701477
`;

tests/class/class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,5 @@ public function __construct( public int $a, private float $b, protected stri
304304
readonly class ReadOnlyCls {
305305
public string $myValue;
306306
}
307+
308+
class FinalCost { final public const FOO = 'foo'; }

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4276,10 +4276,10 @@ path-type@^4.0.0:
42764276
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
42774277
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
42784278

4279-
php-parser@^3.1.3:
4280-
version "3.1.3"
4281-
resolved "https://registry.yarnpkg.com/php-parser/-/php-parser-3.1.3.tgz#7a2aac2eb88a5a6c5aa75e6170a256bee5a30e6b"
4282-
integrity sha512-hPvBmnRYPqWEtMfIFOlyjQv1q75UUtxt4U+YscKIQViGmEE2Xa4BuS1B1/cZdjy7MVcwtnr0WkEsr915LgRKOw==
4279+
php-parser@^3.1.5:
4280+
version "3.1.5"
4281+
resolved "https://registry.yarnpkg.com/php-parser/-/php-parser-3.1.5.tgz#84500e5b5c6a0907e32c38b931bb4e7d3f275026"
4282+
integrity sha512-jEY2DcbgCm5aclzBdfW86GM6VEIWcSlhTBSHN1qhJguVePlYe28GhwS0yoeLYXpM2K8y6wzLwrbq814n2PHSoQ==
42834283

42844284
picocolors@^1.0.0:
42854285
version "1.0.0"

0 commit comments

Comments
 (0)