On Dec 22, 2011, at 10:11 AM, Dmitri Snytkine wrote:

> I think the return type hinting really depends on variable type hinting. 
> A simple example whould bea typical getter function
> 
> public function \Customer getCustomer(){
>  return $this->customer;
> }

The actual syntax would be: 

public \Customer getCustomer()

> 
> If the $customer instance variable is not declared with the type Customer
> then first of all IDE will not be able to spot an error, second compiler may
> have a slighly harder time of detecting a mismatch.

This isn't a compile time feature.  The validation happens at runtime.  Many 
IDEs actually use PHP executables to detect syntax errors only.  In terms of 
code flow, they'll still need to rely on Doc comments and lexical analysis.

> 
> I really believe that variable type hinting should be worked on at the same
> time or even before the type hinting for returns.
> 
> But it's not up to me of cause, just adding my thoughts to the discussion of
> this topic. I think this is a very important topic by the way.
> 
> Dmitri Snytkine
> Web Developer
> Ultra Logistics, Inc.
> Phone: (888) 220-4640 x 2097
> Fax: (888) 795-6642
> E-Mail: dsnytk...@ultralogistics.com
> Web: www.ultralogistics.com
> 
> "A Top 100 Logistics I.T. Provider in 2011"
> 
> 
> -----Original Message-----
> From: Nikita Popov [mailto:nikita....@googlemail.com] 
> Sent: Thursday, December 22, 2011 10:02 AM
> To: Dmitri Snytkine
> Cc: Alain Williams; internals@lists.php.net
> Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC
> 
> Could we maybe keep this discussion contained to return value type
> hints please? Optional variable type hinting is a completely different
> topic that would require a separate RFC and implementation. If you are
> interested in this you can propose a RFC for this.
> 
> Nikita
> 
> On Thu, Dec 22, 2011 at 3:59 PM, Dmitri Snytkine
> <dsnytk...@ultralogistics.com> wrote:
>> I never said to make it mandatory, only to make it available. Just like
> the
>> type hinting of function call is optional but not mandatory, which is a
> big
>> advantage over Java in my opinion.
>> After all, if you make return type hinting mandatory, it would break 100%
> of
>> all existing php scripts.
>> 
>> To clarify I am asking to make type hinting for variable declaration an
>> available option.
>> 
>> Dmitri Snytkine
>> Web Developer
>> Ultra Logistics, Inc.
>> Phone: (888) 220-4640 x 2097
>> Fax: (888) 795-6642
>> E-Mail: dsnytk...@ultralogistics.com
>> Web: www.ultralogistics.com
>> 
>> "A Top 100 Logistics I.T. Provider in 2011"
>> 
>> 
>> -----Original Message-----
>> From: Alain Williams [mailto:a...@phcomp.co.uk]
>> Sent: Thursday, December 22, 2011 9:52 AM
>> To: internals@lists.php.net
>> Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC
>> 
>> On Thu, Dec 22, 2011 at 03:33:40PM +0100, Sebastian Krebs wrote:
>> 
>>>> private \ArrayObject $customers;
>>>> 
>>> 
>>> Once more "Why is PHP not Java?"
>> 
>> That comment confuses matters. People use PHP for all sorts of reasons,
> the
>> desire to tighten up in some places, on some occasions, should not be
>> treated
>> with derision.
>> 
>> Tighter declarations, or any declarations at all, would not be mandatory.
> It
>> would
>> be something that some projects might want to do. It would be nice if this
>> could be
>> done on a module but module basis ... eg the implementors of a class
> library
>> might
>> want to be really strict while allowing the class users to not be strict.
>> 
>> Just because Java has a feature that you appear to not like, does not mean
>> that
>> others might not want it in some circumstances.
>> 
>> --
>> Alain Williams
>> Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT
>> Lecturer.
>> +44 (0) 787 668 0256  http://www.phcomp.co.uk/
>> Parliament Hill Computers Ltd. Registration Information:
>> http://www.phcomp.co.uk/contact.php
>> #include <std_disclaimer.h>
>> 
>> --
>> PHP Internals - PHP Runtime Development Mailing List
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
>> --
>> PHP Internals - PHP Runtime Development Mailing List
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
> 
> 
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to