diff --git a/generated/filesystem.php b/generated/filesystem.php index 28b4a1c6..80ad5564 100644 --- a/generated/filesystem.php +++ b/generated/filesystem.php @@ -449,6 +449,26 @@ function fileowner(string $filename): int } +/** + * Gets the size for the given file. + * + * @param string $filename Path to the file. + * @return int Returns the size of the file in bytes, or FALSE (and generates an error + * of level E_WARNING) in case of an error. + * @throws FilesystemException + * + */ +function filesize(string $filename): int +{ + error_clear_last(); + $result = \filesize($filename); + if ($result === false) { + throw FilesystemException::createFromPhpError(); + } + return $result; +} + + /** * flock allows you to perform a simple reader/writer * model which can be used on virtually every platform (including most Unix diff --git a/generated/functionsList.php b/generated/functionsList.php index 71b2fdd0..2c41fd46 100644 --- a/generated/functionsList.php +++ b/generated/functionsList.php @@ -145,6 +145,7 @@ 'fileinode', 'filemtime', 'fileowner', + 'filesize', 'flock', 'fopen', 'fputcsv', diff --git a/generator/src/DocPage.php b/generator/src/DocPage.php index 3be73c23..ddcc1a85 100644 --- a/generator/src/DocPage.php +++ b/generator/src/DocPage.php @@ -48,6 +48,9 @@ public function detectFalsyFunction(): bool if (preg_match('/&date.datetime.return.modifiedobjectorfalseforfailure;/m', $file)) { return true; } + if (preg_match('/ or &false; \\(and generates an error/m', $file)) { + return true; + } return false; } diff --git a/generator/tests/DocPageTest.php b/generator/tests/DocPageTest.php index c9b483a1..e7635399 100644 --- a/generator/tests/DocPageTest.php +++ b/generator/tests/DocPageTest.php @@ -11,7 +11,7 @@ public function testDetectFalsyFunction() { $implode = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/strings/functions/implode.xml'); $getCwd = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/dir/functions/getcwd.xml'); $setTime = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/datetime/datetime/settime.xml'); - $filesize = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/datetime/filesystem/filesize.xml'); + $filesize = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/filesystem/functions/filesize.xml'); $this->assertTrue($pregMatch->detectFalsyFunction()); $this->assertFalse($implode->detectFalsyFunction()); diff --git a/rector-migrate.yml b/rector-migrate.yml index a5cd796c..890b66d1 100644 --- a/rector-migrate.yml +++ b/rector-migrate.yml @@ -146,6 +146,7 @@ services: fileinode: 'Safe\fileinode' filemtime: 'Safe\filemtime' fileowner: 'Safe\fileowner' + filesize: 'Safe\filesize' flock: 'Safe\flock' fopen: 'Safe\fopen' fputcsv: 'Safe\fputcsv'