Opinions / Votes Needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux