php8.1: added readonly modifier (#6)

This commit is contained in:
Makhnev Petr
2021-07-31 18:00:21 +03:00
committed by GitHub
parent 4d0bfa25aa
commit 8c35b0aef1
18 changed files with 7662 additions and 7053 deletions

View File

@@ -147,7 +147,7 @@ func (p *printer) Nullable(n *ast.Nullable) {
func (p *printer) Parameter(n *ast.Parameter) {
p.printList(n.AttrGroups)
p.printNode(n.Visibility)
p.printList(n.Modifiers)
p.printNode(n.Type)
p.printToken(n.AmpersandTkn, nil)
p.printToken(n.VariadicTkn, nil)

View File

@@ -0,0 +1,25 @@
package printer_test
import (
"testing"
"github.com/VKCOM/php-parser/internal/tester"
)
func TestParseAndPrintReadonlyModifierPHP81(t *testing.T) {
tester.NewParserPrintTestSuite(t).UsePHP8().Run(`<?php
class Foo {
readonly string $a;
private readonly string $a;
private string $a;
private readonly $a = 100;
public function __construct(
readonly string $a,
private readonly string $a,
private string $a,
private readonly $a = 100,
) {}
}
`)
}