peachpiecompiler / peachpie

PeachPie - the PHP compiler and runtime for .NET and .NET Core
https://www.peachpie.io
Apache License 2.0
2.33k stars 202 forks source link

How to call c# extension methods in php? #1093

Closed FibonacciFox closed 1 year ago

FibonacciFox commented 1 year ago

Hello, dear developers peachpie. When I call c# extension methods, throws an exception: Error: Call to undefined method. How can I call them from php?

jakubmisek commented 1 year ago

Hi, Extension methods are a C# language feature - PHP does not have extension methods.

In order to use them in PHP, call them through their static class

instead of $obj->extensionMethod() use the static class name: ExtensionMethodClass::extensionMethod( $obj );