Opinions / Votes Needed
| From: | Nathan Rixham | Date: | Sat, 17 Jan 2009 17:31:27 +0000 |
| Subject: | Opinions / Votes Needed | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-286550@lists.php.net to get a copy of this message | ||
Afternoon all,
I'd love to get some votes from my fellow developers on the following, and indeed some opinions (especially from those who disagree).
Recently I've been running in to a lot of frustrations with PHP when dealing with Classes and Objects. Personally I strongly feel that these need added in to PHP 6, for multiple reasons.
I don't think the scope of this discussion covers the syntax of any implementation, just if it needs implemented or not.
a: Optional Static Typing
I'm finding an ever increasingly need to be able to staticly type properties, parameters, return types etc (in classes) I know there is type hinting but it's just not enough to do what one needs. Additionally support for staticly typing primatives. Here's an example:
<?php
class Example {
private ClassName $obj; // class typed property
public bool $primativeBool; // primative typed property
// typed returns
public function getObj() ClassName {
return $this->obj;} // already implemented public function setObj(ClassName $obj) {
$this->obj = $obj;} // privative type hint (not implemented) public function setPrimativeBool(bool $primativeBool) {
$this->primativeBool = $primativeBool;} public function someMethod() { // also for variables VariableType $variable = new VariableType(); } } ?> b: Object superclass A base class type which all objects automagically extend, with (if nothing else) a unique id / hashcode for each object (much like the Java Object class). Failing this some form of function to get a unique reference string for any variable. Example <?php $someClassInstance = new SomeClass(); // method on all objects that returns a unique // id for that object $objectId = $someClassInstance->hashCode(); // or by a function $objectId = get_hashcode($someClassInstance); // and for variables $aString = 'some string'; $stringId = get_hashcode($aString); ?> c: Method overloading TBH it's something I could live without, whereas a/b aren't, but it would be an ideal addition to php? <?php class Example { public function someMethod(ClassType $arg0) { } public function someMethod(ClassType $arg0, bool $arg1) { } } ?> Thoughts, Opinions, Votes? would love to hear from you guys on this Regards!