package php
Available on php
Special extern class to support PHP language specifics. Don't use these functions unless you are really sure what you are doing.
staticinlineadd<T>(left:T, right:T):T
Generates $left + $right
for numbers.
staticinlinearray(value:Dynamic):NativeArray
(array)$value
staticarrayDecl<T>(args:Rest<T>):NativeIndexedArray<T>
Syntax.arrayDecl(arg1, arg2, arg3);
Generates native array declaration:
[$arg1, $arg2, $arg3]
staticassocDecl<T>(?arg:Null<T>):NativeAssocArray<Dynamic>
Syntax.assocDecl({field1:'first', field2:2}});
Generates native associative array declaration:
["field1" => "first", "field2" => 2];
This method is not recursive. Accepts object declarations only. That means you can't pass an object stored in a variable to this method like Syntax.assocDecl(someVar)
. Use php.Lib.associativeArrayOfObject(someVar)
instead.
staticinlinebool(value:Dynamic):Bool
(bool)$value
staticcall<T>(object:AsVar<T>, methodName:String, args:Rest<Dynamic>):Dynamic
$object->{$methodName}(<args>)
staticinlineclone<T>(value:T):T
Generates clone $value
.
See also:
staticcoalesce<T>(left:T, right:T):T
$left ?? $right
staticcode(code:String, args:Rest<Dynamic>):Dynamic
Embeds plain php code. php
should be a string literal with php code. It can contain placeholders like {0}
, {1}
which will be replaced with corresponding arguments from args
. E.g.:
Syntax.code("var_dump({0}, {1})", a, b);
will generate
var_dump($a, $b);
staticcodeDeref(code:String, args:Rest<Dynamic>):Dynamic
The same as code()
, but adds dereferencing when required to workaround "cannot use temporary expression in write context" php error.
staticinlineconcat(left:String, right:String):String
$left . $right
staticconstruct<T>(cls:AsVar<Class<T>>, args:Rest<Dynamic>):T
staticconstruct(className:AsVar<String>, args:Rest<Dynamic>):Dynamic
new $className($arg1, ...$argN)
staticinlineequal(left:Dynamic, right:Dynamic):Bool
$left == $right
staticinlineexp<T>(left:T, right:T):T
$left ** $right
staticfield<T>(object:AsVar<T>, fieldName:String):Dynamic
object
staticinlinefloat(value:Dynamic):Float
(float)$value
staticinlineforeach<TCollection, TKey, TValue>(collection:TCollection, body:(TKey, TValue) ‑> Void):Void
Syntax.foreach(collection, function(key, value) trace(key, value));
generates:
foreach($collection as $key => $value) {
trace($key, $value);
}
staticgetField<T>(object:AsVar<T>, fieldName:String):Dynamic
object
staticgetStaticField(className:AsVar<EitherType<Class<Dynamic>, String>>, fieldName:String):Dynamic
className
staticinstanceof<V, C>(value:AsVar<V>, type:AsVar<Class<C>>):Bool
staticinstanceof(value:AsVar<Dynamic>, phpClassName:AsVar<String>):Bool
Generates $value instanceof $phpClassName
. Haxe generates Std.isOfType(value, Type)
calls as $value instanceof Type
automatically where possible. So you may need this only if you have a Class
stored in a variable.
staticinlineint(value:Dynamic):Int
(int)$value
statickeepVar(localVar:Rest<Dynamic>):Void
Don't let compiler to optimize away local var passed to this method.
staticinlinemod(left:Float, right:Float):Int
$left % $right
staticnativeClassName<T>(cls:EitherType<Class<T>, Enum<T>>):String
Generates PHP class name for a provided Haxe class.
trace(Syntax.nativeClassName(php.Web)); // outputs: php\Web
staticinlinenotEqual(left:Dynamic, right:Dynamic):Bool
$left != $right
staticinlineobject(value:Dynamic):StdClass
(object)$value
staticsetField<T>(object:AsVar<T>, fieldName:String, value:Dynamic):Void
object
staticsetStaticField(object:AsVar<EitherType<Class<Dynamic>, String>>, fieldName:String, value:Dynamic):Void
object
staticinlineshortTernary<T>(left:T, right:T):T
$left ?: $right
staticinlinespaceship(left:Dynamic, right:Dynamic):Int
$left <=> $right
staticinlinesplat(args:EitherType<NativeArray, Traversable>):Rest<Dynamic>
Adds ...
operator before args
staticstaticCall(className:AsVar<EitherType<Class<Dynamic>, String>>, methodName:String, args:Rest<Dynamic>):Dynamic
$className::{$methodName}(<args>)
staticinlinestrictEqual(left:Dynamic, right:Dynamic):Bool
$left === $right
staticinlinestrictNotEqual(left:Dynamic, right:Dynamic):Bool
$left !== $right
staticinlinestring(value:Dynamic):String
(string)$value
staticsuppress<T>(expression:T):T
Add errors suppression operator @
before expression
staticinlineunion(left:NativeArray, right:NativeArray):NativeArray
Generates $left + $right
for php arrays.
staticinlinexor(left:Bool, right:Bool):Bool
$left xor $right
staticinlineyield(value:Dynamic):Dynamic
Generates yield $value
.
See also:
staticinlineyieldFrom(value:Dynamic):Dynamic
Generates yield for $value
.
See also:
staticinlineyieldPair(key:Dynamic, value:Dynamic):Dynamic
Generates yield $key => $value
.
See also:
© 2005–2020 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/php/Syntax.html