Hi,
I know the discussion is about scalar type hints. But what is with a
object type hint as base for all objects?
What is the next step to get type hinting in the next PHP release,
regardless of whether strict or weak?
Best regards,
Christian
Hi!
I know the discussion is about scalar type hints. But what is with a
object type hint as base for all objects?
When it makes sense to accept any object, regardless of the class, but
not other types? I wonder if it's really a common use-case.
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
Am 17.06.2010 21:14, schrieb Stas Malyshev:
Hi!
I know the discussion is about scalar type hints. But what is with a
object type hint as base for all objects?When it makes sense to accept any object, regardless of the class, but
not other types? I wonder if it's really a common use-case.
My view layer accepts only presentation model objects. So every object
with public properties can be passed to the the view.
Hi!
I know the discussion is about scalar type hints. But what is with a
object type hint as base for all objects?When it makes sense to accept any object, regardless of the class, but not other types? I wonder if it's really a common use-case.
Its useful in some patterns. For example suppose you have a pattern where a class wraps another class. The wrapped class could be any class if you're modify the behaviour of some default methods (say doing something like a decorator pattern). Having a type hint that recognises object vs non objects is useful.
Melanie
Hi!
I know the discussion is about scalar type hints. But what is with a
object type hint as base for all objects?When it makes sense to accept any object, regardless of the class, but not other types? I wonder if it's really a common use-case.
Its useful in some patterns. For example suppose you have a pattern where a class wraps another class. The wrapped class could be any class if you're modify the behaviour of some default methods (say doing something like a decorator pattern). Having a type hint that recognises object vs non objects is useful.
isnt this what interfaces are for?
regards,
Lukas Kahwe Smith
mls@pooteeweet.org
On Fri, 18 Jun 2010 16:28:31 +0200, Lukas Kahwe Smith mls@pooteeweet.org
wrote:
Hi!
I know the discussion is about scalar type hints. But what is with a
object type hint as base for all objects?When it makes sense to accept any object, regardless of the class, but
not other types? I wonder if it's really a common use-case.Its useful in some patterns. For example suppose you have a pattern
where a class wraps another class. The wrapped class could be any
class if you're modify the behaviour of some default methods (say doing
something like a decorator pattern). Having a type hint that
recognises
object vs non objects is useful.isnt this what interfaces are for?
regards,
Lukas Kahwe Smith
mls@pooteeweet.org
Sure, you can create an empty interface for this scenario but only for
self defined classes. All PHP classes can't used with this interface.
On Fri, 18 Jun 2010 16:28:31 +0200, Lukas Kahwe Smith mls@pooteeweet.org
wrote:Hi!
I know the discussion is about scalar type hints. But what is with a
object type hint as base for all objects?When it makes sense to accept any object, regardless of the class, but
not other types? I wonder if it's really a common use-case.Its useful in some patterns. For example suppose you have a pattern
where a class wraps another class. The wrapped class could be any
class if you're modify the behaviour of some default methods (say doing
something like a decorator pattern). Having a type hint that
recognises
object vs non objects is useful.isnt this what interfaces are for?
regards,
Lukas Kahwe Smith
mls@pooteeweet.orgSure, you can create an empty interface for this scenario but only for
self defined classes. All PHP classes can't used with this interface.
and you seriously need type hints for this use case?
regards,
Lukas Kahwe Smith
mls@pooteeweet.org
Hi!
I know the discussion is about scalar type hints. But what is with a
object type hint as base for all objects?When it makes sense to accept any object, regardless of the class, but not other types? I wonder if it's really a common use-case.
Its useful in some patterns. For example suppose you have a pattern where a class wraps another class. The wrapped class could be any class if you're modify the behaviour of some default methods (say doing something like a decorator pattern). Having a type hint that recognises object vs non objects is useful.
Melanie
--
class::method(object $instance)
would certainly be useful.
Could this not be solved by internally extending all userland classes
(and whilst we are at this why not all internal classes) from a PHP
supplied empty class? Maybe stdClass?
scalar, array, class, interface, untyped class.
--
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling