소스 검색

solved minor issues introduced with the new wrapped arrays for PHP

Franco Ponticelli 17 년 전
부모
커밋
ab9e6f0b21
4개의 변경된 파일11개의 추가작업 그리고 7개의 파일을 삭제
  1. 1 1
      std/Reflect.hx
  2. 0 4
      std/Type.hx
  3. 5 2
      std/haxe/io/Bytes.hx
  4. 5 0
      std/php/Boot.hx

+ 1 - 1
std/Reflect.hx

@@ -111,7 +111,7 @@ class Reflect {
 				else if(args.length == 1) return __call__("call_user_func", field(o, func), args[0]);
 				else return __call__("call_user_func", field(o, func), args[0], args[1]);
 			}
-			return __php__("call_user_func_array(is_callable($func) ? $func : array($o, $func) , $args->a)");
+			return __php__("call_user_func_array(is_callable($func) ? $func : array($o, $func) , $args == null ? array() : $args->a)");
 		#else
 			return null;
 		#end

+ 0 - 4
std/Type.hx

@@ -371,11 +371,7 @@ class Type {
 		if( f == null ) throw "No such constructor "+constr;
 		if( Reflect.isFunction(f) ) {
 			if( params == null ) throw "Constructor "+constr+" need parameters";
-#if php
-			return Reflect.callMethod(e,f,untyped params.a);
-#else
 			return Reflect.callMethod(e,f,params);
-#end
 		}
 		if( params != null && params.length != 0 )
 			throw "Constructor "+constr+" does not need parameters";

+ 5 - 2
std/haxe/io/Bytes.hx

@@ -91,7 +91,7 @@ class Bytes {
 		b.readBytes(b2,0,len);
 		return new Bytes(len,b2);
 		#elseif php
-		return new Bytes(len,untyped __call__("new _hx_array", __call__("array_slice", b, pos, len)));
+		return new Bytes(len,untyped __call__("new _hx_array", __call__("array_slice", b.a, pos, len)));
 		#else
 		return new Bytes(len,b.slice(pos,pos+len));
 		#end
@@ -190,7 +190,10 @@ class Bytes {
 		b.length = length;
 		return new Bytes(length,b);
 		#elseif php
-		return new Bytes(length, untyped __call__("new _hx_array", __call__("array_fill", 0, length, 0)));
+		if(length > 0)
+			return new Bytes(length, untyped __call__("new _hx_array", __call__("array_fill", 0, length, 0)));
+		else
+			return new Bytes(0, untyped __call__("new _hx_array", __call__("array")));
 		#else
 		var a = new Array();
 		for( i in 0...length )

+ 5 - 0
std/php/Boot.hx

@@ -145,6 +145,11 @@ class _hx_array implements ArrayAccess {
 	}
 
 	// ArrayAccess methods:
+	function __get($offset) {
+		if(isset($this->a[$offset])) return $this->a[$offset];
+		return null;
+	}
+
 	function offsetExists($offset) {
 		return isset($this->a[$offset]);
 	}