Re: [PHP-DEV] RFC: Protocol Type Hinting

2013-06-27 Thread Bernhard Schussek
(practically, more or less). The tilde conveys that semantic very well. * As you mentioned, brackets are (IMO too) close to generics. Cheers, Bernhard -- Bernhard Schussek Blog: http://webmozarts.com Twitter: http://twitter.com/webmozart 2013/6/25 Anthony Ferrara ircmax...@gmail.com Hey all, I want

Re: [PHP-DEV] property de-referencing

2013-05-02 Thread Bernhard Schussek
2013/5/1 Rasmus Schultz ras...@mindplay.dk One could write a PropertyReference class right now with literally the only difference being the lack of a builtin operator (ie new PropertyReference($obj, 'prop') versus ^$obj-prop): the fact that nobody seems to have done this in a major

Re: [PHP-DEV] [RFC] Alternative typehinting syntax for accessors

2013-01-05 Thread Bernhard Schussek
2013/1/5 Nikita Popov nikita@gmail.com I think that's a very interesting question, thanks for bringing it up. I think a good approach here would be the same one used for function argument typehints, i.e. allow NULL when NULL is specified as the default value. So `public DateTime $date;`

Re: [PHP-DEV] [PHP-DEV [RFC] Property Accessors v1.2

2012-10-14 Thread Bernhard Schussek
Hi Clint, 1) Point taken. 2) The use case can be solved with an object implementing ArrayAccess, but not pragmatically, because then you need a class for *each* bidirectional association. Let me give a short example: Given the class Article with a bidirectional many-to-one relation to Category

Re: [PHP-DEV] [PHP-DEV [RFC] Property Accessors v1.2

2012-10-12 Thread Bernhard Schussek
Hi Clint, I would like to urge you again to consider implementing the array access methods. Without that, this very neat feature becomes essentially unusable for modelling one-to-many, many-to-one and many-to-many object relations, as I tried to explain in the previous topic. Objects and

Re: [PHP-DEV] [RFC] Propety Accessors v1.1

2012-10-10 Thread Bernhard Schussek
Hi Clint, In order to achieve read-only and write-only, we could do something similar to this: /* Explicitly read-only, sub-classes may redefine the getter but may not define a setter */ public $Hours { get() { ... } final private set() {} } This would make the additional keyword

Re: [PHP-DEV] [RFC] Propety Accessors v1.1

2012-10-10 Thread Bernhard Schussek
2012/10/10 Clint Priest cpri...@zerocue.com: While I agree it would be a nice to have it would also be un-necessary. There are already ways to do precisely what is desired here by way of ArrayAccess. class Addresses implements ArrayAccess { offsetSet($offset, $value) { ... }

Re: [PHP-DEV] Generators in PHP

2012-07-26 Thread Bernhard Schussek
I too don't think that a new keyword is necessary for this case. Let's not forget that it is a common practice to document functions with doc blocks, which further helps understanding what it does. /** * @return Generator * @yield string */ function generate() { ... yield $foo; ... }

Re: [PHP-DEV] RFC: Property get/set syntax

2012-07-16 Thread Bernhard Schussek
Hi all, Has array access been considered for properties? I can see a good use for this for cross-referencing objects. class Parent { private $_children = array(); public $children { offsetSet { $value-parent = $this; $this-_children[$key] = $value; } offsetUnset {