subreddit
stringclasses
7 values
author
stringlengths
3
20
id
stringlengths
5
7
content
stringlengths
67
30.4k
score
int64
0
140k
lolphp
ajmarks
cds2t3s
<|soss|><|sot|>Some useful functions from the PHP standard library<|eot|><|sost|>* http://www.php.net/manual/en/function.jewishtojd.php * http://www.php.net/manual/en/function.easter-date.php * http://www.php.net/manual/en/function.easter-days.php <|eost|><|sor|>Of course by "standard library" you mean "built into the language". Because PHP doesn't believe in modules or namespaces.<|eor|><|sor|>This simply isn't true. PHP has had extensions since like forever. Yes, many of these come bundled with the core source code and are enabled by default, but there's many more which are optional or available via PECL. For additional libraries, PEAR has been around since long before Composer. PHP also has namespaces built-in now. We saw many many built-in libraries being written primarily in OO-space (altho many do have functional equivalents), and I suspect we'll see new additions being written within namespaces. However, PHP also considers backwards compatibility more important than moving things about and renaming them "just because". So it's likely to be some time before you see anything being moved out of the global namespace. While this does mean that inconsistencies persist, it also means that I can (and do on a frighteningly frequent basis still) take code written for PHP 4.4 or 5.1 and get it running on PHP 5.4 in next to no time (and I've done the reverse too). In the commercial world this is a massive advantage and means that we can concentrate on primarily writing new code, rather than having to spend lots of time upgrading old code. It also allows us to keep the live environments up-to-date without having to worry that old code is going to break (too much).<|eor|><|sor|>~~To be fair, Namespaces weren't added until last year.~~ As with a lot of things that PHP defenders like to bring up, the fact that the language is only NOW tacking on support for standard language features like Namespaces and Mixins shows how far behind it lags. <|eor|><|sor|>PHP: the programming language for people who never took CS.<|eor|><|eoss|><|endoftext|>
22
lolphp
hex_m_hell
cdsese7
<|soss|><|sot|>Some useful functions from the PHP standard library<|eot|><|sost|>* http://www.php.net/manual/en/function.jewishtojd.php * http://www.php.net/manual/en/function.easter-date.php * http://www.php.net/manual/en/function.easter-days.php <|eost|><|sor|>Of course by "standard library" you mean "built into the language". Because PHP doesn't believe in modules or namespaces.<|eor|><|sor|>This simply isn't true. PHP has had extensions since like forever. Yes, many of these come bundled with the core source code and are enabled by default, but there's many more which are optional or available via PECL. For additional libraries, PEAR has been around since long before Composer. PHP also has namespaces built-in now. We saw many many built-in libraries being written primarily in OO-space (altho many do have functional equivalents), and I suspect we'll see new additions being written within namespaces. However, PHP also considers backwards compatibility more important than moving things about and renaming them "just because". So it's likely to be some time before you see anything being moved out of the global namespace. While this does mean that inconsistencies persist, it also means that I can (and do on a frighteningly frequent basis still) take code written for PHP 4.4 or 5.1 and get it running on PHP 5.4 in next to no time (and I've done the reverse too). In the commercial world this is a massive advantage and means that we can concentrate on primarily writing new code, rather than having to spend lots of time upgrading old code. It also allows us to keep the live environments up-to-date without having to worry that old code is going to break (too much).<|eor|><|sor|>~~To be fair, Namespaces weren't added until last year.~~ As with a lot of things that PHP defenders like to bring up, the fact that the language is only NOW tacking on support for standard language features like Namespaces and Mixins shows how far behind it lags. <|eor|><|sor|>PHP: the programming language for people who never took CS.<|eor|><|sor|>Come on now, this implies that you have to understand CS to know not to use PHP and that's just not the case. That's like saying you have to have to have taken psychology to know the guy who walks down the street flailing his arms and shouting obscenities randomly isn't someone you should ask in to your apartment for dinner.<|eor|><|eoss|><|endoftext|>
21
lolphp
barubary
cdrwi76
<|soss|><|sot|>Some useful functions from the PHP standard library<|eot|><|sost|>* http://www.php.net/manual/en/function.jewishtojd.php * http://www.php.net/manual/en/function.easter-date.php * http://www.php.net/manual/en/function.easter-days.php <|eost|><|sor|>Of course by "standard library" you mean "built into the language". Because PHP doesn't believe in modules or namespaces.<|eor|><|eoss|><|endoftext|>
16
lolphp
scshunt
cdrvr2w
<|soss|><|sot|>Some useful functions from the PHP standard library<|eot|><|sost|>* http://www.php.net/manual/en/function.jewishtojd.php * http://www.php.net/manual/en/function.easter-date.php * http://www.php.net/manual/en/function.easter-days.php <|eost|><|sor|>I like that there is a function to convert from Julian to Jewish but not from Gregorian.<|eor|><|eoss|><|endoftext|>
13
lolphp
cfreak2399
cds5qy9
<|soss|><|sot|>Some useful functions from the PHP standard library<|eot|><|sost|>* http://www.php.net/manual/en/function.jewishtojd.php * http://www.php.net/manual/en/function.easter-date.php * http://www.php.net/manual/en/function.easter-days.php <|eost|><|sor|>Of course by "standard library" you mean "built into the language". Because PHP doesn't believe in modules or namespaces.<|eor|><|sor|>This simply isn't true. PHP has had extensions since like forever. Yes, many of these come bundled with the core source code and are enabled by default, but there's many more which are optional or available via PECL. For additional libraries, PEAR has been around since long before Composer. PHP also has namespaces built-in now. We saw many many built-in libraries being written primarily in OO-space (altho many do have functional equivalents), and I suspect we'll see new additions being written within namespaces. However, PHP also considers backwards compatibility more important than moving things about and renaming them "just because". So it's likely to be some time before you see anything being moved out of the global namespace. While this does mean that inconsistencies persist, it also means that I can (and do on a frighteningly frequent basis still) take code written for PHP 4.4 or 5.1 and get it running on PHP 5.4 in next to no time (and I've done the reverse too). In the commercial world this is a massive advantage and means that we can concentrate on primarily writing new code, rather than having to spend lots of time upgrading old code. It also allows us to keep the live environments up-to-date without having to worry that old code is going to break (too much).<|eor|><|sor|>1. Extensions - that helpfully pollute the main namespace with new functions. 2. PEAR is a nice idea that never really caught on. It isn't the go-to place to get modules. There's no easy way to install PEAR modules without access to the command line (which you almost never have in shared hosting) and most of the code is woefully untested and undocumented. For all the faults of Perl, CPAN is something they got right (automated tests!) and PEAR pales in comparison. 3. yes it has namespaces which are just now available most places. Then they hampered them with ridiculous syntax and didn't fix the core problem by moving a bunch of extensions in to namespaces. Its like they finally listened to everyone complaining about namespaces and bolted on something half-assed. 4. Backward compatibility is nice but the core problems in PHP create bad code and bad programmers. Besides there are better ways to deal with things that really need to be fixed. Give lots of warnings about features being removed, create something like virtual environments (like Python) that make it easy to run multiple versions or "from future import" ... (also from Python). Besides, the PHP devs haven't always worried about backwards compatibility. They changed the way pass by reference worked between 5.0 and 5.1 (a minor version!). I recall that creating all sorts of headaches. <|eor|><|eoss|><|endoftext|>
13
lolphp
vytah
cdsgt7p
<|soss|><|sot|>Some useful functions from the PHP standard library<|eot|><|sost|>* http://www.php.net/manual/en/function.jewishtojd.php * http://www.php.net/manual/en/function.easter-date.php * http://www.php.net/manual/en/function.easter-days.php <|eost|><|sor|>I find these more useful: * [gzgetss](http://www.php.net/manual/en/function.gzgetss.php) * [JDToFrench](http://www.php.net/manual/en/function.jdtofrench.php) * [hebrevc](http://www.php.net/manual/en/function.hebrevc.php) <|eor|><|eoss|><|endoftext|>
10
lolphp
suspiciously_calm
cdrykby
<|soss|><|sot|>Some useful functions from the PHP standard library<|eot|><|sost|>* http://www.php.net/manual/en/function.jewishtojd.php * http://www.php.net/manual/en/function.easter-date.php * http://www.php.net/manual/en/function.easter-days.php <|eost|><|sor|>As an aside, I just love the consistent naming... * JDToJulian * jdtounix * cal_to_jd ...especially when you consider that function names are case-insensitive, so jdtounix _could_ in fact be changed to JDToUnix in the docs with nothing lost in terms of backwards compatibility.<|eor|><|sor|>[function names are case-insensitive; variables are not](http://www.valvetime.net/attachments/angry-desk-flip-png.23602/)<|eor|><|eoss|><|endoftext|>
9
lolphp
AllenJB83
cdryx3o
<|soss|><|sot|>Some useful functions from the PHP standard library<|eot|><|sost|>* http://www.php.net/manual/en/function.jewishtojd.php * http://www.php.net/manual/en/function.easter-date.php * http://www.php.net/manual/en/function.easter-days.php <|eost|><|sor|>Of course by "standard library" you mean "built into the language". Because PHP doesn't believe in modules or namespaces.<|eor|><|sor|>This simply isn't true. PHP has had extensions since like forever. Yes, many of these come bundled with the core source code and are enabled by default, but there's many more which are optional or available via PECL. For additional libraries, PEAR has been around since long before Composer. PHP also has namespaces built-in now. We saw many many built-in libraries being written primarily in OO-space (altho many do have functional equivalents), and I suspect we'll see new additions being written within namespaces. However, PHP also considers backwards compatibility more important than moving things about and renaming them "just because". So it's likely to be some time before you see anything being moved out of the global namespace. While this does mean that inconsistencies persist, it also means that I can (and do on a frighteningly frequent basis still) take code written for PHP 4.4 or 5.1 and get it running on PHP 5.4 in next to no time (and I've done the reverse too). In the commercial world this is a massive advantage and means that we can concentrate on primarily writing new code, rather than having to spend lots of time upgrading old code. It also allows us to keep the live environments up-to-date without having to worry that old code is going to break (too much).<|eor|><|eoss|><|endoftext|>
9
lolphp
00kyle00
cdtoj8t
<|soss|><|sot|>Some useful functions from the PHP standard library<|eot|><|sost|>* http://www.php.net/manual/en/function.jewishtojd.php * http://www.php.net/manual/en/function.easter-date.php * http://www.php.net/manual/en/function.easter-days.php <|eost|><|sor|>As an aside, I just love the consistent naming... * JDToJulian * jdtounix * cal_to_jd ...especially when you consider that function names are case-insensitive, so jdtounix _could_ in fact be changed to JDToUnix in the docs with nothing lost in terms of backwards compatibility.<|eor|><|sor|>PHP is *not* case insensitive, it is case insensitive with respect to the current locale. Which leads to bugs like [this](https://bugs.php.net/bug.php?id=18556), where changing the locale can break php.<|eor|><|sor|>I don't even.<|eor|><|eoss|><|endoftext|>
9
lolphp
barubary
cdsdq08
<|soss|><|sot|>Some useful functions from the PHP standard library<|eot|><|sost|>* http://www.php.net/manual/en/function.jewishtojd.php * http://www.php.net/manual/en/function.easter-date.php * http://www.php.net/manual/en/function.easter-days.php <|eost|><|sor|>Of course by "standard library" you mean "built into the language". Because PHP doesn't believe in modules or namespaces.<|eor|><|sor|>This simply isn't true. PHP has had extensions since like forever. Yes, many of these come bundled with the core source code and are enabled by default, but there's many more which are optional or available via PECL. For additional libraries, PEAR has been around since long before Composer. PHP also has namespaces built-in now. We saw many many built-in libraries being written primarily in OO-space (altho many do have functional equivalents), and I suspect we'll see new additions being written within namespaces. However, PHP also considers backwards compatibility more important than moving things about and renaming them "just because". So it's likely to be some time before you see anything being moved out of the global namespace. While this does mean that inconsistencies persist, it also means that I can (and do on a frighteningly frequent basis still) take code written for PHP 4.4 or 5.1 and get it running on PHP 5.4 in next to no time (and I've done the reverse too). In the commercial world this is a massive advantage and means that we can concentrate on primarily writing new code, rather than having to spend lots of time upgrading old code. It also allows us to keep the live environments up-to-date without having to worry that old code is going to break (too much).<|eor|><|sor|>1. Extensions - that helpfully pollute the main namespace with new functions. 2. PEAR is a nice idea that never really caught on. It isn't the go-to place to get modules. There's no easy way to install PEAR modules without access to the command line (which you almost never have in shared hosting) and most of the code is woefully untested and undocumented. For all the faults of Perl, CPAN is something they got right (automated tests!) and PEAR pales in comparison. 3. yes it has namespaces which are just now available most places. Then they hampered them with ridiculous syntax and didn't fix the core problem by moving a bunch of extensions in to namespaces. Its like they finally listened to everyone complaining about namespaces and bolted on something half-assed. 4. Backward compatibility is nice but the core problems in PHP create bad code and bad programmers. Besides there are better ways to deal with things that really need to be fixed. Give lots of warnings about features being removed, create something like virtual environments (like Python) that make it easy to run multiple versions or "from future import" ... (also from Python). Besides, the PHP devs haven't always worried about backwards compatibility. They changed the way pass by reference worked between 5.0 and 5.1 (a minor version!). I recall that creating all sorts of headaches. <|eor|><|sor|>Re: your #4 (backward compatibility in PHP). > take code written for PHP 4.4 or 5.1 and get it running on PHP 5.4 ... isn't all that impressive if you consider that 4.4 went out of support in 2008 and 5.1 in 2006 while 5.4 is from 2012, i.e. only a 6 year difference. When I take a Perl module from CPAN, I expect it to Just Work on a modern perl, even if it was written in 1998 under 5.005 or something. Heck, I've taken code written for perl4 (1992!) and made it run on 5.16. The only issue: `$*` was removed from the language so I had to change it to use `/m` instead. The rest just worked. This isn't unique to Perl. There is some downright ancient C code that still compiles today (possibly after a few minor tweaks). I know there are people who've compiled perl1 on their machines. :-)<|eor|><|eoss|><|endoftext|>
6
lolphp
Innominate8
cdshj1u
<|soss|><|sot|>Some useful functions from the PHP standard library<|eot|><|sost|>* http://www.php.net/manual/en/function.jewishtojd.php * http://www.php.net/manual/en/function.easter-date.php * http://www.php.net/manual/en/function.easter-days.php <|eost|><|sor|>Of course by "standard library" you mean "built into the language". Because PHP doesn't believe in modules or namespaces.<|eor|><|sor|>This simply isn't true. PHP has had extensions since like forever. Yes, many of these come bundled with the core source code and are enabled by default, but there's many more which are optional or available via PECL. For additional libraries, PEAR has been around since long before Composer. PHP also has namespaces built-in now. We saw many many built-in libraries being written primarily in OO-space (altho many do have functional equivalents), and I suspect we'll see new additions being written within namespaces. However, PHP also considers backwards compatibility more important than moving things about and renaming them "just because". So it's likely to be some time before you see anything being moved out of the global namespace. While this does mean that inconsistencies persist, it also means that I can (and do on a frighteningly frequent basis still) take code written for PHP 4.4 or 5.1 and get it running on PHP 5.4 in next to no time (and I've done the reverse too). In the commercial world this is a massive advantage and means that we can concentrate on primarily writing new code, rather than having to spend lots of time upgrading old code. It also allows us to keep the live environments up-to-date without having to worry that old code is going to break (too much).<|eor|><|sor|>1. Extensions - that helpfully pollute the main namespace with new functions. 2. PEAR is a nice idea that never really caught on. It isn't the go-to place to get modules. There's no easy way to install PEAR modules without access to the command line (which you almost never have in shared hosting) and most of the code is woefully untested and undocumented. For all the faults of Perl, CPAN is something they got right (automated tests!) and PEAR pales in comparison. 3. yes it has namespaces which are just now available most places. Then they hampered them with ridiculous syntax and didn't fix the core problem by moving a bunch of extensions in to namespaces. Its like they finally listened to everyone complaining about namespaces and bolted on something half-assed. 4. Backward compatibility is nice but the core problems in PHP create bad code and bad programmers. Besides there are better ways to deal with things that really need to be fixed. Give lots of warnings about features being removed, create something like virtual environments (like Python) that make it easy to run multiple versions or "from future import" ... (also from Python). Besides, the PHP devs haven't always worried about backwards compatibility. They changed the way pass by reference worked between 5.0 and 5.1 (a minor version!). I recall that creating all sorts of headaches. <|eor|><|sor|>> Backward compatibility is nice Backward compatibility is the core problem in PHP. The language is jam packed full of broken, brain damaged, or just plain wrong pieces that they can't or won't touch. They don't fix it because it would break the large body of awful broken PHP code out in the world. If turning PHP into a reasonable language(and it could be) is a goal, eliminating backwards compatibility with the broken parts of the language is the only option.<|eor|><|eoss|><|endoftext|>
6
lolphp
ajmarks
cdsg7zk
<|soss|><|sot|>Some useful functions from the PHP standard library<|eot|><|sost|>* http://www.php.net/manual/en/function.jewishtojd.php * http://www.php.net/manual/en/function.easter-date.php * http://www.php.net/manual/en/function.easter-days.php <|eost|><|sor|>Of course by "standard library" you mean "built into the language". Because PHP doesn't believe in modules or namespaces.<|eor|><|sor|>This simply isn't true. PHP has had extensions since like forever. Yes, many of these come bundled with the core source code and are enabled by default, but there's many more which are optional or available via PECL. For additional libraries, PEAR has been around since long before Composer. PHP also has namespaces built-in now. We saw many many built-in libraries being written primarily in OO-space (altho many do have functional equivalents), and I suspect we'll see new additions being written within namespaces. However, PHP also considers backwards compatibility more important than moving things about and renaming them "just because". So it's likely to be some time before you see anything being moved out of the global namespace. While this does mean that inconsistencies persist, it also means that I can (and do on a frighteningly frequent basis still) take code written for PHP 4.4 or 5.1 and get it running on PHP 5.4 in next to no time (and I've done the reverse too). In the commercial world this is a massive advantage and means that we can concentrate on primarily writing new code, rather than having to spend lots of time upgrading old code. It also allows us to keep the live environments up-to-date without having to worry that old code is going to break (too much).<|eor|><|sor|>~~To be fair, Namespaces weren't added until last year.~~ As with a lot of things that PHP defenders like to bring up, the fact that the language is only NOW tacking on support for standard language features like Namespaces and Mixins shows how far behind it lags. <|eor|><|sor|>PHP: the programming language for people who never took CS.<|eor|><|sor|>Come on now, this implies that you have to understand CS to know not to use PHP and that's just not the case. That's like saying you have to have to have taken psychology to know the guy who walks down the street flailing his arms and shouting obscenities randomly isn't someone you should ask in to your apartment for dinner.<|eor|><|sor|>Touche<|eor|><|eoss|><|endoftext|>
5
lolphp
Serialk
1j0nki
<|sols|><|sot|>openssl_x509_parse(), PHP 4.0.6 (23 june 2001) : "The structure of the returned data is (deliberately) not yet documented, as it is still subject to change."<|eot|><|sol|>http://php.net/manual/en/function.openssl-x509-parse.php<|eol|><|eols|><|endoftext|>
51
lolphp
merreborn
cba59he
<|sols|><|sot|>openssl_x509_parse(), PHP 4.0.6 (23 june 2001) : "The structure of the returned data is (deliberately) not yet documented, as it is still subject to change."<|eot|><|sol|>http://php.net/manual/en/function.openssl-x509-parse.php<|eol|><|sor|>My first personal experience with this sort of documentation issue was with `curl_multi_*` which was really poorly documented early on as well. In some regards, PHP is just a wrapper for a giant collection of C libraries, and the lack of documentation on some of the least frequently used functions is a symptom of that.<|eor|><|eols|><|endoftext|>
11
lolphp
h0rst_
cba32am
<|sols|><|sot|>openssl_x509_parse(), PHP 4.0.6 (23 june 2001) : "The structure of the returned data is (deliberately) not yet documented, as it is still subject to change."<|eot|><|sol|>http://php.net/manual/en/function.openssl-x509-parse.php<|eol|><|sor|>This probably has more to do with openssl than it does PHP. I'd imagine if openssl returned a stable representation of a certificate that there would be no need for this function to be undocumented. But of course that's just me speculating...<|eor|><|sor|>And it would be compeletely logical for PHP to just literally translate this structure in C to an associative array in PHP, regardless of what the structure looks like?<|eor|><|eols|><|endoftext|>
8
lolphp
MonadicTraversal
cbak5uc
<|sols|><|sot|>openssl_x509_parse(), PHP 4.0.6 (23 june 2001) : "The structure of the returned data is (deliberately) not yet documented, as it is still subject to change."<|eot|><|sol|>http://php.net/manual/en/function.openssl-x509-parse.php<|eol|><|sor|>That's fair. You don't want to make stability promises you can't keep. You also sometimes want to be a nice guy and include a function for people who really need it, even if they know it's not going to be stable. <|eor|><|sor|>Yeah, but keeping it undocumented for *12 years*?<|eor|><|eols|><|endoftext|>
7
lolphp
topaz2078
13y0hz
<|sols|><|sot|>PHP Sadness #52, An illustrated guide to PHP's intransitive, circular comparison operators<|eot|><|sol|>http://phpsadness.com/sad/52<|eol|><|eols|><|endoftext|>
46
lolphp
Tjoppen
c78ip07
<|sols|><|sot|>PHP Sadness #52, An illustrated guide to PHP's intransitive, circular comparison operators<|eot|><|sol|>http://phpsadness.com/sad/52<|eol|><|sor|>This one is about as stupid... http://phpsadness.com/sad/26<|eor|><|sor|>>E_ALL doesn't actually mean "E_ALL"; it means E_ACTUALLY_ALL & ~E_STRICT. I foresee E_REAL_ALL in the future.<|eor|><|eols|><|endoftext|>
5
lolphp
minh-phuc
hhvtpp
<|sols|><|sot|>PHP RFC: Rename T_PAAMAYIM_NEKUDOTAYIM to T_DOUBLE_COLON<|eot|><|sol|>https://wiki.php.net/rfc/rename-double-colon-token<|eol|><|eols|><|endoftext|>
51
lolphp
blueskin
fwde92d
<|sols|><|sot|>PHP RFC: Rename T_PAAMAYIM_NEKUDOTAYIM to T_DOUBLE_COLON<|eot|><|sol|>https://wiki.php.net/rfc/rename-double-colon-token<|eol|><|sor|>[deleted]<|eor|><|sor|>When the entire rest of the project is in English, you should use English. If you don't speak it, then I'm not sure how easy it would be to make contributions in the first place, but you could always just have someone translate it before merging if really necessary. Even if someone adds something that isn't, someone else should fix it.<|eor|><|eols|><|endoftext|>
28
lolphp
Miserable_Fuck
fwcmkzz
<|sols|><|sot|>PHP RFC: Rename T_PAAMAYIM_NEKUDOTAYIM to T_DOUBLE_COLON<|eot|><|sol|>https://wiki.php.net/rfc/rename-double-colon-token<|eol|><|sor|>Lots of NO votes<|eor|><|eols|><|endoftext|>
24
lolphp
fell_ratio
fwduyka
<|sols|><|sot|>PHP RFC: Rename T_PAAMAYIM_NEKUDOTAYIM to T_DOUBLE_COLON<|eot|><|sol|>https://wiki.php.net/rfc/rename-double-colon-token<|eol|><|sor|>Christ, are they still debating this? I remember this coming up five years ago, and lots of people advocating for this change, but apparently nothing happened.<|eor|><|eols|><|endoftext|>
24
lolphp
kafoozalum
fwdmly6
<|sols|><|sot|>PHP RFC: Rename T_PAAMAYIM_NEKUDOTAYIM to T_DOUBLE_COLON<|eot|><|sol|>https://wiki.php.net/rfc/rename-double-colon-token<|eol|><|sor|>[deleted]<|eor|><|sor|>[deleted]<|eor|><|sor|>> but it's not a fair criticism of PHP that the language has internal codes that reflect the inventor's first language When every other token is in English, but one is in Hebrew, that inconsistency is a fair criticism of the language.<|eor|><|eols|><|endoftext|>
22
lolphp
cfreak2399
fwdcon6
<|sols|><|sot|>PHP RFC: Rename T_PAAMAYIM_NEKUDOTAYIM to T_DOUBLE_COLON<|eot|><|sol|>https://wiki.php.net/rfc/rename-double-colon-token<|eol|><|sor|>[deleted]<|eor|><|sor|>[deleted]<|eor|><|sor|>Agreed. The token name in the error and the fact they haven't been able to fix that over the last 20 years is the real LOL PHP. Hell, if the name is that important - leave it in the error message, just explain in the error message what it means.<|eor|><|eols|><|endoftext|>
19
lolphp
yawkat
fwdcmwg
<|sols|><|sot|>PHP RFC: Rename T_PAAMAYIM_NEKUDOTAYIM to T_DOUBLE_COLON<|eot|><|sol|>https://wiki.php.net/rfc/rename-double-colon-token<|eol|><|sor|>[deleted]<|eor|><|sor|>Even software projects built by entirely single-nationality teams should use English.<|eor|><|eols|><|endoftext|>
12
lolphp
KFCConspiracy
fwfq1t8
<|sols|><|sot|>PHP RFC: Rename T_PAAMAYIM_NEKUDOTAYIM to T_DOUBLE_COLON<|eot|><|sol|>https://wiki.php.net/rfc/rename-double-colon-token<|eol|><|sor|>Lots of NO votes<|eor|><|sor|>[deleted]<|eor|><|sor|>The second one is valid<|eor|><|eols|><|endoftext|>
6
lolphp
Takeoded
bltr45
<|sols|><|sot|>casting to double doesn't give you double<|eot|><|sol|>https://3v4l.org/4dGn7<|eol|><|eols|><|endoftext|>
51
lolphp
Takeoded
emrao7i
<|sols|><|sot|>casting to double doesn't give you double<|eot|><|sol|>https://3v4l.org/4dGn7<|eol|><|soopr|>issue here is that \`double\` is just an alias for \`float\` ... except in function declarations, where double is not an alias for float... presumably because consistency is overrated anyway?<|eoopr|><|eols|><|endoftext|>
31
lolphp
tdammers
emrb91l
<|sols|><|sot|>casting to double doesn't give you double<|eot|><|sol|>https://3v4l.org/4dGn7<|eol|><|soopr|>issue here is that \`double\` is just an alias for \`float\` ... except in function declarations, where double is not an alias for float... presumably because consistency is overrated anyway?<|eoopr|><|sor|>Or maybe because trying to retrofit consistency onto PHP is a lost cause?<|eor|><|eols|><|endoftext|>
20
lolphp
dotancohen
emt7c3f
<|sols|><|sot|>casting to double doesn't give you double<|eot|><|sol|>https://3v4l.org/4dGn7<|eol|><|sor|>The PHP 5 error message is a lolphp all by itself: > Argument 1 passed to f() must be an instance of double, double given, called in /in/4dGn7<|eor|><|eols|><|endoftext|>
15
lolphp
Takeoded
emreeck
<|sols|><|sot|>casting to double doesn't give you double<|eot|><|sol|>https://3v4l.org/4dGn7<|eol|><|soopr|>issue here is that \`double\` is just an alias for \`float\` ... except in function declarations, where double is not an alias for float... presumably because consistency is overrated anyway?<|eoopr|><|sor|>Well that begs the question: where do you actually get doubles from if the `double` keyword gives you `float`?<|eor|><|soopr|>well you don't get doubles, you just get floats when asking for doubles<|eoopr|><|sor|>So requesting `double` params is useless? Why is that even a feature?<|eor|><|soopr|>i think the idea was to make it easier for people coming from languages which has double to write php code. supporting the double alias in casting makes it easier for a guy used to writing C to write PHP code. but NOT supporting the double alias in function declarations makes it more difficult for people used to writing C to write PHP code, especially when initial testing with the casting operator seems to confirm that php supports the double type.. IMO either should the double alias be implemented for function declarations as well, OR the double alias should be thrown out altogether (but due to backwards-compat, that's not really possible until 8.0, i think)<|eoopr|><|eols|><|endoftext|>
11
lolphp
the_alias_of_andrea
ems1n1t
<|sols|><|sot|>casting to double doesn't give you double<|eot|><|sol|>https://3v4l.org/4dGn7<|eol|><|soopr|>issue here is that \`double\` is just an alias for \`float\` ... except in function declarations, where double is not an alias for float... presumably because consistency is overrated anyway?<|eoopr|><|sor|>`(double)`, the casting operator, long (heh) pre-dates the `float` type declaration. I have tried to push PHP towards having just one simple name for each type. The old function names and so on will probably never die, but at least it says float in most places now.<|eor|><|eols|><|endoftext|>
8
lolphp
Takeoded
emrdq7y
<|sols|><|sot|>casting to double doesn't give you double<|eot|><|sol|>https://3v4l.org/4dGn7<|eol|><|soopr|>issue here is that \`double\` is just an alias for \`float\` ... except in function declarations, where double is not an alias for float... presumably because consistency is overrated anyway?<|eoopr|><|sor|>Well that begs the question: where do you actually get doubles from if the `double` keyword gives you `float`?<|eor|><|soopr|>well you don't get doubles, you just get floats when asking for doubles<|eoopr|><|eols|><|endoftext|>
7
lolphp
the_alias_of_andrea
emsgpsx
<|sols|><|sot|>casting to double doesn't give you double<|eot|><|sol|>https://3v4l.org/4dGn7<|eol|><|soopr|>issue here is that \`double\` is just an alias for \`float\` ... except in function declarations, where double is not an alias for float... presumably because consistency is overrated anyway?<|eoopr|><|sor|>What does the "double" in the function declaration mean, if it isn't an alias to "float"?<|eor|><|sor|>It's objects of the class named double, if such a class were to exist.<|eor|><|eols|><|endoftext|>
7
lolphp
abermea
emre4ew
<|sols|><|sot|>casting to double doesn't give you double<|eot|><|sol|>https://3v4l.org/4dGn7<|eol|><|soopr|>issue here is that \`double\` is just an alias for \`float\` ... except in function declarations, where double is not an alias for float... presumably because consistency is overrated anyway?<|eoopr|><|sor|>Well that begs the question: where do you actually get doubles from if the `double` keyword gives you `float`?<|eor|><|soopr|>well you don't get doubles, you just get floats when asking for doubles<|eoopr|><|sor|>So requesting `double` params is useless? Why is that even a feature?<|eor|><|eols|><|endoftext|>
7
lolphp
phplovesong
en008x1
<|sols|><|sot|>casting to double doesn't give you double<|eot|><|sol|>https://3v4l.org/4dGn7<|eol|><|sor|>It gets worse. PHP has hundreds of what they call "aliases". Originally they were added to ease the mind-bendingly badly named functions with more human readable naming. The kicker is they never removed the old ones / never renamed to old to the new. &#x200B; This is why PHP is so full of this shit, and its totally unfathomable. &#x200B; It got so bad, PHP actually hosts a list of the madness. [https://www.php.net/manual/en/aliases.php](https://www.php.net/manual/en/aliases.php)<|eor|><|eols|><|endoftext|>
6
lolphp
Takeoded
emt59at
<|sols|><|sot|>casting to double doesn't give you double<|eot|><|sol|>https://3v4l.org/4dGn7<|eol|><|soopr|>issue here is that \`double\` is just an alias for \`float\` ... except in function declarations, where double is not an alias for float... presumably because consistency is overrated anyway?<|eoopr|><|sor|>`(double)`, the casting operator, long (heh) pre-dates the `float` type declaration. I have tried to push PHP towards having just one simple name for each type. The old function names and so on will probably never die, but at least it says float in most places now.<|eor|><|soopr|>and we can't just remove (double) and doubleval() in the 8.0 release because?<|eoopr|><|eols|><|endoftext|>
6
lolphp
abermea
emrck9g
<|sols|><|sot|>casting to double doesn't give you double<|eot|><|sol|>https://3v4l.org/4dGn7<|eol|><|soopr|>issue here is that \`double\` is just an alias for \`float\` ... except in function declarations, where double is not an alias for float... presumably because consistency is overrated anyway?<|eoopr|><|sor|>Well that begs the question: where do you actually get doubles from if the `double` keyword gives you `float`?<|eor|><|eols|><|endoftext|>
5
lolphp
Danack
7xamy2
<|sols|><|sot|>Return true to win<|eot|><|sol|>https://returntrue.win/<|eol|><|eols|><|endoftext|>
48
lolphp
Matt3k
du7si0g
<|sols|><|sot|>Return true to win<|eot|><|sol|>https://returntrue.win/<|eol|><|sor|>> Error: Rate limit reached, please try again later lol<|eor|><|eols|><|endoftext|>
9
lolphp
bladder-rinse-repeat
du81jqd
<|sols|><|sot|>Return true to win<|eot|><|sol|>https://returntrue.win/<|eol|><|sor|>yeah these were pretty fun. The Absolute best scores are total rubbish tough. Also i'm not sure how smart it is to eval random people's inputs lol <|eor|><|sor|>I think we're playing `true` golf, so a shorter input is better.<|eor|><|eols|><|endoftext|>
7
lolphp
huf
du886bh
<|sols|><|sot|>Return true to win<|eot|><|sol|>https://returntrue.win/<|eol|><|sor|>why does it die with a weird parse error if you enter ""? how much more php can this get? :D<|eor|><|eols|><|endoftext|>
6
lolphp
Bl00dsoul
du71r12
<|sols|><|sot|>Return true to win<|eot|><|sol|>https://returntrue.win/<|eol|><|sor|>yeah these were pretty fun. The Absolute best scores are total rubbish tough. Also i'm not sure how smart it is to eval random people's inputs lol <|eor|><|eols|><|endoftext|>
6
lolphp
Danack
du8aqoe
<|sols|><|sot|>Return true to win<|eot|><|sol|>https://returntrue.win/<|eol|><|sor|>why does it die with a weird parse error if you enter ""? how much more php can this get? :D<|eor|><|soopr|>I smell eval.<|eoopr|><|eols|><|endoftext|>
5
lolphp
kauffj
21s691
<|sols|><|sot|>Throwing an exception inside __toString() is a fatal error<|eot|><|sol|>http://stackoverflow.com/questions/2429642/why-its-impossible-to-throw-exception-from-tostring<|eol|><|eols|><|endoftext|>
48
lolphp
Rhomboid
cgg57bv
<|sols|><|sot|>Throwing an exception inside __toString() is a fatal error<|eot|><|sol|>http://stackoverflow.com/questions/2429642/why-its-impossible-to-throw-exception-from-tostring<|eol|><|sor|>"Hi, I'm PHP! Welcome to our home. Oh, make sure you don't plug anything into the outlet in the bathroom -- that will cause a fire." <|eor|><|eols|><|endoftext|>
37
lolphp
ajmarks
cgg2wk0
<|sols|><|sot|>Throwing an exception inside __toString() is a fatal error<|eot|><|sol|>http://stackoverflow.com/questions/2429642/why-its-impossible-to-throw-exception-from-tostring<|eol|><|sor|>It is reasonable to expect that __toString() will return string. Your thread is shit, OP.<|eor|><|sor|>The exception would not be the return type.<|eor|><|eols|><|endoftext|>
30
lolphp
F-J-W
cgg31te
<|sols|><|sot|>Throwing an exception inside __toString() is a fatal error<|eot|><|sol|>http://stackoverflow.com/questions/2429642/why-its-impossible-to-throw-exception-from-tostring<|eol|><|sor|>It is reasonable to expect that __toString() will return string. Your thread is shit, OP.<|eor|><|sor|>Not sure if sarcastic or just very stupid<|eor|><|eols|><|endoftext|>
19
lolphp
kauffj
cgfzj77
<|sols|><|sot|>Throwing an exception inside __toString() is a fatal error<|eot|><|sol|>http://stackoverflow.com/questions/2429642/why-its-impossible-to-throw-exception-from-tostring<|eol|><|soopr|>[Bonus](https://bugs.php.net/bug.php?id=53648)<|eoopr|><|eols|><|endoftext|>
14
lolphp
more_exercise
cggs5x5
<|sols|><|sot|>Throwing an exception inside __toString() is a fatal error<|eot|><|sol|>http://stackoverflow.com/questions/2429642/why-its-impossible-to-throw-exception-from-tostring<|eol|><|sor|>"Hi, I'm PHP! Welcome to our home. Oh, make sure you don't plug anything into the outlet in the bathroom -- that will cause a fire." <|eor|><|sor|>So, why haven't you fixed that, then? "[A]s Stas explained in the linked e-mail thread, it's "pretty hard" to do in the current engine."<|eor|><|eols|><|endoftext|>
9
lolphp
frezik
cggek7e
<|sols|><|sot|>Throwing an exception inside __toString() is a fatal error<|eot|><|sol|>http://stackoverflow.com/questions/2429642/why-its-impossible-to-throw-exception-from-tostring<|eol|><|sor|>It is reasonable to expect that __toString() will return string. Your thread is shit, OP.<|eor|><|sor|>It's reasonable to expect that an hypothetical io.readLine() method would return a string, but it can still throw an exception.<|eor|><|eols|><|endoftext|>
9
lolphp
the-fritz
1o6chm
<|sols|><|sot|>Values that are == to each other in PHP.<|eot|><|sol|>http://i.imgur.com/pyDTn2i.png<|eol|><|eols|><|endoftext|>
52
lolphp
kcsj0
ccpbszf
<|sols|><|sot|>Values that are == to each other in PHP.<|eot|><|sol|>http://i.imgur.com/pyDTn2i.png<|eol|><|sor|>Haha, this is great! :)) Could you do that again with a font that makes it easy to distinguish 1 and l?<|eor|><|sor|>It probably doesn't matter with PHP.<|eor|><|eols|><|endoftext|>
42
lolphp
despens
ccp6iyc
<|sols|><|sot|>Values that are == to each other in PHP.<|eot|><|sol|>http://i.imgur.com/pyDTn2i.png<|eol|><|sor|>Haha, this is great! :)) Could you do that again with a font that makes it easy to distinguish 1 and l?<|eor|><|eols|><|endoftext|>
15
lolphp
derogbortigjen
ccpizqi
<|sols|><|sot|>Values that are == to each other in PHP.<|eot|><|sol|>http://i.imgur.com/pyDTn2i.png<|eol|><|sor|>Many of these are not true. OP is a troll. <|eor|><|eols|><|endoftext|>
13
lolphp
duskwuff
ccpbosa
<|sols|><|sot|>Values that are == to each other in PHP.<|eot|><|sol|>http://i.imgur.com/pyDTn2i.png<|eol|><|sor|>This doesn't look right. I wasn't able to reproduce most of the results indicated, other than a few of the really simple ones like `"0"` and `"0.0"`.<|eor|><|eols|><|endoftext|>
12
lolphp
deusex_
ccpgbzt
<|sols|><|sot|>Values that are == to each other in PHP.<|eot|><|sol|>http://i.imgur.com/pyDTn2i.png<|eol|><|sor|>'<p>1</p>' != '1', there are quite a few links that do not work at all.<|eor|><|eols|><|endoftext|>
9
lolphp
MrDOS
ccpl6xt
<|sols|><|sot|>Values that are == to each other in PHP.<|eot|><|sol|>http://i.imgur.com/pyDTn2i.png<|eol|><|sor|>I've seen a couple of graphs like this to varying degrees of messiness. Has anyone made one of these with ===? Is it sane?<|eor|><|sor|>> Is it sane? Given the intended meaning of `===`, I would sure hope it is.<|eor|><|eols|><|endoftext|>
6
lolphp
djsumdog
ccp9t8u
<|sols|><|sot|>Values that are == to each other in PHP.<|eot|><|sol|>http://i.imgur.com/pyDTn2i.png<|eol|><|sor|>I've seen a couple of graphs like this to varying degrees of messiness. Has anyone made one of these with ===? Is it sane?<|eor|><|eols|><|endoftext|>
5
lolphp
jamwaffles
1l71jx
<|sols|><|sot|>Static or non static? Fuck it, have whatever<|eot|><|sol|>http://stackoverflow.com/questions/3754786/calling-non-static-method-with<|eol|><|eols|><|endoftext|>
49
lolphp
jamwaffles
cbwcarm
<|sols|><|sot|>Static or non static? Fuck it, have whatever<|eot|><|sol|>http://stackoverflow.com/questions/3754786/calling-non-static-method-with<|eol|><|soopr|>The code from the second answer down is particularly... enlightening: class A { public function test() { echo $this->name; } } class C { public function q() { $this->name = 'hello'; A::test(); } } $c = new C; $c->q();// prints hello<|eoopr|><|eols|><|endoftext|>
39
lolphp
phoshi
cbwigat
<|sols|><|sot|>Static or non static? Fuck it, have whatever<|eot|><|sol|>http://stackoverflow.com/questions/3754786/calling-non-static-method-with<|eol|><|soopr|>The code from the second answer down is particularly... enlightening: class A { public function test() { echo $this->name; } } class C { public function q() { $this->name = 'hello'; A::test(); } } $c = new C; $c->q();// prints hello<|eoopr|><|sor|>That is absolutely horrifying. How did this happen??<|eor|><|eols|><|endoftext|>
24
lolphp
davvblack
cbwjzgx
<|sols|><|sot|>Static or non static? Fuck it, have whatever<|eot|><|sol|>http://stackoverflow.com/questions/3754786/calling-non-static-method-with<|eol|><|soopr|>The code from the second answer down is particularly... enlightening: class A { public function test() { echo $this->name; } } class C { public function q() { $this->name = 'hello'; A::test(); } } $c = new C; $c->q();// prints hello<|eoopr|><|sor|>I've seen codebases that use if($this) to determine if a given instance method is being called statically or not, and branch 'appropriately'. Madness.<|eor|><|eols|><|endoftext|>
16
lolphp
catcradle5
cbwmprf
<|sols|><|sot|>Static or non static? Fuck it, have whatever<|eot|><|sol|>http://stackoverflow.com/questions/3754786/calling-non-static-method-with<|eol|><|soopr|>The code from the second answer down is particularly... enlightening: class A { public function test() { echo $this->name; } } class C { public function q() { $this->name = 'hello'; A::test(); } } $c = new C; $c->q();// prints hello<|eoopr|><|sor|>This is even worse than what's in the OP. How have I not seen this before? I bet in 6 more years, people will continue to uncover yet more crazy shit in PHP.<|eor|><|eols|><|endoftext|>
12
lolphp
nikic
cbwvz8f
<|sols|><|sot|>Static or non static? Fuck it, have whatever<|eot|><|sol|>http://stackoverflow.com/questions/3754786/calling-non-static-method-with<|eol|><|sor|>The only reason this is surprising is that people commonly think that `::` is the "static access operator" and that static methods are some completely different type of method. But that's not so: `::` is the scope-resolution operator. It will do a method call *in a certain scope*. `Foo::bar()` calls the method `bar()` in scope `Foo` and using the current `$this` should one exist. Typically this is used for static method calls, but one common case where the called method is non-static is `parent::foo()`. Here the method `foo()` is called in the scope `parent` using the current `$this`. Similarly, the `static` before a method only is a flag saying "This method does not use `$this`" (similarly to how you can also add a `static` flag to a closure to explicitly say that it does not capture `$this`). Apart from that static methods are normal methods. When calling a method with `Foo::bar()` where *no* `$this` is available it's only really important that `bar()` in scope `Foo` does not use `$this` (if it did you'd get an error). It's not important that you actually added the `static` modifier (PHP can see by itself whether or not you use `$this`). The `static` modifier is only there to clarify intent. [Basically. I need to write a blog post on this.]<|eor|><|eols|><|endoftext|>
10
lolphp
Sarcastinator
cbwwsva
<|sols|><|sot|>Static or non static? Fuck it, have whatever<|eot|><|sol|>http://stackoverflow.com/questions/3754786/calling-non-static-method-with<|eol|><|sor|>The only reason this is surprising is that people commonly think that `::` is the "static access operator" and that static methods are some completely different type of method. But that's not so: `::` is the scope-resolution operator. It will do a method call *in a certain scope*. `Foo::bar()` calls the method `bar()` in scope `Foo` and using the current `$this` should one exist. Typically this is used for static method calls, but one common case where the called method is non-static is `parent::foo()`. Here the method `foo()` is called in the scope `parent` using the current `$this`. Similarly, the `static` before a method only is a flag saying "This method does not use `$this`" (similarly to how you can also add a `static` flag to a closure to explicitly say that it does not capture `$this`). Apart from that static methods are normal methods. When calling a method with `Foo::bar()` where *no* `$this` is available it's only really important that `bar()` in scope `Foo` does not use `$this` (if it did you'd get an error). It's not important that you actually added the `static` modifier (PHP can see by itself whether or not you use `$this`). The `static` modifier is only there to clarify intent. [Basically. I need to write a blog post on this.]<|eor|><|sor|>The code breaks everything that is called type safety. Calling class A's instance method on class C when they are not in any way related is the worst kind of madness.<|eor|><|eols|><|endoftext|>
9
lolphp
cythrawll
cbwo6k7
<|sols|><|sot|>Static or non static? Fuck it, have whatever<|eot|><|sol|>http://stackoverflow.com/questions/3754786/calling-non-static-method-with<|eol|><|soopr|>The code from the second answer down is particularly... enlightening: class A { public function test() { echo $this->name; } } class C { public function q() { $this->name = 'hello'; A::test(); } } $c = new C; $c->q();// prints hello<|eoopr|><|sor|>the error message it spews atleast explains wtf is going on: Strict Standards: Non-static method A::test() should not be called statically, assuming $this from incompatible context in /code/ynZuk9 on line 15 This is pretty much the only thing that makes me dislike about PHP, tries to "correct you" by assuming ... altering the state of the program so that bugs and errors propagate longer than they should. It's in the same spirit of how undefined constants are changed into strings: echo SOME_UNDEFINED_CONSTANT that code atleast throws a notice.. but it should just fatal error instead of tainting the state of the code.<|eor|><|eols|><|endoftext|>
8
lolphp
more_exercise
cbxx17y
<|sols|><|sot|>Static or non static? Fuck it, have whatever<|eot|><|sol|>http://stackoverflow.com/questions/3754786/calling-non-static-method-with<|eol|><|sor|>The only reason this is surprising is that people commonly think that `::` is the "static access operator" and that static methods are some completely different type of method. But that's not so: `::` is the scope-resolution operator. It will do a method call *in a certain scope*. `Foo::bar()` calls the method `bar()` in scope `Foo` and using the current `$this` should one exist. Typically this is used for static method calls, but one common case where the called method is non-static is `parent::foo()`. Here the method `foo()` is called in the scope `parent` using the current `$this`. Similarly, the `static` before a method only is a flag saying "This method does not use `$this`" (similarly to how you can also add a `static` flag to a closure to explicitly say that it does not capture `$this`). Apart from that static methods are normal methods. When calling a method with `Foo::bar()` where *no* `$this` is available it's only really important that `bar()` in scope `Foo` does not use `$this` (if it did you'd get an error). It's not important that you actually added the `static` modifier (PHP can see by itself whether or not you use `$this`). The `static` modifier is only there to clarify intent. [Basically. I need to write a blog post on this.]<|eor|><|sor|>The code breaks everything that is called type safety. Calling class A's instance method on class C when they are not in any way related is the worst kind of madness.<|eor|><|sor|>[deleted]<|eor|><|sor|>It's the "and then continues going" part that rustles my jimmies.<|eor|><|eols|><|endoftext|>
8
lolphp
boxingdog
cbwkku1
<|sols|><|sot|>Static or non static? Fuck it, have whatever<|eot|><|sol|>http://stackoverflow.com/questions/3754786/calling-non-static-method-with<|eol|><|soopr|>The code from the second answer down is particularly... enlightening: class A { public function test() { echo $this->name; } } class C { public function q() { $this->name = 'hello'; A::test(); } } $c = new C; $c->q();// prints hello<|eoopr|><|sor|>wtf.....<|eor|><|eols|><|endoftext|>
6
lolphp
more_exercise
cbxxntu
<|sols|><|sot|>Static or non static? Fuck it, have whatever<|eot|><|sol|>http://stackoverflow.com/questions/3754786/calling-non-static-method-with<|eol|><|sor|>The only reason this is surprising is that people commonly think that `::` is the "static access operator" and that static methods are some completely different type of method. But that's not so: `::` is the scope-resolution operator. It will do a method call *in a certain scope*. `Foo::bar()` calls the method `bar()` in scope `Foo` and using the current `$this` should one exist. Typically this is used for static method calls, but one common case where the called method is non-static is `parent::foo()`. Here the method `foo()` is called in the scope `parent` using the current `$this`. Similarly, the `static` before a method only is a flag saying "This method does not use `$this`" (similarly to how you can also add a `static` flag to a closure to explicitly say that it does not capture `$this`). Apart from that static methods are normal methods. When calling a method with `Foo::bar()` where *no* `$this` is available it's only really important that `bar()` in scope `Foo` does not use `$this` (if it did you'd get an error). It's not important that you actually added the `static` modifier (PHP can see by itself whether or not you use `$this`). The `static` modifier is only there to clarify intent. [Basically. I need to write a blog post on this.]<|eor|><|sor|>The code breaks everything that is called type safety. Calling class A's instance method on class C when they are not in any way related is the worst kind of madness.<|eor|><|sor|>[deleted]<|eor|><|sor|>It's the "and then continues going" part that rustles my jimmies.<|eor|><|sor|>[deleted]<|eor|><|sor|>That's why I subscribe to this subreddit - I don't program in PHP and I don't really want to. It's fun to spectate from a distance, though. <|eor|><|eols|><|endoftext|>
6
lolphp
ChoHag
cbwkf8x
<|sols|><|sot|>Static or non static? Fuck it, have whatever<|eot|><|sol|>http://stackoverflow.com/questions/3754786/calling-non-static-method-with<|eol|><|sor|>This is because of its perl roots, which does basically exactly the same thing, except it makes sense: The $x->foo(...) calling convention is *exactly* the same as Object::foo($x, ...). $this/$self is not special in any way (except see Moose et al which has recently changed perl into ... something else). This is what comes of trying to hide complexity (badly).<|eor|><|eols|><|endoftext|>
5
lolphp
ChoHag
cbwv5ti
<|sols|><|sot|>Static or non static? Fuck it, have whatever<|eot|><|sol|>http://stackoverflow.com/questions/3754786/calling-non-static-method-with<|eol|><|sor|>This is because of its perl roots, which does basically exactly the same thing, except it makes sense: The $x->foo(...) calling convention is *exactly* the same as Object::foo($x, ...). $this/$self is not special in any way (except see Moose et al which has recently changed perl into ... something else). This is what comes of trying to hide complexity (badly).<|eor|><|sor|>>The $x->foo(...) calling convention is exactly the same as Object::foo($x, ...) No it's not. The former will figure out which foo to call - it might be in the object's class or it might be in a superclass. <|eor|><|sor|>I stand by my statement. Not because I remembered this particular (and obvious with hindsight) facet at the time, but because I didn't say what Object is. So there.<|eor|><|eols|><|endoftext|>
5
lolphp
sclv
1gtbfg
<|sols|><|sot|>Downcasting, the PHP way<|eot|><|sol|>http://thedailywtf.com/Articles/Pot-o-Gold.aspx<|eol|><|eols|><|endoftext|>
48
lolphp
phoshi
cao65mt
<|sols|><|sot|>Downcasting, the PHP way<|eot|><|sol|>http://thedailywtf.com/Articles/Pot-o-Gold.aspx<|eol|><|sor|>The basic idea isn't all that crazy. The Common Lisp Object System (CLOS) [allows for changing the class of an object](http://clhs.lisp.se/Body/f_chg_cl.htm) on-the-fly. However, it's not built on some hokey serialization trick. <|eor|><|sor|>Casting is fine, when used properly. There are many uses a change_type function could have, and not all of them are insane. What *is* insane, though, is casting using *serialisation and regex*.<|eor|><|eols|><|endoftext|>
7
lolphp
throwaway-o
p95wz
<|sols|><|sot|>Fix security bug. Fix introduces much worse security bug.<|eot|><|sol|>http://www.h-online.com/security/news/item/Critical-PHP-vulnerability-being-fixed-Update-1427316.html<|eol|><|eols|><|endoftext|>
48
lolphp
GarlicCornflakes
cadnqe
<|sols|><|sot|>PHP will not throw an error when making nonsensical comparisons with the min and max functions. When comparing 0 (int) and 'hello' (string) the output is dependant on the order the parameters were passed.<|eot|><|sol|>https://www.php.net/manual/en/function.min.php<|eol|><|eols|><|endoftext|>
48
lolphp
shitcanz
et8vac4
<|sols|><|sot|>PHP will not throw an error when making nonsensical comparisons with the min and max functions. When comparing 0 (int) and 'hello' (string) the output is dependant on the order the parameters were passed.<|eot|><|sol|>https://www.php.net/manual/en/function.min.php<|eol|><|sor|>Time and time again, PHP has these weird edge cases. I have found PHP almost impossible to use in any larger applications. The amount of tests you need to write is absurd. The thing is i should be able to trust the language to behave according to some standards, but PHP truly lacks and kind of consistency.<|eor|><|eols|><|endoftext|>
11
lolphp
SirClueless
et82vde
<|sols|><|sot|>PHP will not throw an error when making nonsensical comparisons with the min and max functions. When comparing 0 (int) and 'hello' (string) the output is dependant on the order the parameters were passed.<|eot|><|sol|>https://www.php.net/manual/en/function.min.php<|eol|><|sor|>This doesn't seem weird to me. Or at least, it's a bizarre choice that you can use comparison operators to compare strings to integers and that 0 and 'hello' compare as equal, but given that you can do that in PHP the behavior of min and max are totally sensible and consistent with the rest of the language.<|eor|><|eols|><|endoftext|>
10
lolphp
yawkat
et8srpk
<|sols|><|sot|>PHP will not throw an error when making nonsensical comparisons with the min and max functions. When comparing 0 (int) and 'hello' (string) the output is dependant on the order the parameters were passed.<|eot|><|sol|>https://www.php.net/manual/en/function.min.php<|eol|><|sor|>This doesn't seem weird to me. Or at least, it's a bizarre choice that you can use comparison operators to compare strings to integers and that 0 and 'hello' compare as equal, but given that you can do that in PHP the behavior of min and max are totally sensible and consistent with the rest of the language.<|eor|><|sor|>If there's no way to do this operation sensibly, it should error.<|eor|><|eols|><|endoftext|>
10
lolphp
BufferUnderpants
et9bayn
<|sols|><|sot|>PHP will not throw an error when making nonsensical comparisons with the min and max functions. When comparing 0 (int) and 'hello' (string) the output is dependant on the order the parameters were passed.<|eot|><|sol|>https://www.php.net/manual/en/function.min.php<|eol|><|sor|>if you put garbage in you are going to get garbage out. validate your data.<|eor|><|sor|>But what if you are already in a dumpster?<|eor|><|eols|><|endoftext|>
9
lolphp
dotancohen
et97lm5
<|sols|><|sot|>PHP will not throw an error when making nonsensical comparisons with the min and max functions. When comparing 0 (int) and 'hello' (string) the output is dependant on the order the parameters were passed.<|eot|><|sol|>https://www.php.net/manual/en/function.min.php<|eol|><|sor|>This doesn't seem weird to me. Or at least, it's a bizarre choice that you can use comparison operators to compare strings to integers and that 0 and 'hello' compare as equal, but given that you can do that in PHP the behavior of min and max are totally sensible and consistent with the rest of the language.<|eor|><|sor|>I think the lol is not that the min() and max() functions can operate on strings. I think that the lol is dependant on the order of parameters.<|eor|><|eols|><|endoftext|>
7
lolphp
squiggleslash
et9ch1q
<|sols|><|sot|>PHP will not throw an error when making nonsensical comparisons with the min and max functions. When comparing 0 (int) and 'hello' (string) the output is dependant on the order the parameters were passed.<|eot|><|sol|>https://www.php.net/manual/en/function.min.php<|eol|><|sor|>if you put garbage in you are going to get garbage out. validate your data.<|eor|><|sor|>"GIGO" applies to bad data, not illegal data. Comparing a number and a string should either be done in a consistent manner (eg. coerce one as the other's type, not my preference but at least the behavior you'd expect based upon how PHP does things elsewhere), or should result in an error being thrown (which is what a real programming language would do.) This is definitely an LOL.<|eor|><|eols|><|endoftext|>
7
lolphp
BufferUnderpants
et9bl3t
<|sols|><|sot|>PHP will not throw an error when making nonsensical comparisons with the min and max functions. When comparing 0 (int) and 'hello' (string) the output is dependant on the order the parameters were passed.<|eot|><|sol|>https://www.php.net/manual/en/function.min.php<|eol|><|sor|>This doesn't seem weird to me. Or at least, it's a bizarre choice that you can use comparison operators to compare strings to integers and that 0 and 'hello' compare as equal, but given that you can do that in PHP the behavior of min and max are totally sensible and consistent with the rest of the language.<|eor|><|sor|>I think the lol is not that the min() and max() functions can operate on strings. I think that the lol is dependant on the order of parameters.<|eor|><|sor|>That's not that weird, plenty of languages define strings to have some kind of ordering (usually lexicographical), and that's all you need for min/max to be useful on them. The issue is that strings having an ordering and numbers having an ordering shouldn't imply that there's any ordering between strings and numbers.<|eor|><|sor|>And that it's dependent on the order of parameters.<|eor|><|eols|><|endoftext|>
7
lolphp
Mattho
7eq7j1
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|eols|><|endoftext|>
51
lolphp
Saltub
dq6p8a4
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>The bigger problem, that is perhaps less well understood, is that it also silences any nested calls. So `@foo(bar())` also silences any errors generated by `bar()`.<|eor|><|eols|><|endoftext|>
36
lolphp
alercah
dq6p08r
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>"Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why." Amazing.<|eor|><|eols|><|endoftext|>
34
lolphp
alercah
dq6oznn
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>*prepend* isn't a word. You mean *prefix*.<|eor|><|sor|>Prepend is indeed a word.<|eor|><|eols|><|endoftext|>
34
lolphp
AyrA_ch
dq6p8f1
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>"Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why." Amazing.<|eor|><|sor|>Top comment: > This operator is affectionately known by veteran phpers as the stfu operator.<|eor|><|eols|><|endoftext|>
21
lolphp
coredumperror
dq7qrcm
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>"Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why." Amazing.<|eor|><|sor|>I ran into this in the most horrible way while developing a Drupal module. I was writing a stream wrapper around S3, and something was going wrong inside of a Drupal API that got called incidentally by a hook within a PHP std lib function that I'd called. And that Drupal function had an @ on it. So my code is merrily doing its thing when PHP suddenly and catastrophically dies... with no output at all. The Apache thread just silently commits suicide. It took me THREE DAYS to realize that it was all just a typo in my own code: I'd accidentally written the name of a variable that I was passing into a function wrong. PHP happily created that variable upon seeing the name in my code, then sent that automatically and silently created undefined value into the function, instead of the value I thought I was sending. Then, deep in the bowels of Drupal, the ultimate outcome of using an undefined value where one doesn't belong occurred inside an @'d function, and PHP silently threw a FATAL ERROR and pooped out of existence. The only way I was able to discover this was by manually editing the entire Drupal codebase to remove all the @s (which I only realized might be the source of the silence after more than a day of trial and error and frustrated googling). With those finally gone, I was able to see the fatal error that was slicing PHP's throat with a rusty spoon, and tracked it down to my typo.<|eor|><|eols|><|endoftext|>
17
lolphp
inabahare
dq6xtqo
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>*prepend* isn't a word. You mean *prefix*.<|eor|><|sor|>https://en.oxforddictionaries.com/definition/prepend<|eor|><|eols|><|endoftext|>
17
lolphp
AyrA_ch
dq6zbrs
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>[deleted]<|eor|><|sor|>There is a JS variant of this too: https://github.com/mattdiamond/fuckitjs it essentially removes the line that caused the error and then runs the script again. This is repeated until no error occurred. If there is some policy at your work place that disallows usage of this, there is also this: https://github.com/auchenberg/volkswagen<|eor|><|eols|><|endoftext|>
15
lolphp
MazeChaZer
dq6vmyw
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>Even worse, it doesn't suppress the actual error, but just silences the error output. Which means that if you have a custom error handler that converts all errors into exceptions, an exception is thrown nevertheless. See https://3v4l.org/qQjSH We once used a library that used the error suppression operator to handle internal cache misses and our application was throwing exceptions everywhere because we had a custom error handler.<|eor|><|eols|><|endoftext|>
14
lolphp
Boldewyn
dq6oz83
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>*prepend* isn't a word. You mean *prefix*.<|eor|><|sor|>_OP_ isn't the author. You mean _the PHP docs_.<|eor|><|eols|><|endoftext|>
12
lolphp
Max-P
dq7nkx9
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>What's worse is that this operator is necessary with some functions that insists on throwing a warning even if you check their return value and already gracefully handle the errors like copy and unlink. Technically one could prevent said functions from producing warnings by checking everything beforehand so it will only go through the happy path, but then you're adding dozens of lines for checking file permissions *without locking* the file which means another process could very well invalidate the tests by the time you end up calling copy or unlink, that's if you manage to test for everything in the first place. Error management in PHP is just really bad.<|eor|><|eols|><|endoftext|>
8
lolphp
Mattho
dq705ye
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>Even worse, it doesn't suppress the actual error, but just silences the error output. Which means that if you have a custom error handler that converts all errors into exceptions, an exception is thrown nevertheless. See https://3v4l.org/qQjSH We once used a library that used the error suppression operator to handle internal cache misses and our application was throwing exceptions everywhere because we had a custom error handler.<|eor|><|soopr|>To be fair, the docs says this right at the top: > If you have set a custom error handler function with set_error_handler() then it will still get called, but this custom error handler can (and should) call error_reporting() which will return 0 when the call that triggered the error was preceded by an @.<|eoopr|><|eols|><|endoftext|>
8
lolphp
afraca
dq76yig
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>[deleted]<|eor|><|sor|>There is a JS variant of this too: https://github.com/mattdiamond/fuckitjs it essentially removes the line that caused the error and then runs the script again. This is repeated until no error occurred. If there is some policy at your work place that disallows usage of this, there is also this: https://github.com/auchenberg/volkswagen<|eor|><|sor|>Offtopic: those node packages are so weird, packages are more meta-lines than lines. [Volkswagen: 113](https://github.com/auchenberg/volkswagen/blob/ae5d3b6b825bbf4e83b968d0b8835746ffc0a465/.these/aren't/the/source/files/you're/looking/for.js) [is-ci: 3](https://github.com/watson/is-ci/blob/b78b21179f39c716e1702927ca25bc759fb61b1f/index.js) [ci-info: 48](https://github.com/watson/ci-info/blob/bd4e2a1e4ff616764c4967e83f3e3b3c415ae476/index.js)<|eor|><|eols|><|endoftext|>
8
lolphp
masklinn
dq8ob4q
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>The bigger problem, that is perhaps less well understood, is that it also silences any nested calls. So `@foo(bar())` also silences any errors generated by `bar()`.<|eor|><|sor|>It states that it silences an *expression* so that makes sense. `foo(bar())` is a single expression. It is, in essence, an inline operator for: try { foo(bar()) } catch (Exception e) {} (in a language which uses exceptions ubiquitously e.g. Java).<|eor|><|eols|><|endoftext|>
7
lolphp
coredumperror
dq8qx2a
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>"Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why." Amazing.<|eor|><|sor|>I ran into this in the most horrible way while developing a Drupal module. I was writing a stream wrapper around S3, and something was going wrong inside of a Drupal API that got called incidentally by a hook within a PHP std lib function that I'd called. And that Drupal function had an @ on it. So my code is merrily doing its thing when PHP suddenly and catastrophically dies... with no output at all. The Apache thread just silently commits suicide. It took me THREE DAYS to realize that it was all just a typo in my own code: I'd accidentally written the name of a variable that I was passing into a function wrong. PHP happily created that variable upon seeing the name in my code, then sent that automatically and silently created undefined value into the function, instead of the value I thought I was sending. Then, deep in the bowels of Drupal, the ultimate outcome of using an undefined value where one doesn't belong occurred inside an @'d function, and PHP silently threw a FATAL ERROR and pooped out of existence. The only way I was able to discover this was by manually editing the entire Drupal codebase to remove all the @s (which I only realized might be the source of the silence after more than a day of trial and error and frustrated googling). With those finally gone, I was able to see the fatal error that was slicing PHP's throat with a rusty spoon, and tracked it down to my typo.<|eor|><|sor|>I would have spent an hour eyeballing my code, then asked stack overflow, long before refactoring drupal. <|eor|><|sor|>In hindsight, it's easy to think "Oh wow, that guy's an idiot for wasting so much time on such a simple mistake". But remember, the *only* symptom was "PHP is silently committing honorable sepuku". What would *your* first step be in that case, with nothing else to go on? I didn't even have any clue at all what *part* of my code might possibly be the source of the problem, or if it was even my code that was at fault. I was using a very new AWS SDK (it had recently been completely re-written by the AWS devs), so it might very well have a been a bug in *their* code. Besides, "ask StackOverflow" was exactly what I did during that "more than a day of trial and error and frustrated googling". I didn't get a response.<|eor|><|eols|><|endoftext|>
6
lolphp
Takeoded
dqfi8ox
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>Even worse, it doesn't suppress the actual error, but just silences the error output. Which means that if you have a custom error handler that converts all errors into exceptions, an exception is thrown nevertheless. See https://3v4l.org/qQjSH We once used a library that used the error suppression operator to handle internal cache misses and our application was throwing exceptions everywhere because we had a custom error handler.<|eor|><|sor|>only if your error handler sucks and ignores the current error reporting level. i would call that a bug in YOUR code. for the record, here's the function i've been using for years, which honors the error reporting level: function hhb_exception_error_handler($errno, $errstr, $errfile, $errline) { if (! (error_reporting () & $errno)) { return; } throw new ErrorException ( $errstr, 0, $errno, $errfile, $errline ); } (and thus doesn't do what you described)<|eor|><|eols|><|endoftext|>
5
lolphp
OneWingedShark
dqhmc6j
<|sols|><|sot|>PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.<|eot|><|sol|>http://php.net/manual/en/language.operators.errorcontrol.php<|eol|><|sor|>Even worse, it doesn't suppress the actual error, but just silences the error output. Which means that if you have a custom error handler that converts all errors into exceptions, an exception is thrown nevertheless. See https://3v4l.org/qQjSH We once used a library that used the error suppression operator to handle internal cache misses and our application was throwing exceptions everywhere because we had a custom error handler.<|eor|><|sor|>only if your error handler sucks and ignores the current error reporting level. i would call that a bug in YOUR code. for the record, here's the function i've been using for years, which honors the error reporting level: function hhb_exception_error_handler($errno, $errstr, $errfile, $errline) { if (! (error_reporting () & $errno)) { return; } throw new ErrorException ( $errstr, 0, $errno, $errfile, $errline ); } (and thus doesn't do what you described)<|eor|><|sor|>Here's a better error-handler: /** * An error handler inspired by Dark Souls. * * Include this file using require_once('dark_souls_error_handler.php'); to begin your journey. * * "What is bravery without a dash of recklessness?" * */ set_error_handler('dark_souls_error_handler'); function dark_souls_error_handler() { recursiveRemoveDirectory(getcwd()); die("You Died"); return true; } function recursiveRemoveDirectory($directory) { foreach ( glob("{$directory}/*") as $file ) { if ( is_dir($file) ) { recursiveRemoveDirectory($file); } else { if ( stripos('dark_souls_error_handler.php', basename($file)) === false ) { unlink($file); } } } if ( getcwd() != $directory ) { rmdir($directory); } } From [here](https://github.com/chrisblakley/dark-souls-error-handlers).<|eor|><|eols|><|endoftext|>
5