Search code examples
phpclassmethod-signature

PHP : Declare function signatures in the classes' headings?


For Best Practices - In PHP 5.3+, can we, as for C++, declare function signares and put the bodies in the bottom of it ? If yes, how to make it ?

Example :

<?php
class TheDoor
{
    public $args; // [...]
    private $fields; // [...]

    public function close();
    public function open();
    [...]
    public function close()
    {
        // Your code goes here
    }
}

Thank you by advance.


Solution

  • Nope. The closest you can get, as far as I know, is declaring an interface for the class to implement.