note 126780 added to filesystemiterator.construct

From: Date: Wed, 19 Jan 2022 17:15:11 +0000
Subject: note 126780 added to filesystemiterator.construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-217518@lists.php.net to get a copy of this message
I'm not sure why $fileInfo in the following code sample is return type of DirectoryIterator | Mixed and not just DirectoryIterator: <?php foreach(new DirectoryIterator('.') as $fileinfo) { ... } ?> However, this causes my IDE not flag syntax errors (ie $fileInfo->getCime() (miss spelled method name)) via built in inspections due to the fact that mixed is a possible type of $fileInfo. In what scenario would $fileInfo be mixed and not DirectoryIterator? ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.135 (proxied: 2601:248:4000:1570::3) ---- Manual Page -- https://php.net/manual/en/filesystemiterator.construct.php Edit -- https://main.php.net/note/edit/126780 Del: integrated -- https://main.php.net/note/delete/126780/integrated Del: useless -- https://main.php.net/note/delete/126780/useless Del: bad code -- https://main.php.net/note/delete/126780/bad+code Del: spam -- https://main.php.net/note/delete/126780/spam Del: non-english -- https://main.php.net/note/delete/126780/non-english Del: in docs -- https://main.php.net/note/delete/126780/in+docs Del: other reasons-- https://main.php.net/note/delete/126780 Reject -- https://main.php.net/note/reject/126780 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217518) next »