Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions blink/internal/fixer/rules/gen3_class_sep.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ func classSepMemberType(s *tokens.Stream, m int) int {
return sepMethod
case "case":
return sepCase
default:
return sepUnknown
}
// otherwise a keyword type ("array", "int", "string", ...) opens a typed
// property; fall through to the variable scan below
}
for x := k; x <= end; x++ {
t := s.At(x)
Expand Down
18 changes: 18 additions & 0 deletions blink/internal/fixer/rules/gen3_class_sep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ func TestGen3ClassSepMethods(t *testing.T) {
}
}

func TestGen3ClassSepKeywordTypedProperty(t *testing.T) {
// a property typed with a keyword type ("array") is still a property and must
// be separated from the previous member by a blank line
src := "<?php class A {\n" +
" private int $a;\n" +
" private array $b = [];\n" +
"}"
want := "<?php class A {\n" +
" private int $a;\n" +
"\n" +
" private array $b = [];\n" +
"}"
got, changed := apply(t, ClassAttributesSeparation{}, src)
if !changed || got != want {
t.Fatalf("changed=%v\n got: %q\nwant: %q", changed, got, want)
}
}

func TestGen3ClassSepPropertiesAndConsts(t *testing.T) {
src := "<?php class A {\n" +
" const X = 1;\n" +
Expand Down
Loading