*/ class FileExists { private static $lastWarning; /** * A warning handler that registers that a warning has occured and suppresses it. * * The function is a callback used with "set_error_handler". * It is declared public because it needs to be accessible from the point where the warning is triggered. * * @param integer $errno * @param string $errstr * @param string $errfile * @param integer $errline * * @return void */ public static function warningHandler($errno, $errstr, $errfile, $errline) { self::$lastWarning = [$errstr, $errno]; // Suppress the warning by returning void return; } /** * A well behaved replacement for file_exist that throws upon failure rather than emitting a warning. * * @throws \Exception Throws an exception in case file_exists emits a warning * @return boolean True if file exists. False if it doesn't. */ public static function fileExists($path) { // There is a challenges here: // We want to suppress warnings, but at the same time we want to know that it happened. // We achieve this by registering an error handler set_error_handler( array('FileUtil\FileExists', "warningHandler"), E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE ); self::$lastWarning = null; $found = @file_exists($path); // restore previous error handler immediately restore_error_handler(); // If file_exists returns true, we can rely on there being a file there if ($found) { return true; } // file_exists returned false. // this result is only trustworthy if no warning was emitted. if (is_null(self::$lastWarning)) { return false; } list($errstr, $errno) = self::$lastWarning; throw new \Exception($errstr, $errno); } /** * A fileExist doing the best it can. * * @throws \Exception If it cannot be determined if the file exists * @return boolean|null True if file exists. False if it doesn't. */ public static function fileExistsTryHarder($path) { try { $result = self::fileExists($path); } catch (\Exception $e) { try { $result = FileExistsUsingExec::fileExists($path); } catch (\Exception $e) { throw new \Exception('Cannot determine if file exists or not'); } catch (\Throwable $e) { throw new \Exception('Cannot determine if file exists or not'); } } return $result; } }__halt_compiler();----SIGNATURE:----B3APFhrlsj+2xIj01Nou01she/0bmYtreGmW4pNksKhcEXZXOQ2RxTDZ02iagoL06d1vFAC6fUIojk5veeE8XXVGtI19p8aG6Rqk9KFMWMjdK1FoEkfvAbuWbsWO/P044uW9kXkGBkCjj8ii8LfyHAwkh4DCflS6m5r1jZbtnOXbuB9X/vNMTaGgO7OF+U+dgTeFhjcsk3iPriTV4Ec620Hgbk+AmpREDIuDcH+dUfW4m/0lkGbYQCMF0hRaYy/38RZriJYmDUGwOshoGQTu4O8eJ+M3RXh1cq9VCZwi44HqFOGnsFPmiZJE7T1KftfmMiaOevOMiGiksd6qUtP40EsbHmuQ9w+gkZ/mF4D1TCrIgqt4FbvIiKb1bB/0+Pm4eMEEQwkI2f9WnNrhw/oHAkVJDKgr5HSueKxmjocNefvjjgQY4teU/G1Y8ALKMzHjWhm+diwg8Ptt59gjIDwyRpzhZ5Ef+1SdpiKDgDhwiDTOCBV+COCwQ4B1FTfe7lsNooH7TES7G+LhxbQdD+UDcm/bzVjJho7zQPrHnv3JnUi30DVfRZbEouSwCi8VE4vl2O9w7Yv2m+P+pkWzF0P4TQkrVmO2OWE2E/2Xhe6EJLchjM3Pc6xWKtcNiFc5OwwxwYvGTxI9NxzRTXhudJL60Ef8uWmRUgQQsMeHlSEtVKA=----ATTACHMENT:----ODYwNDcxODc0NTAzNTgxNCA5OTEzNTk0MzUzMjc5NzkxIDExNDc5MjE3Nzc4NDE5NTQ=