Declaring purely static classes [Was Re: [PHP-DEV] RFC: Expectations]

From: Date: Mon, 21 Oct 2013 08:29:17 +0000
Subject: Declaring purely static classes [Was Re: [PHP-DEV] RFC: Expectations]
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-69722@lists.php.net to get a copy of this message
Matthew Leverton wrote (on 21/10/2013):
final/abstract (although PHP doesn't allow that combo for some reason)
Final means "cannot be sub-classed", abstract means "must be sub-classed"; the combination would make no sense. Specifically, it would allow completely illogical code like "final abstract class Foo { abstract public function some_method(); }" Incidentally, Java doesn't allow this combination either; this isn't PHP being picky. The logical declaration for a class that can only be used statically would be "static class Foo { ... }". The combination "abstract static" also makes sense (for a static class with missing method bodies). There's an ancient RFC proposing that here, but it seems it didn't get anywhere much: https://wiki.php.net/rfc/static-classes Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#69722) next »