From 31c892ce1af0664edb48a64c8727bd71d1380555 Mon Sep 17 00:00:00 2001 From: Dreamsxin Date: Thu, 4 Jun 2015 14:45:32 +0800 Subject: Allow interfaces define static methods --- include/interface.h | 16 ++++++++++++++++ zend/classimpl.h | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/interface.h b/include/interface.h index ecb011e..5b15016 100644 --- a/include/interface.h +++ b/include/interface.h @@ -42,6 +42,22 @@ public: return *this; } + /** + * Add a - of course abstract - method to the interface + * @param name Name of the method + * @param flags Optional flags + * @param arguments Optional description of the arguments + * @return Interface Same object to allow chaining + */ + Interface &method(const char *name, int flags, const Arguments &arguments = {}) + { + // call base + ClassBase::method(name, flags, arguments); + + // return self + return *this; + } + /** * Extends exisiting PHP interface * diff --git a/zend/classimpl.h b/zend/classimpl.h index 5d0ab60..bd385be 100644 --- a/zend/classimpl.h +++ b/zend/classimpl.h @@ -414,7 +414,7 @@ public: * @param flags Optional flags (like public or protected) * @param args Description of the supported arguments */ - void method(const char *name, int flags=0, const Arguments &args = {}) { _methods.push_back(std::make_shared(name, (flags & (MethodModifiers | Static)) | Abstract , args)); } + void method(const char *name, int flags=0, const Arguments &args = {}) { _methods.push_back(std::make_shared(name, (flags & (MethodModifiers | Static | Abstract)) , args)); } /** * Add a property to the class -- cgit v1.2.3