File tree Expand file tree Collapse file tree 5 files changed +26
-1
lines changed Expand file tree Collapse file tree 5 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -449,6 +449,26 @@ function fileowner(string $filename): int
449449}
450450
451451
452+ /**
453+ * Gets the size for the given file.
454+ *
455+ * @param string $filename Path to the file.
456+ * @return int Returns the size of the file in bytes, or FALSE (and generates an error
457+ * of level E_WARNING) in case of an error.
458+ * @throws FilesystemException
459+ *
460+ */
461+ function filesize (string $ filename ): int
462+ {
463+ error_clear_last ();
464+ $ result = \filesize ($ filename );
465+ if ($ result === false ) {
466+ throw FilesystemException::createFromPhpError ();
467+ }
468+ return $ result ;
469+ }
470+
471+
452472/**
453473 * flock allows you to perform a simple reader/writer
454474 * model which can be used on virtually every platform (including most Unix
Original file line number Diff line number Diff line change 145145 'fileinode ' ,
146146 'filemtime ' ,
147147 'fileowner ' ,
148+ 'filesize ' ,
148149 'flock ' ,
149150 'fopen ' ,
150151 'fputcsv ' ,
Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ public function detectFalsyFunction(): bool
4848 if (preg_match ('/&date.datetime.return.modifiedobjectorfalseforfailure;/m ' , $ file )) {
4949 return true ;
5050 }
51+ if (preg_match ('/ or &false; \\(and generates an error/m ' , $ file )) {
52+ return true ;
53+ }
5154
5255 return false ;
5356 }
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public function testDetectFalsyFunction() {
1111 $ implode = new DocPage (__DIR__ . '/../doc/doc-en/en/reference/strings/functions/implode.xml ' );
1212 $ getCwd = new DocPage (__DIR__ . '/../doc/doc-en/en/reference/dir/functions/getcwd.xml ' );
1313 $ setTime = new DocPage (__DIR__ . '/../doc/doc-en/en/reference/datetime/datetime/settime.xml ' );
14- $ filesize = new DocPage (__DIR__ . '/../doc/doc-en/en/reference/datetime/ filesystem/filesize.xml ' );
14+ $ filesize = new DocPage (__DIR__ . '/../doc/doc-en/en/reference/filesystem/functions /filesize.xml ' );
1515
1616 $ this ->assertTrue ($ pregMatch ->detectFalsyFunction ());
1717 $ this ->assertFalse ($ implode ->detectFalsyFunction ());
Original file line number Diff line number Diff line change @@ -146,6 +146,7 @@ services:
146146 fileinode : ' Safe\fileinode'
147147 filemtime : ' Safe\filemtime'
148148 fileowner : ' Safe\fileowner'
149+ filesize : ' Safe\filesize'
149150 flock : ' Safe\flock'
150151 fopen : ' Safe\fopen'
151152 fputcsv : ' Safe\fputcsv'
You can’t perform that action at this time.
0 commit comments