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
2 changes: 1 addition & 1 deletion .github/workflows/blink_parity_laravel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Compare the two trees
run: |
# ratchet gate: fail once the differing share crosses this; lower it as parity improves
MAX_DIFF_PERCENT=7.3
MAX_DIFF_PERCENT=4
total=0
differ=0
differing_files=""
Expand Down
5 changes: 3 additions & 2 deletions blink/internal/fixer/rules/array_notation.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (
)

// convertLongArray rewrites a long "name(...)" construct to "[...]", where name
// is "array" or "list". Method/constant uses (after -> ?-> ::) are skipped.
// is "array" or "list". Method/constant uses (after -> ?-> ::) and a method
// declared with that name (after "function") are skipped.
func convertLongArray(s *tokens.Stream, name string) bool {
changed := false
for i := 0; i < s.Len(); i++ {
Expand All @@ -23,7 +24,7 @@ func convertLongArray(s *tokens.Stream, name string) bool {
}
if prev, ok := prevSignificant(s, i); ok {
switch prev.Value {
case "->", "?->", "::":
case "->", "?->", "::", "function":
continue
}
}
Expand Down
6 changes: 3 additions & 3 deletions blink/internal/fixer/rules/percs.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func isStaticRef(v string) bool {

// PHP-CS-Fixer: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/src/Fixer/Basic/SingleLineEmptyBodyFixer.php
//
// SingleLineEmptyBody collapses an empty class or function body to "{}" on the
// declaration line ("function f()\n{\n}" -> "function f() {}").
// SingleLineEmptyBody collapses an empty class, function or closure body to "{}"
// on the declaration line ("function f()\n{\n}" -> "function f() {}").
type SingleLineEmptyBody struct{}

func (SingleLineEmptyBody) Name() string {
Expand All @@ -158,7 +158,7 @@ func (SingleLineEmptyBody) Fix(s *tokens.Stream) bool {
continue
}
switch kind, _ := classifyBrace(s, i); kind {
case braceClassLike, braceFunctionDecl:
case braceClassLike, braceFunctionDecl, braceClosure:
default:
continue
}
Expand Down
7 changes: 6 additions & 1 deletion blink/internal/fixer/rules/phpdoc_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ func (NoEmptyPhpdoc) Fix(s *tokens.Stream) bool {
changed = true
// Drop one newline of the following whitespace, like removing a blank line.
if i < s.Len() && s.At(i).Kind == token.Whitespace && strings.HasPrefix(s.At(i).Value, "\n") {
if v := s.At(i).Value[1:]; v == "" {
// The preceding whitespace already carries the newline + indent for the
// next line, so remove the docblock's trailing whitespace outright;
// de-newlining it would leave a dangling indent that doubles up.
if i > 0 && s.At(i-1).Kind == token.Whitespace && hasNewline(s.At(i-1).Value) {
s.RemoveAt(i)
} else if v := s.At(i).Value[1:]; v == "" {
s.RemoveAt(i)
} else {
s.SetValue(i, v)
Expand Down
Loading