浏览代码

- php : added @:core_type where missing

Franco Ponticelli 15 年之前
父节点
当前提交
bd0a3fd27c
共有 3 个文件被更改,包括 37 次插入37 次删除
  1. 8 8
      std/php/_std/List.hx
  2. 25 25
      std/php/_std/Math.hx
  3. 4 4
      std/php/_std/StringTools.hx

+ 8 - 8
std/php/_std/List.hx

@@ -28,18 +28,18 @@
 	that are chained together. It's optimized so that adding or removing an
 	element doesn't imply to copy the whole array content everytime.
 **/
-class List<T> implements php.IteratorAggregate<T> {
+@:core_api class List<T> implements php.IteratorAggregate<T> {
 
 	private var h : ArrayAccess<Dynamic>;
 	private var q : ArrayAccess<Dynamic>;
 
 	public var length(default,null) : Int;
 
-	public function new() {
+	public function new() : Void {
 		length = 0;
 	}
 
-	public function add( item : T ) {
+	public function add( item : T ) : Void {
 		var x = untyped __call__('array', item, null);
 		if( h == null )
 			untyped __php__("$this->h =& $x");
@@ -49,7 +49,7 @@ class List<T> implements php.IteratorAggregate<T> {
 		length++;
 	}
 
-	public function push( item : T ) {
+	public function push( item : T ) : Void {
 		var x = untyped __call__('array', item, __php__("&$this->h"));
 		untyped __php__("$this->h =& $x");
 		if( q == null )
@@ -110,7 +110,7 @@ class List<T> implements php.IteratorAggregate<T> {
 		return untyped __call__("new _hx_list_iterator", this);
 	}
 
-	public function toString() {
+	public function toString() : String {
 		var s = "";
 		var first = true;
 		var l = h;
@@ -125,7 +125,7 @@ class List<T> implements php.IteratorAggregate<T> {
 		return "{" + s + "}";
 	}
 
-	public function join(sep : String) {
+	public function join(sep : String) : String {
 		var s = "";
 		var first = true;
 		var l = h;
@@ -140,7 +140,7 @@ class List<T> implements php.IteratorAggregate<T> {
 		return s;
 	}
 
-	public function filter( f : T -> Bool ) {
+	public function filter( f : T -> Bool ) : List<T> {
 		var l2 = new List();
 		var l = h;
 		while( l != null ) {
@@ -163,7 +163,7 @@ class List<T> implements php.IteratorAggregate<T> {
 		return b;
 	}
 
-	function getIterator() {
+	function getIterator() : Iterator<T> {
 		return iterator();
 	}
 }

+ 25 - 25
std/php/_std/Math.hx

@@ -23,35 +23,35 @@
  * DAMAGE.
  */
 
-class Math
+@:core_api class Math
 {
-	public static var PI;
-	public static var NaN;
-	public static var POSITIVE_INFINITY;
-	public static var NEGATIVE_INFINITY;
+	public static var PI(default,null) : Float;
+	public static var NaN(default,null) : Float;
+	public static var POSITIVE_INFINITY(default,null) : Float;
+	public static var NEGATIVE_INFINITY(default,null) : Float;
 
-	public static function abs(v) : Float      { return untyped __call__("abs", v); }
-	public static function min(a,b) : Float    { return untyped __call__("min", a, b); }
-	public static function max(a,b) : Float    { return untyped __call__("max", a, b); }
-	public static function sin(v) : Float      { return untyped __call__("sin", v); }
-	public static function cos(v) : Float      { return untyped __call__("cos", v); }
-	public static function atan2(y,x) : Float  { return untyped __call__("atan2", y, x); }
-	public static function tan(v) : Float      { return untyped __call__("tan", v); }
-	public static function exp(v) : Float      { return untyped __call__("exp", v); }
-	public static function log(v) : Float      { return untyped __call__("log", v); }
-	public static function sqrt(v) : Float     { return untyped __call__("sqrt", v); }
-	public static function round(v) : Int      { return untyped __call__("(int) floor", v + 0.5); }
-	public static function floor(v) : Int      { return untyped __call__("(int) floor", v); }
-	public static function ceil(v) : Int       { return untyped __call__("(int) ceil", v); }
-	public static function atan(v) : Float     { return untyped __call__("atan", v); }
-	public static function asin(v) : Float     { return untyped __call__("asin", v); }
-	public static function acos(v) : Float     { return untyped __call__("acos", v); }
-	public static function pow(b,e) : Float    { return untyped __call__("pow", b, e); }
+	public static function abs(v : Float) : Float      { return untyped __call__("abs", v); }
+	public static function min(a : Float,b : Float) : Float    { return untyped __call__("min", a, b); }
+	public static function max(a : Float,b : Float) : Float    { return untyped __call__("max", a, b); }
+	public static function sin(v : Float) : Float      { return untyped __call__("sin", v); }
+	public static function cos(v : Float) : Float      { return untyped __call__("cos", v); }
+	public static function atan2(y : Float,x : Float) : Float  { return untyped __call__("atan2", y, x); }
+	public static function tan(v : Float) : Float      { return untyped __call__("tan", v); }
+	public static function exp(v : Float) : Float      { return untyped __call__("exp", v); }
+	public static function log(v : Float) : Float      { return untyped __call__("log", v); }
+	public static function sqrt(v : Float) : Float     { return untyped __call__("sqrt", v); }
+	public static function round(v : Float) : Int      { return untyped __call__("(int) floor", v + 0.5); }
+	public static function floor(v : Float) : Int      { return untyped __call__("(int) floor", v); }
+	public static function ceil(v : Float) : Int       { return untyped __call__("(int) ceil", v); }
+	public static function atan(v : Float) : Float     { return untyped __call__("atan", v); }
+	public static function asin(v : Float) : Float     { return untyped __call__("asin", v); }
+	public static function acos(v : Float) : Float     { return untyped __call__("acos", v); }
+	public static function pow(b : Float,e : Float) : Float    { return untyped __call__("pow", b, e); }
 	public static function random() : Float    { return untyped __call__("mt_rand") / __call__("mt_getrandmax"); }
-	public static function isNaN(f) : Bool     { return untyped __call__("is_nan", f); }
-	public static function isFinite(f) : Bool  { return untyped __call__("is_finite", f); }
+	public static function isNaN(f : Float) : Bool     { return untyped __call__("is_nan", f); }
+	public static function isFinite(f : Float) : Bool  { return untyped __call__("is_finite", f); }
 
-	static function __init__() {
+	static function __init__() : Void {
 	 	PI = untyped __php__("M_PI");
 	 	NaN = untyped __php__("acos(1.01)");
 	 	NEGATIVE_INFINITY = untyped __php__("log(0)");

+ 4 - 4
std/php/_std/StringTools.hx

@@ -23,7 +23,7 @@
  * DAMAGE.
  */
 
-class StringTools {
+@:core_api class StringTools {
 
 	public inline static function urlEncode( s : String ) : String untyped {
 		return __call__("rawurlencode", s);
@@ -41,11 +41,11 @@ class StringTools {
 		return untyped __call__("htmlspecialchars_decode", s);
 	}
 
-	public static function startsWith( s : String, start : String ) {
+	public static function startsWith( s : String, start : String ) : Bool {
 		return( s.length >= start.length && s.substr(0,start.length) == start );
 	}
 
-	public static function endsWith( s : String, end : String ) {
+	public static function endsWith( s : String, end : String ) : Bool {
 		var elen = end.length;
 		var slen = s.length;
 		return( slen >= elen && s.substr(slen-elen,elen) == end );
@@ -80,7 +80,7 @@ class StringTools {
 		return untyped __call__("str_replace", sub, by, s);
 	}
 
-	public static function hex( n : Int, ?digits : Int ) {
+	public static function hex( n : Int, ?digits : Int ) : String {
 		var s : String = untyped __call__("dechex", n);
 		if ( digits != null )
 			s = lpad(s, '0', digits);