Browse Source

Merge pull request #4225 from markknol/patch-2

Php additional documentation
Simon Krajewski 10 years ago
parent
commit
a595b0406c
2 changed files with 31 additions and 18 deletions
  1. 17 5
      std/php/Lib.hx
  2. 14 13
      std/php/Web.hx

+ 17 - 5
std/php/Lib.hx

@@ -30,32 +30,41 @@ class Lib {
 	}
 
 	/**
-		Print the specified value on the default output followed by a newline character.
+		Print the specified value on the default output followed by 
+		a newline character.
 	**/
 	public static function println( v : Dynamic ) : Void {
 		print(v);
 		print("\n");
 	}
 
+	/**
+		Displays structured information about one or more expressions 
+		that includes its type and value. Arrays and objects are 
+		explored recursively with values indented to show structure.
+	*/
 	public static function dump(v : Dynamic) : Void {
 		untyped __call__("var_dump", v);
 	}
 
 	/**
-		Serialize using native PHP serialization. This will return a Binary string that can be
-		stored for long term usage.
+		Serialize using native PHP serialization. This will return a binary 
+		`String` that can be stored for long term usage.
 	**/
 	public static function serialize( v : Dynamic ) : String {
 		return untyped __call__("serialize", v);
 	}
 
 	/**
-		Unserialize a string using native PHP serialization. See [serialize].
+		Unserialize a `String` using native PHP serialization. See `php.Lib.serialize()`.
 	**/
 	public static function unserialize( s : String ) : Dynamic {
 		return untyped __call__("unserialize", s);
 	}
 
+	/**
+		Find out whether an extension is loaded.
+	*/
 	public static function extensionLoaded(name : String) {
 		return untyped __call__("extension_loaded", name);
 	}
@@ -64,6 +73,9 @@ class Lib {
 		return untyped __php__("(0 == strncasecmp(PHP_SAPI, 'cli', 3))");
 	}
 
+	/**
+		Output file content from the given file name.
+	*/
 	public static function printFile(file : String) {
 		return untyped __call__("fpassthru", __call__("fopen", file,  "r"));
 	}
@@ -179,4 +191,4 @@ class Lib {
  		}
  ");
  	}
-}
+}

+ 14 - 13
std/php/Web.hx

@@ -57,8 +57,8 @@ class Web {
 
 	/**
 		Returns an Array of Strings built using GET / POST values.
-		If you have in your URL the parameters [a[]=foo;a[]=hello;a[5]=bar;a[3]=baz] then
-		[php.Web.getParamValues("a")] will return [["foo","hello",null,"baz",null,"bar"]]
+		If you have in your URL the parameters `a[]=foo;a[]=hello;a[5]=bar;a[3]=baz` then
+		`php.Web.getParamValues("a")` will return `["foo","hello",null,"baz",null,"bar"]`.
 	**/
 	public static function getParamValues( param : String ) : Array<String> {
 		var reg = new EReg("^"+param+"(\\[|%5B)([0-9]*?)(\\]|%5D)=(.*?)$", "");
@@ -97,7 +97,7 @@ class Web {
 	}
 
 	/**
-		Returns the local server host name
+		Returns the local server host name.
 	**/
 	public static inline function getHostName() : String {
 		return untyped __php__("$_SERVER['SERVER_NAME']");
@@ -111,7 +111,7 @@ class Web {
 	}
 
 	/**
-		Returns the original request URL (before any server internal redirections)
+		Returns the original request URL (before any server internal redirections).
 	**/
 	public static function getURI() : String {
 		var s : String = untyped __php__("$_SERVER['REQUEST_URI']");
@@ -119,7 +119,7 @@ class Web {
 	}
 
 	/**
-		Tell the client to redirect to the given url ("Location" header)
+		Tell the client to redirect to the given url ("Location" header).
 	**/
 	public static function redirect( url : String ) {
 		untyped __call__('header', "Location: " + url);
@@ -134,7 +134,7 @@ class Web {
 	}
 
 	/**
-		Set the HTTP return code. Same remark as setHeader.
+		Set the HTTP return code. Same remark as `php.Web.setHeader()`.
 		See status code explanation here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
 	**/
 	public static function setReturnCode( r : Int ) {
@@ -220,7 +220,7 @@ class Web {
 	}
 
 	/**
-		Returns all the GET parameters String
+		Returns all the GET parameters `String`
 	**/
 	public static function getParamsString() : String {
 		if(untyped __call__("isset", __var__("_SERVER", "QUERY_STRING")))
@@ -234,8 +234,8 @@ class Web {
 		being application/x-www-form-urlencoded and is stored into
 		the getParams hashtable. POST Data is maximimized to 256K
 		unless the content type is multipart/form-data. In that
-		case, you will have to use [getMultipart] or [parseMultipart]
-		methods.
+		case, you will have to use `php.Web.getMultipart()` or
+		`php.Web.parseMultipart()` methods.
 	**/
 	public static function getPostData() {
 		var h = untyped __call__("fopen", "php://input", "r");
@@ -253,7 +253,8 @@ class Web {
 
 	/**
 		Returns an hashtable of all Cookies sent by the client.
-		Modifying the hashtable will not modify the cookie, use setCookie instead.
+		Modifying the hashtable will not modify the cookie, use `php.Web.setCookie()` 
+		instead.
 	**/
 	public static function getCookies():Map<String,String> {
 		return Lib.hashOfAssociativeArray(untyped __php__("$_COOKIE"));
@@ -261,7 +262,7 @@ class Web {
 
 
 	/**
-		Set a Cookie value in the HTTP headers. Same remark as setHeader.
+		Set a Cookie value in the HTTP headers. Same remark as `php.Web.setHeader()`.
 	**/
 	public static function setCookie( key : String, value : String, ?expire: Date, ?domain: String, ?path: String, ?secure: Bool, ?httpOnly: Bool ) {
 		var t = expire == null ? 0 : Std.int(expire.getTime()/1000.0);
@@ -316,9 +317,9 @@ class Web {
 	}
 
 	/**
-		Parse the multipart data. Call [onPart] when a new part is found
+		Parse the multipart data. Call `onPart` when a new part is found
 		with the part name and the filename if present
-		and [onData] when some part data is readed. You can this way
+		and `onData` when some part data is readed. You can this way
 		directly save the data on hard drive in the case of a file upload.
 	**/
 	public static function parseMultipart( onPart : String -> String -> Void, onData : Bytes -> Int -> Int -> Void ) : Void {