Skip to content

Attribute DirectCall

Piotr edited this page Dec 8, 2013 · 4 revisions

Targets: Property, Method; AllowMultiple: false

ConfigModuleAttribute is used to decorate property or method with name of PHP method or PHP field that should be used instead of decorated c# property or c# method

Name contains destination method or field followed by attributes

  • no attributes - procedural style PHP function will be used
  • -> or instance - instance method/field will be used
  • :: or static - static method/field will be used
  • $ or field - field will be used instead of method

Map contains sequence of numbers and this separated by comma that can change original method arguments. Map parameter is mostly used for decorating methods. In case of decorating property only empty value or this is allowed.

If ->, :: or $ is used whitespace around are not necessary. Expressions ->$fieldName, -> $ fieldName or instace field fieldName have the same meaning.

###Example for instance property###

Assume original c# code int a = someObject.SomeProperty and SomeProperty is decorated by DirectCallAttribute

  • decoration DirectCall("MethodName") gives translation $a = MethodName()

  • decoration DirectCall("->MethodName") gives translation $a = $someObject->MethodName()

  • decoration DirectCall("MethodName", "this") gives translation $a = MethodName($someObject). String.Length is decorated this way using DirectCall("mb_strlen", "this")

  • decoration DirectCall("->$FieldName") gives translation $a = $someObject->FieldName

###For method###

Assume original c# code int result = someObject.someMethod(a, b, c)

  • decoration DirectCall("somePhpFunction") gives translation $result = somePhpFunction($a, $b, $c)

  • decoration DirectCall("->somePhpFunction") gives translation $result = $someObject->somePhpFunction($a, $b, $c)

  • decoration DirectCall("somePhpFunction", "0,1,this,2") gives translation $result = somePhpFunction($a, $b, $someObject, $c)

Clone this wiki locally