Fork me on GitHub
Objective-PHP is a port of the Objective-C (or Objective-J runtime to PHP. This adds the language features of Objective-C nestled nicely inside the syntax of Objective-C. Moka is a port of the Apple Cocoa Frameworks (or Cappuccino).

About Protocols in Objective-PHP

A protocol is a mechanism of providing guarantees for objects. Effectively a protocol is adopted by an object (or an object expects another object to adopt a certain protocol) hopefully guaranteeing the existance in that object of certain methods defined by the protocol.

For example a protocol A specifies there should be an instance method mustHaveMe in any class which adopts it

@protocol A
- mustHaveMe;

now if a class Class adopts protocol A it must have a method mustHaveMe somewhere in it or its inheritance chain.

@implementation Class <A>
- (void)mustHaveMe
    echo "I obey!\n";

For a better description see this page.

As in Objective-C, in ObjPHP protocols too are first class objects. They are subclasses of the root object MKObject and Protocol. The actual implementation is an ObjPHP class (so it consists of 3 PHP classes, one for the protocols instance object, one for the class object and one for the meta class object).

For each class that adopts protocols a table is created of protocol names which is checked for conformance at compile time and if the class is missing any methods an exception is thown. Objective-C doesnt produce an error if the protocol is not obeyed so to align Objective-PHP with Objective-C this may change.

Document status: INCOMPLETE for current version.