Explorar el Código

[php] Add externs for the `finfo` class and constants (#10065)

Cédric Belin hace 4 años
padre
commit
52e7ba5786
Se han modificado 2 ficheros con 51 adiciones y 0 borrados
  1. 15 0
      std/php/Const.hx
  2. 36 0
      std/php/Finfo.hx

+ 15 - 0
std/php/Const.hx

@@ -604,4 +604,19 @@ extern class Const {
 	static final INPUT_REQUEST:Int;
 	static final INPUT_SERVER:Int;
 	static final INPUT_SESSION:Int;
+
+	/**
+		@see http://php.net/manual/en/fileinfo.constants.php
+	**/
+	static final FILEINFO_COMPRESS: Int;
+	static final FILEINFO_CONTINUE: Int;
+	static final FILEINFO_DEVICES: Int;
+	static final FILEINFO_EXTENSION: Int;
+	static final FILEINFO_MIME: Int;
+	static final FILEINFO_MIME_ENCODING: Int;
+	static final FILEINFO_MIME_TYPE: Int;
+	static final FILEINFO_NONE: Int;
+	static final FILEINFO_PRESERVE_ATIME: Int;
+	static final FILEINFO_RAW: Int;
+	static final FILEINFO_SYMLINK: Int;
 }

+ 36 - 0
std/php/Finfo.hx

@@ -0,0 +1,36 @@
+/*
+ * Copyright (C)2005-2021 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package php;
+
+import haxe.extern.EitherType;
+
+/**
+	@see https://www.php.net/manual/en/class.finfo.php
+**/
+@:native("finfo")
+extern class Finfo {
+	function new(?flags: Int, magic_database: String = "");
+	function buffer(string: String, ?flags: Int, ?context:Resource): EitherType<String, Bool>;
+	function file(filename: String, ?flags: Int, ?context:Resource): EitherType<String, Bool>;
+	function set_flags(flags: Int): Bool;
+}