Closed
Description
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.