Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linter: loading only php files from embedded stubs #1197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
22 changes: 18 additions & 4 deletions src/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,16 +453,30 @@ func LoadEmbeddedStubs(l *linter.Linter, filenames []string) error {
}

func loadEmbeddedStubs(l *linter.Linter) error {
var filenames []string
var stubsFilenames []string
// NOVERIFYDEBUG_LOAD_STUBS is used in golden tests to specify
// the test dependencies that need to be loaded.
if list := os.Getenv("NOVERIFYDEBUG_LOAD_STUBS"); list != "" {
filenames = strings.Split(list, ",")
stubsFilenames = strings.Split(list, ",")
} else {
filenames = stubs.AssetNames()
stubsFilenames = stubs.AssetNames()
}
if len(filenames) == 0 {

if len(stubsFilenames) == 0 {
return fmt.Errorf("empty file list")
}

extensions := l.Config().PhpExtensions
extensions = append(extensions, "php")

var filenames []string
for _, filename := range stubsFilenames {
for _, extension := range extensions {
if strings.HasSuffix(filename, extension) {
filenames = append(filenames, filename)
}
}
}

return LoadEmbeddedStubs(l, filenames)
}