Skip to content

[New Rule] No try block detected when processing system resources #21

Closed
@lenaorobei

Description

@lenaorobei

Rule

If a method uses system resources (such as files, sockets, streams, etc), the code MUST be wrapped with a try block and the corresponding finally block. In the finally sections, all resources SHOULD be properly released.

Reason

Source: Magento Technical Guidelines.

Implementation

  • Subscribe to T_STRING token.
  • Prepare the list of build in PHP functions that use resources or alternatively functions prefixes (stream_, socket_, etc)
  • Check if token content is in_array of system functions.
  • Raise a warning if no outer try statement detected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedNew rule is acceptednew ruleNew feature implementationon holdThe issue or PR is on hold.technical guidelinesThe rule is based on Magento Technical Guidelines

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions