Skip to content

Commit fbd5b1d

Browse files
authored
Merge pull request #94 from magento-commerce/imported-loginesta-magento-coding-standard-308
[Imported] AC-1167 Add all filesystem PHP native functions covered by Filesystem\DriverInterface to DiscouragedFunctionSniff
2 parents 43b69ef + 1b9f386 commit fbd5b1d

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

Magento2/Sniffs/Functions/DiscouragedFunctionSniff.php

+9
Original file line numberDiff line numberDiff line change
@@ -229,5 +229,14 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
229229
'^strval$' => '(string) construction',
230230
'^htmlspecialchars$' => '\Magento\Framework\Escaper->escapeHtml',
231231
'^getimagesize$' => 'getimagesizefromstring',
232+
'^file_exists$' => 'Magento\Framework\Filesystem\DriverInterface::isExists()',
233+
'^file_get_contents$' => 'Magento\Framework\Filesystem\DriverInterface::fileGetContents()',
234+
'^file_put_contents$' => 'Magento\Framework\Filesystem\DriverInterface::filePutContents()',
235+
'^fgetcsv$' => 'Magento\Framework\Filesystem\DriverInterface::fileGetCsv()',
236+
'^fputcsv$' => 'Magento\Framework\Filesystem\DriverInterface::filePutCsv()',
237+
'^ftell$' => 'Magento\Framework\Filesystem\DriverInterface::fileTell()',
238+
'^fseek$' => 'Magento\Framework\Filesystem\DriverInterface::fileSeek()',
239+
'^feof$' => 'Magento\Framework\Filesystem\DriverInterface::endOfFile()',
240+
'^flock$' => 'Magento\Framework\Filesystem\DriverInterface::fileLock()',
232241
];
233242
}

Magento2/Tests/Functions/DiscouragedFunctionUnitTest.inc

+18
Original file line numberDiff line numberDiff line change
@@ -464,3 +464,21 @@ $str = chop($text, 'ttt');
464464
md5($text);
465465

466466
htmlspecialchars('text');
467+
468+
file_exists('./');
469+
470+
file_get_contents('file.txt');
471+
472+
file_put_contents($file, 'test');
473+
474+
fgetcsv($fp,'r');
475+
476+
fputcsv($fp, $fields);
477+
478+
ftell($file);
479+
480+
fseek($file, 0);
481+
482+
feof($fp);
483+
484+
flock($fp, LOCK_EX);

Magento2/Tests/Functions/DiscouragedFunctionUnitTest.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,16 @@ public function getWarningList()
246246
458 => 1,
247247
460 => 1,
248248
462 => 1,
249-
466 => 1
249+
466 => 1,
250+
468 => 1,
251+
470 => 1,
252+
472 => 1,
253+
474 => 1,
254+
476 => 1,
255+
478 => 1,
256+
480 => 1,
257+
482 => 1,
258+
484 => 1
250259
];
251260
}
252261
}

0 commit comments

Comments
 (0)