This commit is contained in:
Dante
2026-05-21 23:40:20 -07:00
parent 3e2915dff7
commit 877a69d844
5737 changed files with 29796 additions and 1589684 deletions

View File

@ -559,10 +559,8 @@ class Boot {
/**
Create Haxe-compatible anonymous structure of `data` associative array
**/
static public function createAnon(data:NativeArray):Dynamic {
var o = new HxAnon();
Syntax.foreach(data, (field:String, value:Any) -> Syntax.setField(o, field, value));
return o;
static public inline function createAnon(data:NativeArray):Dynamic {
return new HxAnon(data);
}
/**
@ -948,6 +946,13 @@ private class HxDynamicStr extends HxClosure {
@:keep
@:dox(hide)
private class HxAnon extends StdClass {
public function new(fields:NativeArray = null) {
super();
if (fields != null) {
Syntax.foreach(fields, function(name, value) Syntax.setField(this, name, value));
}
}
@:phpMagic
function __get(name:String) {
return null;

View File

@ -619,4 +619,62 @@ extern class Const {
static final FILEINFO_PRESERVE_ATIME: Int;
static final FILEINFO_RAW: Int;
static final FILEINFO_SYMLINK: Int;
/**
@see http://php.net/manual/en/calendar.constants.php
**/
static final CAL_DOW_DAYNO: Int;
static final CAL_DOW_LONG: Int;
static final CAL_DOW_SHORT: Int;
static final CAL_EASTER_ALWAYS_GREGORIAN: Int;
static final CAL_EASTER_ALWAYS_JULIAN: Int;
static final CAL_EASTER_DEFAULT: Int;
static final CAL_EASTER_ROMAN: Int;
static final CAL_FRENCH: Int;
static final CAL_GREGORIAN: Int;
static final CAL_JEWISH: Int;
static final CAL_JEWISH_ADD_ALAFIM: Int;
static final CAL_JEWISH_ADD_ALAFIM_GERESH: Int;
static final CAL_JEWISH_ADD_GERESHAYIM: Int;
static final CAL_JULIAN: Int;
static final CAL_MONTH_FRENCH: Int;
static final CAL_MONTH_GREGORIAN_LONG: Int;
static final CAL_MONTH_GREGORIAN_SHORT: Int;
static final CAL_MONTH_JEWISH: Int;
static final CAL_MONTH_JULIAN_LONG: Int;
static final CAL_MONTH_JULIAN_SHORT: Int;
static final CAL_NUM_CALS: Int;
/**
@see http://php.net/manual/en/ftp.constants.php
**/
static final FTP_ASCII: Int;
static final FTP_AUTORESUME: Int;
static final FTP_AUTOSEEK: Int;
static final FTP_BINARY: Int;
static final FTP_FAILED: Int;
static final FTP_FINISHED: Int;
static final FTP_IMAGE: Int;
static final FTP_MOREDATA: Int;
static final FTP_TEXT: Int;
static final FTP_TIMEOUT_SEC: Int;
static final FTP_USEPASVADDRESS: Bool;
/**
@see http://php.net/manual/en/misc.constants.php
**/
static final CONNECTION_ABORTED: Int;
static final CONNECTION_NORMAL: Int;
static final CONNECTION_TIMEOUT: Int;
/**
@see http://php.net/manual/fr/filesystem.constants.php
**/
static final FILE_APPEND: Int;
static final FILE_BINARY: Int;
static final FILE_IGNORE_NEW_LINES: Int;
static final FILE_NO_DEFAULT_CONTEXT: Int;
static final FILE_SKIP_EMPTY_LINES: Int;
static final FILE_TEXT: Int;
static final FILE_USE_INCLUDE_PATH: Int;
}

View File

@ -0,0 +1,40 @@
/*
* 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;
/**
The `DirectoryIterator` class provides a simple interface for viewing the contents of filesystem directories.
@see https://www.php.net/manual/en/class.directoryiterator.php
**/
@:native("DirectoryIterator")
extern class DirectoryIterator extends SplFileInfo implements SeekableIterator<Int, DirectoryIterator> {
function new(directory: String);
function current(): DirectoryIterator;
function isDot(): Bool;
function key(): Int;
function next(): Void;
function rewind(): Void;
function seek(offset: Int): Void;
function valid(): Bool;
}

View File

@ -0,0 +1,51 @@
/*
* 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;
/**
The Filesystem iterator.
@see https://www.php.net/manual/en/class.filesystemiterator.php
**/
@:native("FilesystemIterator")
extern class FilesystemIterator extends DirectoryIterator implements SeekableIterator<String, Dynamic> {
@:phpClassConst static final CURRENT_AS_FILEINFO: Int;
@:phpClassConst static final CURRENT_AS_PATHNAME: Int;
@:phpClassConst static final CURRENT_AS_SELF: Int;
@:phpClassConst static final CURRENT_MODE_MASK: Int;
@:phpClassConst static final FOLLOW_SYMLINKS: Int;
@:phpClassConst static final KEY_AS_FILENAME: Int;
@:phpClassConst static final KEY_AS_PATHNAME: Int;
@:phpClassConst static final KEY_MODE_MASK: Int;
@:phpClassConst static final NEW_CURRENT_AND_KEY: Int;
@:phpClassConst static final SKIP_DOTS: Int;
@:phpClassConst static final UNIX_PATHS: Int;
function new(directory: String, ?flags: Int);
function current(): EitherType<FilesystemIterator, EitherType<SplFileInfo, String>>;
function getFlags(): Int;
function key(): String;
function setFlags(flags: Int): Void;
}

View File

@ -9,6 +9,36 @@ import haxe.Constraints;
**/
@:phpGlobal
extern class Global {
/**
@see http://php.net/manual/en/function.get-browser.php
**/
static function get_browser(?user_agent:String, ?return_array:Bool = false):EitherType<Dynamic, EitherType<NativeArray, Bool>>;
/**
@see http://php.net/manual/en/function.get-defined-constants.php
**/
static function get_defined_constants(categorize:Bool = false):NativeArray;
/**
@see http://php.net/manual/en/function.finfo-file.php
**/
static function finfo_file(finfo:Finfo, filename:String, flags:Int = 0, ?context:Resource):EitherType<String, Bool>;
/**
@see http://php.net/manual/en/function.finfo-open.php
**/
static function finfo_open(flags:Int = 0, ?magic_database:String):EitherType<Finfo, Bool>;
/**
@see http://php.net/manual/en/function.finfo-close.php
**/
static function finfo_close(finfo:Finfo):Bool;
/**
@see http://php.net/manual/en/function.fastcgi-finish-request.php
**/
static function fastcgi_finish_request():Bool;
/**
@see http://php.net/manual/en/function.exit.php
**/
@ -370,6 +400,11 @@ extern class Global {
**/
static function strpos(haystack:String, needle:String, offset:Int = 0):EitherType<Bool, Int>;
/**
@see http://php.net/manual/en/function.stripos.php
**/
static function stripos(haystack:String, needle:String, offset:Int = 0):EitherType<Bool, Int>;
/**
@see http://php.net/manual/en/function.strrpos.php
**/
@ -390,6 +425,11 @@ extern class Global {
**/
static function strcmp(str1:String, str2:String):Int;
/**
@see https://www.php.net/manual/en/function.strspn.php
**/
static function strspn(string:String, characters:String, offset:Int = 0, ?length:Int):Int;
/**
@see http://php.net/manual/en/function.strtr.php
**/
@ -407,6 +447,11 @@ extern class Global {
static function str_replace(search:EitherType<String, NativeArray>, replace:EitherType<String, NativeArray>, subject:EitherType<String, NativeArray>,
?count:Int):EitherType<String, NativeArray>;
/**
@see https://www.php.net/manual/en/function.str-starts-with.php
**/
static function str_starts_with(haystack:String, needle:String):Bool;
/**
@see http://php.net/manual/en/function.explode.php
**/
@ -1197,7 +1242,7 @@ extern class Global {
/**
@see http://php.net/manual/en/function.mb-strlen.php
**/
static function mb_strlen(str:String, ?encoding:String):EitherType<Int, Bool>;
static function mb_strlen(str:String, ?encoding:String):Int;
/**
@see http://php.net/manual/en/function.mb-substr.php
@ -1454,6 +1499,11 @@ extern class Global {
**/
static function base64_decode(data:String, strict:Bool = false):EitherType<String, Bool>;
/**
@see http://php.net/manual/en/function.gethostname.php
**/
static function gethostname():EitherType<String, Bool>;
/**
@see http://php.net/manual/en/function.gethostbyname.php
**/
@ -1868,4 +1918,244 @@ extern class Global {
@see http://php.net/manual/en/function.empty.php
**/
static function empty(variable:Any):Bool;
/**
@see http://php.net/manual/en/function.quoted-printable-decode.php
**/
static function quoted_printable_decode(string:String):String;
/**
@see http://php.net/manual/en/function.quoted-printable-encode.php
**/
static function quoted_printable_encode(string:String):String;
/**
@see http://php.net/manual/en/function.easter-date.php
**/
static function easter_date(?year:Int, ?mode:Int): Int;
/**
@see http://php.net/manual/en/function.easter-days.php
**/
static function easter_days(?year:Int, ?mode:Int): Int;
/**
@see http://php.net/manual/en/function.sys-get-temp-dir.php
**/
static function sys_get_temp_dir():String;
/**
@see http://php.net/manual/en/function.tempnam.php
**/
static function tempnam(directory:String, prefix:String):EitherType<String, Bool>;
/**
@see http://php.net/manual/en/function.tmpfile.php
**/
static function tmpfile():EitherType<Resource, Bool>;
/**
@see http://php.net/manual/en/function.ftp-alloc.php
**/
static function ftp_alloc(ftp: Resource, size: Int, ?response: Ref<String>): Bool;
/**
@see http://php.net/manual/en/function.ftp-append.php
**/
static function ftp_append(ftp: Resource, remote_filename: String, local_filename: String, ?mode: Int): Bool;
/**
@see http://php.net/manual/en/function.ftp-cdup.php
**/
static function ftp_cdup(ftp: Resource): Bool;
/**
@see http://php.net/manual/en/function.ftp-chdir.php
**/
static function ftp_chdir(ftp: Resource, directory: String): Bool;
/**
@see http://php.net/manual/en/function.ftp-chmod.php
**/
static function ftp_chmod(ftp: Resource, permissions: Int, filename: String): EitherType<Int, Bool>;
/**
@see http://php.net/manual/en/function.ftp-close.php
**/
static function ftp_close(ftp: Resource): Bool;
/**
@see http://php.net/manual/en/function.ftp-connect.php
**/
static function ftp_connect(hostname: String, port: Int = 21, timeout: Int = 90): EitherType<Resource, Bool>;
/**
@see http://php.net/manual/en/function.ftp-delete.php
**/
static function ftp_delete(ftp: Resource, filename: String): Bool;
/**
@see http://php.net/manual/en/function.ftp-exec.php
**/
static function ftp_exec(ftp: Resource, command: String): Bool;
/**
@see http://php.net/manual/en/function.ftp-fget.php
**/
static function ftp_fget(ftp: Resource, stream: Resource, remote_filename: String, ?mode: Int, offset: Int = 0): Bool;
/**
@see http://php.net/manual/en/function.ftp-fput.php
**/
static function ftp_fput(ftp: Resource, remote_filename: String, stream: Resource, ?mode: Int, offset: Int = 0): Bool;
/**
@see http://php.net/manual/en/function.ftp-get.php
**/
static function ftp_get(ftp: Resource, local_filename: String, remote_filename: String, offset: Int = 0): Bool;
/**
@see http://php.net/manual/en/function.ftp-get-option.php
**/
static function ftp_get_option(ftp: Resource, option: Int): EitherType<Int, Bool>;
/**
@see http://php.net/manual/en/function.ftp-login.php
**/
static function ftp_login(ftp: Resource, username: String, password: String): Bool;
/**
@see http://php.net/manual/en/function.ftp-mdtm.php
**/
static function ftp_mdtm(ftp: Resource, filename: String): Int;
/**
@see http://php.net/manual/en/function.ftp-mkdir.php
**/
static function ftp_mkdir(ftp: Resource, directory: String): EitherType<String, Bool>;
/**
@see http://php.net/manual/en/function.ftp-mlsd.php
**/
static function ftp_mlsd(ftp: Resource, directory: String): EitherType<NativeIndexedArray<NativeAssocArray<String>>, Bool>;
/**
@see http://php.net/manual/en/function.ftp-nb-continue.php
**/
static function ftp_nb_continue(ftp: Resource): Int;
/**
@see http://php.net/manual/en/function.ftp-nb-fget.php
**/
static function ftp_nb_fget(ftp: Resource, stream: Resource, remote_filename: String, ?mode: Int, offset: Int = 0): Int;
/**
@see http://php.net/manual/en/function.ftp-nb-fput.php
**/
static function ftp_nb_fput(ftp: Resource, remote_filename: String, stream: Resource, ?mode: Int, offset: Int = 0): Int;
/**
@see http://php.net/manual/en/function.ftp-nb-get.php
**/
static function ftp_nb_get(ftp: Resource, local_filename: String, remote_filename: String, offset: Int = 0): Int;
/**
@see http://php.net/manual/en/function.ftp-nb-put.php
**/
static function ftp_nb_put(ftp: Resource, remote_filename: String, local_filename: String, offset: Int = 0): EitherType<Int, Bool>;
/**
@see http://php.net/manual/en/function.ftp-nlist.php
**/
static function ftp_nlist(ftp: Resource, directory: String): EitherType<NativeIndexedArray<String>, Bool>;
/**
@see http://php.net/manual/en/function.ftp-pasv.php
**/
static function ftp_pasv(ftp: Resource, enable: Bool): Bool;
/**
@see http://php.net/manual/en/function.ftp-put.php
**/
static function ftp_put(ftp: Resource, remote_filename: String, local_filename: String, offset: Int = 0): Bool;
/**
@see http://php.net/manual/en/function.ftp-pwd.php
**/
static function ftp_pwd(ftp: Resource): EitherType<String, Bool>;
/**
@see http://php.net/manual/en/function.ftp-raw.php
**/
static function ftp_raw(ftp: Resource, command: String): NativeIndexedArray<String>;
/**
@see http://php.net/manual/en/function.ftp-rawlist.php
**/
static function ftp_rawlist(ftp: Resource, directory: String, recursive: Bool = false): EitherType<NativeIndexedArray<String>, Bool>;
/**
@see http://php.net/manual/en/function.ftp-rename.php
**/
static function ftp_rename(ftp: Resource, from: String, to: String): Bool;
/**
@see http://php.net/manual/en/function.ftp-rmdir.php
**/
static function ftp_rmdir(ftp: Resource, directory: String): Bool;
/**
@see http://php.net/manual/en/function.ftp-set-option.php
**/
static function ftp_set_option(ftp: Resource, option: Int, value: EitherType<Int, Bool>): Bool;
/**
@see http://php.net/manual/en/function.ftp-site.php
**/
static function ftp_site(ftp: Resource, command: String): Bool;
/**
@see http://php.net/manual/en/function.ftp-size.php
**/
static function ftp_size(ftp: Resource, filename: String): Int;
/**
@see http://php.net/manual/en/function.ftp-ssl-connect.php
**/
static function ftp_ssl_connect(hostname: String, port: Int = 21, timeout: Int = 90): EitherType<Resource, Bool>;
/**
@see http://php.net/manual/en/function.ftp-systype.php
**/
static function ftp_systype(ftp: Resource): EitherType<String, Bool>;
/**
@see http://php.net/manual/en/function.connection-aborted.php
**/
static function connection_aborted(): Int;
/**
@see http://php.net/manual/en/function.connection-status.php
**/
static function connection_status(): Int;
/**
@see http://php.net/manual/en/function.ignore-user-abort.php
**/
static function ignore_user_abort(enable: Null<Bool> = null): Int;
/**
@see http://php.net/manual/en/function.highlight-file.php
**/
static function highlight_file(filename: String, returns: Bool = false): EitherType<String, Bool>;
/**
@see http://php.net/manual/en/function.highlight-string.php
**/
static function highlight_string(string: String, returns: Bool = false): EitherType<String, Bool>;
/**
@see http://php.net/manual/en/function.php-strip-whitespace.php
**/
static function php_strip_whitespace(filename: String): String;
}

View File

@ -98,7 +98,7 @@ class Lib {
return @:privateAccess Array.wrap(a);
}
public static function hashOfAssociativeArray<T>(arr:NativeAssocArray<T>):Map<String, T> {
public static function hashOfAssociativeArray<T>(arr:NativeAssocArray<T>):StringMap<T> {
var result = new StringMap();
@:privateAccess result.data = arr;
return result;

View File

@ -0,0 +1,104 @@
/*
* 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;
/**
The `Phar` class provides a high-level interface to accessing and creating PHAR archives.
@see https://www.php.net/manual/en/class.phar.php
**/
@:native("Phar")
extern class Phar extends RecursiveDirectoryIterator implements Countable implements php.ArrayAccess<String, PharFileInfo> {
@:phpClassConst static final BZ2: Int;
@:phpClassConst static final COMPRESSED: Int;
@:phpClassConst static final GZ: Int;
@:phpClassConst static final MD5: Int;
@:phpClassConst static final NONE: Int;
@:phpClassConst static final OPENSSL: Int;
@:phpClassConst static final PHAR: Int;
@:phpClassConst static final PHP: Int;
@:phpClassConst static final PHPS: Int;
@:phpClassConst static final SHA1: Int;
@:phpClassConst static final SHA256: Int;
@:phpClassConst static final SHA512: Int;
@:phpClassConst static final TAR: Int;
@:phpClassConst static final ZIP: Int;
final static function apiVersion(): String;
final static function canCompress(type: Int = 0): Bool;
final static function canWrite(): Bool;
final static function createDefaultStub(?index: String, ?webIndex: String): String;
final static function getSupportedCompression(): NativeIndexedArray<String>;
final static function getSupportedSignatures(): NativeIndexedArray<String>;
final static function isValidPharFilename(filename: String, executable: Bool = true): Bool;
final static function loadPhar(filename: String, ?alias: String): Bool;
final static function mapPhar(?alias: String, dataoffset: Int = 0): Bool;
final static function mount(pharpath: String, externalpath: String): Void;
final static function mungServer(munglist: NativeIndexedArray<String>): Void;
final static function running(retphar: Bool = true): String;
final static function unlinkArchive(archive: String): Bool;
final static function webPhar(?alias: String, index: String = "index.php", ?f404: String, ?mimetypes: NativeAssocArray<String>, ?callable: String -> EitherType<String, Bool>): Void;
function new(fname: String, ?flags: Int, ?alias: String);
function addEmptyDir(dirname: String): Void;
function addFile(file: String, ?localname: String): Void;
function addFromString(localname: String, contents: String): Void;
function buildFromDirectory(base_dir: String, ?regex: String): NativeAssocArray<String>;
function buildFromIterator(iter: EitherType<NativeIterator<String, String>, NativeIterator<Int, SplFileInfo>>, ?base_directory: String): NativeAssocArray<String>;
function compress(compression: Int, ?extension: String): Phar;
function compressFiles(compression: Int): Void;
function convertToData(?format: Int, ?compression: Int, ?extension: String): PharData;
function convertToExecutable(?format: Int, ?compression: Int, ?extension: String): Phar;
function copy(oldfile: String, newfile: String): Bool;
function count(): Int;
function decompress(?extension: String): PharData;
function decompressFiles(): Void;
function delete(entry: String): Bool;
function delMetadata(): Bool;
function extractTo(pathto: String, ?files: EitherType<String, NativeIndexedArray<String>>, overwrite: Bool = false): Bool;
function getAlias(): String;
function getMetadata(): Dynamic;
function getModified(): Bool;
function getPath(): String;
function getSignature(): NativeAssocArray<String>;
function getStub(): String;
function getVersion(): String;
function hasMetadata(): Bool;
function isBuffering(): Bool;
function isCompressed(): EitherType<Int, Bool>;
function isFileFormat(format: Int): Bool;
function isWritable(): Bool;
function offsetExists(offset: String): Bool;
function offsetGet(offset: String): PharFileInfo;
function offsetSet(offset: String, value: Dynamic): Void;
function offsetUnset(offset: String): Void;
function setAlias(alias: String): Bool;
function setDefaultStub(?index: String, ?webindex: String): Bool;
function setMetadata(metadata: Any): Void;
function setSignatureAlgorithm(sigtype: Int, ?privatekey: String): Void;
function setStub(stub: String, len: Int = -1): Bool;
function startBuffering(): Void;
function stopBuffering(): Void;
}

View File

@ -0,0 +1,59 @@
/*
* 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;
/**
The `PharData` class provides a high-level interface to accessing and creating non-executable TAR and ZIP archives.
@see https://www.php.net/manual/en/class.phardata.php
**/
@:native("PharData")
extern class PharData extends RecursiveDirectoryIterator implements Countable implements php.ArrayAccess<String, PharFileInfo> {
function new(fname: String, ?flags: Int, ?alias: String, ?format: Int);
function addEmptyDir(dirname: String): Void;
function addFile(file: String, ?localname: String): Void;
function addFromString(localname: String, contents: String): Void;
function buildFromDirectory(base_dir: String, ?regex: String): NativeAssocArray<String>;
function buildFromIterator(iter: EitherType<NativeIterator<String, String>, NativeIterator<Int, SplFileInfo>>, ?base_directory: String): NativeAssocArray<String>;
function compress(compression: Int, ?extension: String): PharData;
function compressFiles(compression: Int): Void;
function copy(oldfile: String, newfile: String): Bool;
function count(): Int;
function decompress(?extension: String): PharData;
function decompressFiles(): Void;
function delete(entry: String): Bool;
function delMetadata(): Bool;
function extractTo(pathto: String, ?files: EitherType<String, NativeIndexedArray<String>>, overwrite: Bool = false): Bool;
function isWritable(): Bool;
function offsetExists(offset: String): Bool;
function offsetGet(offset: String): PharFileInfo;
function offsetSet(offset: String, value: Dynamic): Void;
function offsetUnset(offset: String): Void;
function setAlias(alias: String): Bool;
function setDefaultStub(?index: String, ?webindex: String): Bool;
function setMetadata(metadata: Any): Void;
function setSignatureAlgorithm(sigtype: Int): Void;
function setStub(stub: String, len: Int = -1): Bool;
}

View File

@ -0,0 +1,30 @@
/*
* 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;
/**
The `PharException` class provides a phar-specific exception class for try/catch blocks.
@see https://www.php.net/manual/en/class.pharexception.php
**/
@:native("PharException")
extern class PharException extends Exception {}

View File

@ -0,0 +1,46 @@
/*
* 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;
/**
The `PharFileInfo` class provides a high-level interface to the contents and attributes of a single file within a PHAR archive.
@see https://www.php.net/manual/en/class.pharfileinfo
**/
@:native("PharFileInfo")
extern class PharFileInfo extends SplFileInfo {
function new(entry: String);
function chmod(permissions: Int): Void;
function compress(compression: Int): Bool;
function decompress(): Bool;
function delMetadata(): Bool;
function getCompressedSize(): Int;
function getContent(): String;
function getCRC32(): Int;
function getMetadata(): Dynamic;
function getPharFlags(): Int;
function hasMetadata(): Bool;
function isCompressed(?compression_type: Int): Bool;
function isCRCChecked(): Bool;
function setMetadata(metadata: Any): Void;
}

View File

@ -0,0 +1,39 @@
/*
* 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;
/**
The `RecursiveDirectoryIterator` provides an interface for iterating recursively over filesystem directories.
@see https://www.php.net/manual/en/class.recursivedirectoryiterator.php
**/
@:native("RecursiveDirectoryIterator")
extern class RecursiveDirectoryIterator extends FilesystemIterator implements RecursiveIterator<String, Dynamic> implements SeekableIterator<String, Dynamic> {
function new(directory: String, ?flags: Int);
function getChildren(): Null<RecursiveDirectoryIterator>;
function getSubPath(): String;
function getSubPathname(): String;
@:overload(function(allowLinks: Bool): Bool {})
function hasChildren(): Bool;
}

View File

@ -0,0 +1,33 @@
/*
* 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;
/**
Classes implementing `RecursiveIterator` can be used to iterate over iterators recursively.
@see https://www.php.net/manual/en/class.recursiveiterator.php
**/
@:native("RecursiveIterator")
extern interface RecursiveIterator<K, V> extends NativeIterator<K, V> {
function getChildren(): Null<RecursiveIterator<K, V>>;
function hasChildren(): Bool;
}

View File

@ -0,0 +1,42 @@
/*
* 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;
/**
The `ResourceBundle` class implements access to ICU resource data files.
@see https://www.php.net/manual/en/class.resourcebundle.php
**/
@:native("ResourceBundle")
extern class ResourceBundle {
function new(locale: Null<String>, bundle: Null<String>, fallback: Bool = true);
static function create(locale: Null<String>, bundle: Null<String>, fallback: Bool = true): Null<ResourceBundle>;
static function getLocales(bundle: String): EitherType<NativeIndexedArray<String>, Bool>;
function count(): Int;
function get(index: EitherType<Int, String>, fallback: Bool = true): Dynamic;
function getErrorCode(): Int;
function getErrorMessage(): String;
}

View File

@ -0,0 +1,73 @@
/*
* 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;
/**
The `SplFileInfo` class offers a high-level object-oriented interface to information for an individual file.
@see https://www.php.net/manual/en/class.splfileinfo.php
**/
@:native("SplFileInfo")
extern class SplFileInfo {
function new(filename: String);
function getATime(): EitherType<Int, Bool>;
function getBasename(suffix: String = ""): String;
function getCTime(): EitherType<Int, Bool>;
function getExtension(): String;
function getFileInfo(?className: String): SplFileInfo;
function getFilename(): String;
function getGroup(): EitherType<Int, Bool>;
function getInode(): EitherType<Int, Bool>;
function getLinkTarget(): EitherType<String, Bool>;
function getMTime(): EitherType<Int, Bool>;
function getOwner(): EitherType<Int, Bool>;
function getPath(): String;
function getPathInfo(?className: String): Null<SplFileInfo>;
function getPathname(): String;
function getPerms(): EitherType<Int, Bool>;
function getRealPath(): EitherType<String, Bool>;
function getSize(): EitherType<Int, Bool>;
function getType(): EitherType<SplFileInfoType, Bool>;
function isDir(): Bool;
function isExecutable(): Bool;
function isFile(): Bool;
function isLink(): Bool;
function isReadable(): Bool;
function isWritable(): Bool;
function openFile(mode: String = "r", useIncludePath: Bool = false, ?context: Resource): SplFileObject;
function setFileClass(?className: String): Void;
function setInfoClass(?className: String): Void;
}
enum abstract SplFileInfoType(String) to String {
var Block = "block";
var Char = "char";
var Dir = "dir";
var Fifo = "fifo";
var File = "file";
var Link = "link";
var Socket = "socket";
var Unknown = "unknown";
}

View File

@ -0,0 +1,71 @@
/*
* 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;
import haxe.extern.Rest;
/**
The `SplFileObject` class offers an object-oriented interface for a file.
@see https://www.php.net/manual/en/class.splfileobject.php
**/
@:native("SplFileObject")
extern class SplFileObject extends SplFileInfo implements RecursiveIterator<Int, Dynamic> implements SeekableIterator<Int, Dynamic> {
@:phpClassConst static final DROP_NEW_LINE: Int;
@:phpClassConst static final READ_AHEAD: Int;
@:phpClassConst static final READ_CSV: Int;
@:phpClassConst static final SKIP_EMPTY: Int;
function new(filename: String, mode: String = "r", useIncludePath: Bool = false, ?context: Resource);
function current(): EitherType<String, EitherType<NativeIndexedArray<String>, Bool>>;
function eof(): Bool;
function fflush(): Bool;
function fgetc(): EitherType<String, Bool>;
function fgetcsv(separator: String = ",", enclosure: String = "\"", escape: String = "\\"): EitherType<NativeIndexedArray<String>, Bool>;
function fgets(): String;
function fgetss(?allowable_tags: String): String;
function flock(operation: Int, ?wouldBlock: Ref<Int>): Bool;
function fpassthru(): Int;
function fputcsv(fields: NativeIndexedArray<String>, separator: String = ",", enclosure: String = "\"", escape: String = "\\"): EitherType<Int, Bool>;
function fread(length: Int): EitherType<String, Bool>;
function fscanf(format: String, vars: Rest<Ref<Dynamic>>): EitherType<Int, NativeIndexedArray<Dynamic>>;
function fseek(offset: Int, ?whence: Int): Int;
function fstat(): NativeArray;
function ftell(): EitherType<Int, Bool>;
function ftruncate(size: Int): Bool;
function fwrite(data: String, length: Int = 0): EitherType<Int, Bool>;
function getChildren(): Null<RecursiveIterator<Int, Dynamic>>;
function getCsvControl(): NativeIndexedArray<String>;
function getFlags(): Int;
function getMaxLineLen(): Int;
function hasChildren(): Bool;
function key(): Int;
function next(): Void;
function rewind(): Void;
function seek(line: Int): Void;
function setCsvControl(separator: String = ",", enclosure: String = "\"", escape: String = "\\"): Void;
function setFlags(flags: Int): Void;
function setMaxLineLen(maxLength: Int): Void;
function valid(): Bool;
}

View File

@ -60,4 +60,12 @@ namespace { //Namespace declaration is required because this file is included un
}
}
/**
* @see https://www.php.net/manual/en/function.str-starts-with.php
*/
if (!function_exists('str_starts_with')) {
function str_starts_with($str, $start) {
return (@substr_compare($str, $start, 0, strlen($start))==0);
}
}
}

View File

@ -215,11 +215,14 @@ final class Array<T> implements ArrayAccess<Int, T> implements IteratorAggregate
@:noCompletion @:keep
@:php.attribute('\\ReturnTypeWillChange')
function offsetGet(offset:Int):Ref<T> {
try {
return arr[offset];
} catch (e:Dynamic) {
return null;
if(offset < 0 || offset >= length) {
//This var is required in generated php code
//because only variables can be returned by reference.
final result = null;
Syntax.keepVar(result);
return result;
}
return arr[offset];
}
@:noCompletion @:keep

View File

@ -52,22 +52,27 @@ import php.Syntax;
}
public static function parseInt(x:String):Null<Int> {
if (Global.is_numeric(x)) {
return Global.intval(x, 10);
} else {
x = Global.ltrim(x);
var firstCharIndex = (x.charAt(0) == '-' ? 1 : 0);
var firstCharCode = x.charCodeAt(firstCharIndex);
if (!isDigitCode(firstCharCode)) {
x = Global.ltrim(x, " \t\n\x0b\x0c\r");
final digitsOnly = Global.ltrim(x, "+-");
if (Global.str_starts_with(digitsOnly, '0x') || Global.str_starts_with(digitsOnly, '0X')) {
final val = Global.intval(x, 16); // hexadecimal
// if the value was 0, ensure there is only a maximum of one + or - sign
if (val == 0 && digitsOnly.length + 1 < x.length)
return null;
}
var secondChar = x.charAt(firstCharIndex + 1);
if (secondChar == 'x' || secondChar == 'X') {
return Global.intval(x, 0);
} else {
return Global.intval(x, 10);
}
return val;
}
switch Global.stripos(x, 'e') {
case false:
case ePos: x = Global.substr(x, 0, ePos);
}
final val = Global.intval(x, 10);
// if the value was 0, make sure it wasn't because the string had no valid digits
// last check ensures there is only a maximum of one + or - sign
if (val == 0 && (Global.strspn(digitsOnly, "0123456789", 0, 1) == 0 || digitsOnly.length + 1 < x.length))
return null;
return val;
}
public static function parseFloat(x:String):Float {

View File

@ -29,6 +29,43 @@ import haxe.SysTools;
/** Environment variables set by `Sys.putEnv()` */
static var customEnvVars = new NativeAssocArray<String>();
// we need to keep track of capitalization for windows
static final isWindows = systemName() == "Windows";
static var envCapitalization(get, null):Map<String, String>;
static function get_envCapitalization():Map<String, String> {
if (envCapitalization == null)
return envCapitalization = [for (k => _ in SuperGlobal._SERVER) k.toUpperCase() => k];
return envCapitalization;
}
static inline function addCustom(name:String, value:String):Void {
customEnvVars[name] = value;
if (!isWindows)
return;
final upperCase = name.toUpperCase();
if (envCapitalization.exists(upperCase))
return;
envCapitalization[upperCase] = name;
}
static inline function removeCustom(name:String):Void {
Global.unset(customEnvVars[name]);
if (!isWindows)
return;
envCapitalization.remove(name.toUpperCase());
}
static inline function getCapitalization(name:String):String {
if (!isWindows)
return name;
final existing = envCapitalization[name.toUpperCase()];
if (existing != null)
return existing;
return name;
}
public static inline function print(v:Dynamic):Void {
Global.echo(Std.string(v));
}
@ -50,9 +87,14 @@ import haxe.SysTools;
return value == false ? null : value;
}
public static function putEnv(s:String, v:String):Void {
customEnvVars[s] = '$v'; // in case of `null` it should become `"null"`
Global.putenv('$s=$v');
public static function putEnv(s:String, v:Null<String>):Void {
if (v == null) {
removeCustom(s);
Global.putenv('$s');
} else {
addCustom(s, v);
Global.putenv('$s=$v');
}
}
public static inline function sleep(seconds:Float):Void {
@ -124,7 +166,8 @@ import haxe.SysTools;
public static function environment():Map<String, String> {
var env = SuperGlobal._SERVER;
Syntax.foreach(customEnvVars, function(name:String, value:String) {
env[name] = value;
final actualName = getCapitalization(name);
env[actualName] = value;
});
return php.Lib.hashOfAssociativeArray(env);
}

View File

@ -17,6 +17,11 @@ abstract Rest<T>(NativeRest<T>) {
static public inline function of<T>(array:Array<T>):Rest<T>
return new Rest(@:privateAccess array.arr);
@:noDoc
@:from
static inline function ofNative<T>(array:NativeIndexedArray<T>):Rest<T>
return new Rest(array);
inline function new(a:NativeIndexedArray<T>):Void
this = a;

View File

@ -44,15 +44,18 @@ class Base64 {
public static inline function decode(str:String, complement = true):Bytes {
if (!complement) {
switch (strlen(str) % 3) {
case 1:
str += "==";
switch (strlen(str) % 4) {
case 2:
str += "==";
case 3:
str += "=";
default:
}
}
return Bytes.ofString(base64_decode(str, true));
return switch base64_decode(str, true) {
case false: throw new Exception("Base64.decode : invalid encoded string");
case s: Bytes.ofString(s);
}
}
public static inline function urlEncode(bytes:Bytes, complement = false):String {
@ -62,14 +65,17 @@ class Base64 {
public static inline function urlDecode(str:String, complement = false):Bytes {
if (complement) {
switch (strlen(str) % 3) {
case 1:
str += "==";
switch (strlen(str) % 4) {
case 2:
str += "==";
case 3:
str += "=";
default:
}
}
return Bytes.ofString(base64_decode(str_replace(URL_62_63, NORMAL_62_63, str), true));
return switch base64_decode(str_replace(URL_62_63, NORMAL_62_63, str), true) {
case false: throw new Exception("Base64.urlDecode : invalid encoded string");
case s: Bytes.ofString(s);
}
}
}

View File

@ -79,7 +79,7 @@ import php.NativeIndexedArray;
Global.array_push(parts, '$key => ' + Std.string(value));
});
return '{' + Global.implode(', ', parts) + '}';
return "[" + Global.implode(", ", parts) + "]";
}
public inline function clear():Void {

View File

@ -78,7 +78,7 @@ class ObjectMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
}
public function toString():String {
var s = "{";
var s = "[";
var it = keys();
for (i in it) {
s += Std.string(i);
@ -87,7 +87,7 @@ class ObjectMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
if (it.hasNext())
s += ", ";
}
return s + "}";
return s + "]";
}
public inline function clear():Void {

View File

@ -80,7 +80,7 @@ import haxe.Constraints;
Global.array_push(parts, '$key => ' + Std.string(value));
});
return '{' + Global.implode(', ', parts) + '}';
return "[" + Global.implode(", ", parts) + "]";
}
public inline function clear():Void {

View File

@ -28,19 +28,24 @@ private class PhpVectorData<T> {
public var length:Int;
public var data:NativeIndexedArray<T>;
public inline function new(length:Int) {
public inline function new(length:Int, data:NativeIndexedArray<T>) {
this.length = length;
data = new NativeIndexedArray();
this.data = data;
}
}
private typedef VectorData<T> = PhpVectorData<T>;
@:coreApi
abstract Vector<T>(VectorData<T>) {
public var length(get, never):Int;
public inline function new(length:Int) {
this = new VectorData(length);
extern overload public inline function new(length:Int) {
this = new VectorData(length, new NativeIndexedArray());
}
extern overload public inline function new(length:Int, defaultValue:T):Vector<T> {
this = new VectorData(length, Global.array_fill(0, length, defaultValue));
}
@:op([]) public inline function get(index:Int):T {
@ -55,6 +60,9 @@ abstract Vector<T>(VectorData<T>) {
return this.length;
}
public inline function fill(value:T):Void
this.data = Global.array_fill(0, length, value);
public static function blit<T>(src:Vector<T>, srcPos:Int, dest:Vector<T>, destPos:Int, len:Int):Void {
if (src == dest) {
if (srcPos < destPos) {
@ -99,8 +107,7 @@ abstract Vector<T>(VectorData<T>) {
}
static public inline function fromArrayCopy<T>(array:Array<T>):Vector<T> {
var vectorData = new VectorData(array.length);
vectorData.data = @:privateAccess array.arr;
var vectorData = new VectorData(array.length, @:privateAccess array.arr);
return cast vectorData;
}
@ -127,7 +134,7 @@ abstract Vector<T>(VectorData<T>) {
return result;
}
public inline function sort<T>(f:T->T->Int):Void {
public inline function sort(f:T->T->Int):Void {
Global.usort(this.data, f);
}
}

View File

@ -99,7 +99,7 @@ extern class PDO {
function errorInfo():NativeArray;
function exec(statement:String):Int;
function getAttribute(attribute:Int):Dynamic;
function getAvailableDrivers():NativeArray;
static function getAvailableDrivers():NativeIndexedArray<String>;
function lastInsertId(?name:String):String;
function prepare(statement:String, ?driver_options:NativeArray):PDOStatement;
function query(statement:String, ?mode:Int):PDOStatement;