[PHP-DEV] Re: Let's discuss enums!

2015-09-17 Thread Stephen Coakley
On 09/17/2015 06:06 PM, Rowan Collins wrote: Hi All, This has come up in passing a few times recently, but I'm not sure there's ever been a dedicated discussion of it: would it be useful for PHP to have a built-in Enumeration type, and if so, how should it look? Many other languages have enum t

[PHP-DEV] Re: Let's discuss enums!

2015-09-17 Thread Jefferson Gonzalez
On 09/17/2015 08:05 PM, Rowan Collins wrote: I don't think serializing to a name is particularly more inefficient than serializing to an integer - depending on the internal implementation, of course. Or do you mean efficiency in terms of the length of the string produced? Exactly! Lets say you

Re: [PHP-DEV] Let's discuss enums!

2015-09-17 Thread Ben Scholzen
On 18.09.2015 01:06, Rowan Collins wrote: Hi All, This has come up in passing a few times recently, but I'm not sure there's ever been a dedicated discussion of it: would it be useful for PHP to have a built-in Enumeration type, and if so, how should it look? For what it's worth, there's SplEn

Re: [PHP-DEV] Let's discuss enums!

2015-09-17 Thread John Bafford
> On Sep 17, 2015, at 20:15, Bob Weinand wrote: > >> Am 18.09.2015 um 01:56 schrieb Rowan Collins : >> >> On 18/09/2015 00:16, Marcio Almada wrote: >>> A kitten is working on thathttps://wiki.php.net/rfc/enum. Many points >>> on the linked RFC are compatible to the points you raised so it might

Re: [PHP-DEV] Let's discuss enums!

2015-09-17 Thread Bob Weinand
> Am 18.09.2015 um 02:35 schrieb John Bafford : > >> On Sep 17, 2015, at 20:06, Bob Weinand wrote: >> >>> Am 18.09.2015 um 01:52 schrieb John Bafford : >>> >>> If we’re bikeshedding, one feature I would really like to see, with >>> typehinting, is warnings if all cases of an enum aren’t handle

Re: [PHP-DEV] Let's discuss enums!

2015-09-17 Thread Bob Weinand
> Am 18.09.2015 um 02:27 schrieb Ryan Pallas : > > I few questions wrt the rfc: https://wiki.php.net/rfc/enum > >> An enum value is only equal to itself. > I'm not sure I agree. How then do I store the enum into a DB and compare it > after reading? > switch($db->query('select role from user where

Re: [PHP-DEV] Let's discuss enums!

2015-09-17 Thread John Bafford
> On Sep 17, 2015, at 20:06, Bob Weinand wrote: > >> Am 18.09.2015 um 01:52 schrieb John Bafford : >> >> If we’re bikeshedding, one feature I would really like to see, with >> typehinting, is warnings if all cases of an enum aren’t handled in a switch. >> So, for example, given our example We

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Lester Caine
On 18/09/15 00:14, Rowan Collins wrote: > On 17/09/2015 23:45, Lester Caine wrote: >> The 'does not exist' requires that there IS a second field to carry the >> flag that 'MOT' is not required, while simply leaving it out of the >> result set then saves two fields. > > I'm confused - do you mean t

Re: [PHP-DEV] Let's discuss enums!

2015-09-17 Thread Ryan Pallas
I few questions wrt the rfc: https://wiki.php.net/rfc/enum > An enum value is only equal to itself. I'm not sure I agree. How then do I store the enum into a DB and compare it after reading? switch($db->query('select role from user where user_id = 123')->fetch()[0]) { case UserRole::Admin:

Re: [PHP-DEV] Let's discuss enums!

2015-09-17 Thread Bob Weinand
> Am 18.09.2015 um 01:56 schrieb Rowan Collins : > > On 18/09/2015 00:16, Marcio Almada wrote: >> A kitten is working on thathttps://wiki.php.net/rfc/enum. Many points >> on the linked RFC are compatible to the points you raised so it might >> be worth reading before even starting any new proposal

