summaryrefslogtreecommitdiff
path: root/tests/cpp/main.cpp
diff options
context:
space:
mode:
authorvalmat <ufabiz@gmail.com>2014-03-28 02:34:51 +0600
committervalmat <ufabiz@gmail.com>2014-03-28 02:34:51 +0600
commit7bc500847e3027bb785c5525a21078ff72acc2ab (patch)
tree06e29578cbaf38e328b662c6e4130ad07b055f39 /tests/cpp/main.cpp
parent28152192b85cbe9bf5ea08ebe8c706d12e2e13e5 (diff)
add test: 004-static-funct.phpt (Test class with static function)
Diffstat (limited to 'tests/cpp/main.cpp')
-rw-r--r--tests/cpp/main.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/cpp/main.cpp b/tests/cpp/main.cpp
index 7569a0b..b892b41 100644
--- a/tests/cpp/main.cpp
+++ b/tests/cpp/main.cpp
@@ -56,6 +56,24 @@ extern "C"
extension.add( Php::Class<TestBaseClass::Comparable>("TestBaseClass\\Comparable") );
+ // test static functions
+ //
+ // description of the class so that PHP knows which methods are accessible
+ Php::Class<TestBaseClass::testStaticPubClass> ClassWithStatic("TestBaseClass\\ClassWithStatic");
+ // register the testStaticPubClass::staticMethod to be a static method callable from PHP
+ ClassWithStatic.method("static1", &TestBaseClass::testStaticPubClass::staticMethod);
+ // regular functions have the same signatures as static methods. So nothing forbids you to register a normal function as static method too
+ ClassWithStatic.method("static2", TestBaseClass::testStaticRegFunc);
+ // and even static methods from completely different classes have the same function signature and can thus be registered
+ ClassWithStatic.method("static3", &TestBaseClass::testStaticPrivClass::staticMethod);
+ // add the class to the extension
+ extension.add(std::move(ClassWithStatic));
+ // In fact, because a static method has the same signature
+ // as a regular function, you can also register static
+ // C++ methods as regular global PHP functions
+ extension.add("TestBaseClass\\staticFun1", &TestBaseClass::testStaticPrivClass::staticMethod);
+
+
/**