Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString()

2017-03-11 Thread Fleshgrinder
On 3/10/2017 11:57 AM, Andrey Andreev wrote: > Yes, they're valid string values, but the examples I gave were meant > to show that context can make them predictably invalid, and hence why > strict typing is desirable. I am totally in favor of strict types, but having a union of some type and havin

Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString()

2017-03-11 Thread Andrey Andreev
On Sat, Mar 11, 2017 at 1:39 PM, Fleshgrinder wrote: > On 3/10/2017 11:57 AM, Andrey Andreev wrote: >> Yes, they're valid string values, but the examples I gave were meant >> to show that context can make them predictably invalid, and hence why >> strict typing is desirable. > > I am totally in fa

Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString()

2017-03-11 Thread Rowan Collins
On 11 March 2017 13:23:16 GMT+00:00, Andrey Andreev wrote: >Ironically enough, the following code executes silently: > >$array = ['a', 'b', 'c']; >sort($array, '2234234324'); > >If you don't see the problem with that, I guess it does make "no sense >at all" from your POV. Just agree to dis

Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString()

2017-03-11 Thread Andrey Andreev
On Sat, Mar 11, 2017 at 3:34 PM, Rowan Collins wrote: > On 11 March 2017 13:23:16 GMT+00:00, Andrey Andreev wrote: >>Ironically enough, the following code executes silently: >> >>$array = ['a', 'b', 'c']; >>sort($array, '2234234324'); >> >>If you don't see the problem with that, I guess i

Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString()

2017-03-11 Thread Fleshgrinder
On 3/11/2017 2:53 PM, Andrey Andreev wrote: > I don't disagree with that in general, but strictly rejecting strings > and other non-integer values would alleviate the problem for a > majority of cases; i.e. would solve the 90% problem. > > What I strongly disagree on is that I should be happy with

Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString()

2017-03-11 Thread Andrey Andreev
On Sat, Mar 11, 2017 at 3:57 PM, Fleshgrinder wrote: > On 3/11/2017 2:53 PM, Andrey Andreev wrote: >> I don't disagree with that in general, but strictly rejecting strings >> and other non-integer values would alleviate the problem for a >> majority of cases; i.e. would solve the 90% problem. >> >

Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString()

2017-03-11 Thread Rowan Collins
On 11 March 2017 13:53:10 GMT+00:00, Andrey Andreev wrote: >I don't disagree with that in general, but strictly rejecting strings >and other non-integer values would alleviate the problem for a >majority of cases; i.e. would solve the 90% problem. I guess I just don't see that as 90% at all. The

Re: [PHP-DEV] Type variants

2017-03-11 Thread Michael Vostrikov
> 'Order does not match OrderForCheckout. Reason: ...'. Sorry, this is text for second example) I missed this moment. But I think the idea is clear. For manual call of __match() type casting can be used: $orderForCheckout = (OrderForCheckout)$order; Also this feature can be used for checking e

Re: [PHP-DEV] Type variants

2017-03-11 Thread MichaƂ Brzuchalski
2017-03-11 17:24 GMT+01:00 Michael Vostrikov : > > 'Order does not match OrderForCheckout. Reason: ...'. > > Sorry, this is text for second example) I missed this moment. But I think > the idea is clear. > > > For manual call of __match() type casting can be used: > $orderForCheckout = (OrderForCh

Re: [PHP-DEV] Type variants

2017-03-11 Thread Sherif Ramadan
PHP already has horizontal inheritance. They're called traits. How is this an improvement in anyway? On Sat, Mar 11, 2017 at 1:36 AM, Michael Vostrikov < michael.vostri...@gmail.com> wrote: > Hello. I have an idea which seems rather useful. I would like to know your > opinion, > > Let's say we h

Re: [PHP-DEV] Type variants

2017-03-11 Thread Michael Vostrikov
> Example with Rectangle and Square IMO is an example of bad naming in this case. I used this example because this is known problem of inheritance. Type variants solve this problem. Square is a particular case (variant) of Rectangle. > PHP already has horizontal inheritance. They're called traits

Re: [PHP-DEV] Type variants

2017-03-11 Thread Sherif Ramadan
Yea, but how's that an improvement over using an interface? On Sun, Mar 12, 2017 at 1:38 AM, Michael Vostrikov < michael.vostri...@gmail.com> wrote: > > Example with Rectangle and Square IMO is an example of bad naming in this > case. > > I used this example because this is known problem of inher

Re: [PHP-DEV] Type variants

2017-03-11 Thread Michael Vostrikov
2017-03-12 11:41 GMT+05:00 Sherif Ramadan : > Yea, but how's that an improvement over using an interface? > > How can I check if an order is ready for checkout with interface? The difference is in property values, not in presence of methods.

Re: [PHP-DEV] Type variants

2017-03-11 Thread Sherif Ramadan
You could have an abstract classes implement the interface and extend from the abstract classes. On Sun, Mar 12, 2017 at 1:57 AM, Michael Vostrikov < michael.vostri...@gmail.com> wrote: > 2017-03-12 11:41 GMT+05:00 Sherif Ramadan : > > > Yea, but how's that an improvement over using an interface?

Re: [PHP-DEV] Type variants

2017-03-11 Thread Michael Vostrikov
2017-03-12 12:03 GMT+05:00 Sherif Ramadan : > You could have an abstract classes implement the interface and extend from > the abstract classes. > > Ok, could you give an example, how to check described requirements with interface?

Re: [PHP-DEV] Type variants

2017-03-11 Thread Sherif Ramadan
Which requirements are those exactly? On Sun, Mar 12, 2017 at 3:15 AM, Michael Vostrikov < michael.vostri...@gmail.com> wrote: > 2017-03-12 12:03 GMT+05:00 Sherif Ramadan : > >> You could have an abstract classes implement the interface and extend >> from the abstract classes. >> >> > Ok, could

Re: [PHP-DEV] Type variants

2017-03-11 Thread Michael Vostrikov
2017-03-12 12:19 GMT+05:00 Sherif Ramadan : > Which requirements are those exactly? > An order should have count of products > 0 and date and address filled before checkout procedure.