Re: [PHP-DEV] Let's discuss enums!

2015-09-17 Thread Bob Weinand
> Am 18.09.2015 um 01:52 schrieb John Bafford : > > On Sep 17, 2015, at 19:16, Bob Weinand wrote: >> >>> Am 18.09.2015 um 01:06 schrieb Rowan Collins : >>> >>> This has come up in passing a few times recently, but I'm not sure there's >>> ever been a dedicated discussion of it: would it be use

[PHP-DEV] Re: Let's discuss enums!

2015-09-17 Thread Rowan Collins
On 18/09/2015 00:34, user@domain.invalid wrote: Well, how are you supposed to serialize an enum value without some sort of numerical representation or value? Maybe you could serialize it by converting the enum to a string representation of its name but that wouldn't be efficient and also if a d

Re: [PHP-DEV] Let's discuss enums!

2015-09-17 Thread Rowan Collins
On 18/09/2015 00:16, Marcio Almada wrote: A kitten is working on thathttps://wiki.php.net/rfc/enum. Many points on the linked RFC are compatible to the points you raised so it might be worth reading before even starting any new proposal. Aha, I hadn't seen that, should have thought to search th

Re: [PHP-DEV] Let's discuss enums!

2015-09-17 Thread John Bafford
On Sep 17, 2015, at 19:16, Bob Weinand wrote: > >> Am 18.09.2015 um 01:06 schrieb Rowan Collins : >> >> This has come up in passing a few times recently, but I'm not sure there's >> ever been a dedicated discussion of it: would it be useful for PHP to have a >> built-in Enumeration type, and i

[PHP-DEV] Re: Let's discuss enums!

2015-09-17 Thread user
On 09/17/2015 07:06 PM, Rowan Collins wrote: 3) there should be no accessible "value" for a member; the value of Weekdays::SUNDAY is simply Weekdays::SUNDAY, not 0 or 7 or 'SUNDAY' (I'm thinking that internally, each member would be represented as an object pointer, so there's no real benefit to

Re: [PHP-DEV] Let's discuss enums!

2015-09-17 Thread Marcio Almada
Hi, 2015-09-17 20:06 GMT-03:00 Rowan Collins : > Hi All, > > This has come up in passing a few times recently, but I'm not sure there's > ever been a dedicated discussion of it: would it be useful for PHP to have a > built-in Enumeration type, and if so, how should it look? > > Many other language

Re: [PHP-DEV] Let's discuss enums!

2015-09-17 Thread Bob Weinand
> Am 18.09.2015 um 01:06 schrieb Rowan Collins : > > Hi All, > > This has come up in passing a few times recently, but I'm not sure there's > ever been a dedicated discussion of it: would it be useful for PHP to have a > built-in Enumeration type, and if so, how should it look? > > Many other

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
On 17/09/2015 23:45, Lester Caine wrote: The 'does not exist' requires that there IS a second field to carry the flag that 'MOT' is not required, while simply leaving it out of the result set then saves two fields. I'm confused - do you mean that some rows in the result set from the database h

[PHP-DEV] Let's discuss enums!

2015-09-17 Thread Rowan Collins
Hi All, This has come up in passing a few times recently, but I'm not sure there's ever been a dedicated discussion of it: would it be useful for PHP to have a built-in Enumeration type, and if so, how should it look? Many other languages have enum types, with varying functionality. The cent

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Lester Caine
On 17/09/15 23:10, Rowan Collins wrote: > You keep defending your use of NULL, but that is not what needs > defending; it is the proposed use of an unset variable as a "very null" > state which I am questioning. As far as I know, most databases do not > have the notion of "does not exist" in tables

[PHP-DEV] PHP 5.6.14 RC1 is available for testing

2015-09-17 Thread Ferenc Kovacs
Hello everyone, PHP 5.6.14 RC1 was just released and can be downloaded from: http://downloads.php.net/~tyrael/ The Windows binaries are available at http://windows.php.net/qa/ This release contains a number of bugfixes. For the list of bugfixes that you can target in your testing, please refer

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
On 17/09/2015 20:51, Rowan Collins wrote: What would really be handy in a case like this is the ability to create your own null-like values, guaranteed to be distinct from all other values: type hidden extends \php\basetypes\terminal {} type default extends \php\basetypes\terminal {} $checkli

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
On 17/09/2015 22:31, Lester Caine wrote: To paraphrase, your 3 states being communicated from the controller to the view are: a) Do not use this object, even if you want to. EG Vehicle is not old enough to need MOT b) If you want this object, you may create a default one. EG No current MOT fo

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Lester Caine
On 17/09/15 20:51, Rowan Collins wrote: >> exists($checklist) { >>is_null($checklist) { create default/empty object(); } >>else { create populate odbject($checklist); >> } else { >>display code in place of object; >> } > > Thanks, this is an interesting example of how the function coul

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
Lester Caine wrote on 17/09/2015 00:26: If the 'variable' exists but is NULL you create a default element of that name. If the 'variable' does not exist nothing gets created. So exists($checklist) { is_null($checklist) { create default/empty object(); } else { create populate odbject($chec

Re: [PHP-DEV] Make strict mode more strict?

2015-09-17 Thread Anthony Ferrara
Yasuo, On Wed, Sep 16, 2015 at 6:10 PM, Yasuo Ohgaki wrote: > Hi all, > > PHP 7 has strict_types mode for function parameters/return values and > these are binded to certain type strictly. > https://wiki.php.net/rfc/scalar_type_hints_v5 > > Why not make strict_types mode more strict? > The idea i

[PHP-DEV] Benchmark Results for PHP Master 2015-09-17

2015-09-17 Thread lp_benchmark_robot
Results for project php-src-nightly, build date 2015-09-17 05:00:00+03:00 commit: 82712a1eb0caf41772995a08a755e48d82faa463 revision_date: 2015-09-17 01:50:01+02:00 environment:Haswell-EP cpu:Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
Terry Cullen wrote on 17/09/2015 14:09: ​I agree that there is already ways around this issue, but I agree with Bob that there is a hole that exists() would fill. I my world where PHP is the glue between JSON requests and database queries, ​ exists() would be a function I'd use way more the ar

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Terry Cullen
​Hi Rowan,​ On 17 September 2015 at 22:52, Rowan Collins wrote: > Terry Cullen wrote on 17/09/2015 13:41: > >> Here is an example where exists would be useful; >> > > You answered your own request: > > // I should have used property_exists() instead of isset().. wasn't >> expecting a null.. >>

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
Terry Cullen wrote on 17/09/2015 13:41: Here is an example where exists would be useful; You answered your own request: // I should have used property_exists() instead of isset().. wasn't expecting a null.. We already have that function, so that's alright then! :) As I've said several time

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Terry Cullen
Hi, On 17 September 2015 at 19:01, Rowan Collins wrote: > On 17 September 2015 02:17:59 BST, Robert Williams > wrote: > > An unset variable is not null. Rather, it’s > >completely undefined, and PHP yells at you for just that reason if you > >try to access it. Then, it turns around and tries to

[PHP-DEV] PHP 7.0.0RC3 is available

2015-09-17 Thread ab
Hi, The third release candidate for 7.0.0 was just released and can be downloaded from: https://downloads.php.net/~ab/ The Windows binaries are available at http://windows.php.net/qa/ This release contains fixes for 19 reported bugs and over 100 commits with various improvements. It a

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
On 17 September 2015 02:17:59 BST, Robert Williams wrote: > An unset variable is not null. Rather, it’s >completely undefined, and PHP yells at you for just that reason if you >try to access it. Then, it turns around and tries to appease you by >giving you null. I see it as rather the other way

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
On 17 September 2015 01:50:31 BST, Robert Williams wrote: >On Sep 16, 2015, at 14:09, Rowan Collins >wrote: >More common than different variables in different circumstances is the >missing variable. Consider the user who’s setting up an instance of an >application that uses a config file with ba