Special extern class to support PHP language specifics. Don't use these functions unless you are really sure what you are doing.

Static methods

staticinlineadd<T>(left:T, right:T):T

Generates $left + $right for numbers.

staticinlinearray(value:Dynamic):NativeArray

Generates (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

Generates (bool)$value

staticcall<T>(object:AsVar<T>, methodName:String, args:Rest<Dynamic>):Dynamic

Generates a call to instance method: $object->{$methodName}(<args>)

staticinlineclone<T>(value:T):T

staticcoalesce<T>(left:T, right:T):T

Generates $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

Generates $left . $right

staticconstruct<T>(cls:AsVar<Class<T>>, args:Rest<Dynamic>):T

staticconstruct(className:AsVar<String>, args:Rest<Dynamic>):Dynamic

Generates new $className($arg1, ...$argN)

staticcustomArrayDecl<T>(decl:Dynamic):NativeArray

Syntax.customArrayDecl([v1 => v2, v3 => v4]);

Generates native array declaration:

[$v1 => $v2, $v3 => $v4]

staticinlineequal(left:Dynamic, right:Dynamic):Bool

Generates $left == $right

staticinlineexp<T>(left:T, right:T):T

Generates $left ** $right

staticfield<T>(object:AsVar<T>, fieldName:String):Dynamic

Generates instance field access for reading on object

staticinlinefloat(value:Dynamic):Float

Generates (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

Deprecated: "php.Syntax.getField() is deprecated. Use php.Syntax.field() instead."

Generates instance field access for reading on object

staticgetStaticField(className:AsVar<EitherType<Class<Dynamic>, String>>, fieldName:String):Dynamic

Generates static field access for reading on 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

Generates (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

Generates $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

Generates $left != $right

staticinlineobject(value:Dynamic):StdClass

Generates (object)$value

staticsetField<T>(object:AsVar<T>, fieldName:String, value:Dynamic):Void

Generates instance field access for writing on object

staticsetStaticField(object:AsVar<EitherType<Class<Dynamic>, String>>, fieldName:String, value:Dynamic):Void

Generates static field access for writing on object

staticinlineshortTernary<T>(left:T, right:T):T

Generates $left ?: $right

staticinlinespaceship(left:Dynamic, right:Dynamic):Int

Generates $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

Generates a call to static method: $className::{$methodName}(<args>)

staticinlinestrictEqual(left:Dynamic, right:Dynamic):Bool

Generates $left === $right

staticinlinestrictNotEqual(left:Dynamic, right:Dynamic):Bool

Generates $left !== $right

staticinlinestring(value:Dynamic):String

Generates (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

Generates $left xor $right

staticinlineyield(value:Dynamic):Dynamic

staticinlineyieldFrom(value:Dynamic):Dynamic

staticinlineyieldPair(key:Dynamic, value:Dynamic):Dynamic

Generates yield $key => $value.

See also: