Skip to content

Reference-based parameters like preg_match() scoping rules in undefined variables #1

@chuck-sys

Description

@chuck-sys
preg_match('/f/', 'f', $matches);

Will result in $matches being reported as an undefined variable, even though it is technically defined by preg_match() in the function call. Though I'm not happy about it, it is standard. Our options are currently:

  • Make specific exceptions for specific argument placements on specific functions, essentially hard-coding these types of functions, which definitely won't scale well but will have the benefit of actually working
  • Wait for integration with typing information via a more thorough analysis that goes through more files, including the phpstorm stubs, and have an exception where parameters that are passed by reference are defined by the function instead

I like the second one more.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions