Skip to content

RestrictedFunctions sniff incorrectly captures class instantiations #469

@GaryJones

Description

@GaryJones

Bug Description

WordPressVIPMinimum.Functions.RestrictedFunctions sniff catches instantiation of classes that have the same name as the restricted functions.

Minimal Code Snippet

$foo = new Link();

This is reported (by the vip-go-ci bot) as:

Warning: File system operations only work on the /tmp/ and wp-content/uploads/ directories. To avoid unexpected results, please use helper functions like get_temp_dir() or wp_get_upload_dir() to get the proper directory path when using functions such as link(). For more details, please see: wpvip.com/documentation/vip-go/writing-files-on-vip-go
(WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_link).

...despite this not being a function call. I suspect that if classes matched other restricted function names, they too would get this false positive.

Environment

Use php -v and composer show to get versions.

Question Answer
PHP version 7
PHP_CodeSniffer version 3.5
VIPCS version 2.0.0

Tested Against master branch?

  • I have verified the issue still exists in the master branch of VIPCS.
  • I have verified the issue still exists in the develop branch of VIPCS.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions