When Im talking about something like this would come in handy
obviously doesnt work! The paramter null could be added, to get
desired result but to be programmatically correct:
class MyOverload{
function __construct($Foo) {
$this->Foo = $Foo;
}
// overload the constructor
function __construct(String $Foo, String $Bar){
$this->Foo = $Foo;
$this->Bar = $Bar;
}
public function doSomething(){
if($this->Foo != null && $this->Bar == null){
return $this->Foo . " needs a partner";
// do something with Foo
}elseif($this->Foo != null && $this->Bar != null){
return $this->Foo . " and " . $this->Bar . " are partners"; //do
something with Foo and Bar
}
}
private $Foo;
private $Bar;
}
$obj = new MyOverload("Mary");
print $obj->doSomething();
----- Original Message -----
From: "Hartmut Holzgraefe" <[EMAIL PROTECTED]>
To: "Jakes Potgieter" <[EMAIL PROTECTED]>
Cc: "Stephan Schmidt" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, February 27, 2004 4:20 PM
Subject: Re: [PHP-DEV] stdClass
> Jakes Potgieter wrote:
> > It would be nice to have a base class to inherit some special
> > methods as we do in Java.
>
> could you name which ones you think of?
>
> being out of the JAVA camp for several years know i no longer
> know all java.object methods and properties by heart, but
> PHP mechanisms like __sleep()/__wakeup(), __toString() and
> the introspection related functions like get_class() and
> friends should provide comparable behaviour ...
>
> (IMHO the fact that any object in JAVA can be casted down
> to java.object is not that clever after all, and part of it
> is only due to the fact that there is no other way to have
> portable container classes, which is now finally solved
> with generics)
>
> > The same as method overloading,
> > one of the most important aspects missing in PHP5 and the
> > new object model.
>
> due to the feature of optional parameters you may end up with
> more than one overloaded function matching a call signature,
> due to the fact that argument types in a function call
> are not known at compile time signature matching would have
> to happen at runtime,
> and the language syntax would need to be extended to add
> parameter type specifiers to function parameter declarations
> (ok, we already have this one for interfaces ...)
>
> --
> Hartmut Holzgraefe <[EMAIL PROTECTED]>
>
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php