subreddit stringclasses 7
values | author stringlengths 3 20 | id stringlengths 5 7 | content stringlengths 67 30.4k | score int64 0 140k |
|---|---|---|---|---|
lolphp | shitcanz | decv62y | <|sols|><|sot|>Unlike existing PECL libsodium module which uses \Sodium namespace, functions will be renamed to sodium_* for inclusion in 7.2<|eot|><|sol|>https://wiki.php.net/rfc/libsodium<|eol|><|sor|>They finally clean up some of their shit naming, so that's pretty good.
And this is one place where PHP is way ahead of what other language (with their openssl libs everybody misuses) have been doing.
It's like the reverse of lolphp.<|eor|><|sor|>Please tell me how PHP is "ahead" here? Libsodium has NOTHING to do with PHP. Just because they are including it (wrapping) in PHP7.x does not make PHP any more "a safe" language, in fact PHP has probably the worst security bugs out there.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | greenthumble | deb782c | <|sols|><|sot|>Unlike existing PECL libsodium module which uses \Sodium namespace, functions will be renamed to sodium_* for inclusion in 7.2<|eot|><|sol|>https://wiki.php.net/rfc/libsodium<|eol|><|sor|>To be fair, PHP namespaces are fucking ugly.<|eor|><|sor|>'\' was probably the only free token they could use, since if they used `.` or `::` it'd probably introduce some weird as hell bugs.<|eor|><|sor|>I was thinking about that earlier today weirdly enough just a random train of thought. The period would conflict with the string concatenation operator. It's why PHP's using `->` to dereference values in objects.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | yxpow | deb7zs0 | <|sols|><|sot|>Unlike existing PECL libsodium module which uses \Sodium namespace, functions will be renamed to sodium_* for inclusion in 7.2<|eot|><|sol|>https://wiki.php.net/rfc/libsodium<|eol|><|sor|>To be fair, PHP namespaces are fucking ugly.<|eor|><|sor|>'\' was probably the only free token they could use, since if they used `.` or `::` it'd probably introduce some weird as hell bugs.<|eor|><|sor|>I was thinking about that earlier today weirdly enough just a random train of thought. The period would conflict with the string concatenation operator. It's why PHP's using `->` to dereference values in objects.<|eor|><|sor|>When I used to write PHP I always surrounded `.` with spaces, because I'd had one too many instances of someone concatenating constants (like `SOME_VAL.$length`), which caused my mind to briefly flip to "languages that use `.` to access members" mode.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | n0t0ri0us9 | 5mwwld | <|sols|><|sot|>TIL: Strict types aren't working in PHP7.0 for generators /r/PHP<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/5mtpr0/til_strict_types_arent_working_in_php70_for/<|eol|><|eols|><|endoftext|> | 38 |
lolphp | n0t0ri0us9 | dc6y6yf | <|sols|><|sot|>TIL: Strict types aren't working in PHP7.0 for generators /r/PHP<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/5mtpr0/til_strict_types_arent_working_in_php70_for/<|eol|><|soopr|>The funniest part is the the the poor souls question "Is this behavior documented somewhere?" is completely ignored by the dev...<|eoopr|><|eols|><|endoftext|> | 20 |
lolphp | pilif | dc6yn75 | <|sols|><|sot|>TIL: Strict types aren't working in PHP7.0 for generators /r/PHP<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/5mtpr0/til_strict_types_arent_working_in_php70_for/<|eol|><|sor|>PHP has enough warts that aren't being fixed because of backwards compatibility or plain questionable opinions.
Let's not laugh about stuff that was actually fixed in the latest version of the language (7.1).<|eor|><|eols|><|endoftext|> | 19 |
lolphp | n0t0ri0us9 | dc732qt | <|sols|><|sot|>TIL: Strict types aren't working in PHP7.0 for generators /r/PHP<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/5mtpr0/til_strict_types_arent_working_in_php70_for/<|eol|><|sor|>PHP has enough warts that aren't being fixed because of backwards compatibility or plain questionable opinions.
Let's not laugh about stuff that was actually fixed in the latest version of the language (7.1).<|eor|><|soopr|>Suit yourself. I will stop laughing when people stop using this piece of shit.<|eoopr|><|eols|><|endoftext|> | 18 |
lolphp | 00Davo | 40on3p | <|sols|><|sot|>The order of interfaces in an implements clause is meaningful.<|eot|><|sol|>https://3v4l.org/0gFa6<|eol|><|eols|><|endoftext|> | 37 |
lolphp | cliath | cyvzbii | <|sols|><|sot|>The order of interfaces in an implements clause is meaningful.<|eot|><|sol|>https://3v4l.org/0gFa6<|eol|><|sor|>Only applies if you implement a derived class and its base class, the base class must go first. Not sure how I feel about this...<|eor|><|eols|><|endoftext|> | 15 |
lolphp | OneWingedShark | cyvvzwh | <|sols|><|sot|>The order of interfaces in an implements clause is meaningful.<|eot|><|sol|>https://3v4l.org/0gFa6<|eol|><|sor|>...that's crazy.<|eor|><|eols|><|endoftext|> | 14 |
lolphp | 00Davo | cywffiy | <|sols|><|sot|>The order of interfaces in an implements clause is meaningful.<|eot|><|sol|>https://3v4l.org/0gFa6<|eol|><|sor|>Only applies if you implement a derived class and its base class, the base class must go first. Not sure how I feel about this...<|eor|><|sor|>I'm not sure what the use case is. I mean, you're already declaring that you implement the base and the derived just by mentioning the derived. It's just implicit not explicit. My question here would be what benefit does being explicit in this instance actually provide? Or maybe this is an issue for tools that generate PHP code?<|eor|><|soopr|>It's certainly more a theoretical wart than a real inconvenience in practice. I discovered the restriction while doing something like this:
interface I {}
class A implements Foo, I, \Serializable {}
class B implements Foo, Bar, I, Baz, \Serializable {}
// five or six classes along those lines
// now we realise instances of I should always be serialisable!
interface I extends \Serializable {}
// every implementer of I is now broken, because implements was written in the "wrong" order
Rare, perhaps, but it really shouldn't be a fatal error.<|eoopr|><|eols|><|endoftext|> | 12 |
lolphp | Danack | cywk11l | <|sols|><|sot|>The order of interfaces in an implements clause is meaningful.<|eot|><|sol|>https://3v4l.org/0gFa6<|eol|><|sor|>Reported - https://bugs.php.net/bug.php?id=71358
btw there are some other *cough* edge-cases related to "implements":
* https://bugs.php.net/bug.php?id=69317
* https://bugs.php.net/bug.php?id=62609
* https://bugs.php.net/bug.php?id=60161
It's almost as if PHP has been grown organically without a clear plan of how it's type system should work from the start....<|eor|><|eols|><|endoftext|> | 9 |
lolphp | xrogaan | cywk73l | <|sols|><|sot|>The order of interfaces in an implements clause is meaningful.<|eot|><|sol|>https://3v4l.org/0gFa6<|eol|><|sor|>Reported - https://bugs.php.net/bug.php?id=71358
btw there are some other *cough* edge-cases related to "implements":
* https://bugs.php.net/bug.php?id=69317
* https://bugs.php.net/bug.php?id=62609
* https://bugs.php.net/bug.php?id=60161
It's almost as if PHP has been grown organically without a clear plan of how it's type system should work from the start....<|eor|><|sor|>What type system?<|eor|><|eols|><|endoftext|> | 6 |
lolphp | emilvikstrom | cywg5lo | <|sols|><|sot|>The order of interfaces in an implements clause is meaningful.<|eot|><|sol|>https://3v4l.org/0gFa6<|eol|><|sor|>Only applies if you implement a derived class and its base class, the base class must go first. Not sure how I feel about this...<|eor|><|sor|>I'm not sure what the use case is. I mean, you're already declaring that you implement the base and the derived just by mentioning the derived. It's just implicit not explicit. My question here would be what benefit does being explicit in this instance actually provide? Or maybe this is an issue for tools that generate PHP code?<|eor|><|sor|>You need to know that the derived interface extends the base interface, which might be just an implementation detail (and even change on short notice between minor versions of a library if the library developer doesn't know about this drawback). It creates [leaky abstractions](https://en.wikipedia.org/wiki/Leaky_abstraction).<|eor|><|eols|><|endoftext|> | 6 |
lolphp | arturaz | 3j775k | <|soss|><|sot|>When you try to connect to a Postgresql database with a password containing 1 or more spaces, pdo will fail to connect<|eot|><|sost|>http://stackoverflow.com/questions/13329787/pdo-cannot-connect-if-password-contains-spaces<|eost|><|eoss|><|endoftext|> | 36 |
lolphp | loptr | cun2kub | <|soss|><|sot|>When you try to connect to a Postgresql database with a password containing 1 or more spaces, pdo will fail to connect<|eot|><|sost|>http://stackoverflow.com/questions/13329787/pdo-cannot-connect-if-password-contains-spaces<|eost|><|sor|>So now every single bug in PHP and related libraries/functionality is a "lol"?
This was faulty code/parsing but it would have behaved the same way in other languages when coded with the same logic. This is was not a PHP language inconsistency just a bug in a function call that was fixed (a year ago).
You could also work around it by escaping the string yourself.
<|eor|><|eoss|><|endoftext|> | 25 |
lolphp | BufferUnderpants | cun8htd | <|soss|><|sot|>When you try to connect to a Postgresql database with a password containing 1 or more spaces, pdo will fail to connect<|eot|><|sost|>http://stackoverflow.com/questions/13329787/pdo-cannot-connect-if-password-contains-spaces<|eost|><|sor|>So now every single bug in PHP and related libraries/functionality is a "lol"?
This was faulty code/parsing but it would have behaved the same way in other languages when coded with the same logic. This is was not a PHP language inconsistency just a bug in a function call that was fixed (a year ago).
You could also work around it by escaping the string yourself.
<|eor|><|sor|>> So now every single bug in PHP and related libraries/functionality is a "lol"?
When it's as basic as this, yep.
> You could also work around it by escaping the string yourself.
How PHPesque.
<|eor|><|eoss|><|endoftext|> | 21 |
lolphp | mort96 | cumw6v3 | <|soss|><|sot|>When you try to connect to a Postgresql database with a password containing 1 or more spaces, pdo will fail to connect<|eot|><|sost|>http://stackoverflow.com/questions/13329787/pdo-cannot-connect-if-password-contains-spaces<|eost|><|sor|>It's not a bug, it's a feature!
Seriously, why are PHP bugs considered sacred and never fixed?<|eor|><|sor|>https://bugs.php.net/bug.php?id=62479
They seem to go straight on to fix it, not arguing about whether it should be fixed or not... Who's considering it sacred and arguing to not fix it?<|eor|><|eoss|><|endoftext|> | 15 |
lolphp | cbraga | cunk37o | <|soss|><|sot|>When you try to connect to a Postgresql database with a password containing 1 or more spaces, pdo will fail to connect<|eot|><|sost|>http://stackoverflow.com/questions/13329787/pdo-cannot-connect-if-password-contains-spaces<|eost|><|sor|>So now every single bug in PHP and related libraries/functionality is a "lol"?
This was faulty code/parsing but it would have behaved the same way in other languages when coded with the same logic. This is was not a PHP language inconsistency just a bug in a function call that was fixed (a year ago).
You could also work around it by escaping the string yourself.
<|eor|><|sor|>> So now every single bug in PHP and related libraries/functionality is a "lol"?
When it's as basic as this, yep.
> You could also work around it by escaping the string yourself.
How PHPesque.
<|eor|><|sor|>I thought we were in /r/phpapologists<|eor|><|sor|>I'm very, very disappointed that's not a real sub right now.<|eor|><|sor|>here this will keep you entertained
http://phpthegoodparts.tumblr.com/<|eor|><|eoss|><|endoftext|> | 15 |
lolphp | Miserable_Fuck | cunh2qa | <|soss|><|sot|>When you try to connect to a Postgresql database with a password containing 1 or more spaces, pdo will fail to connect<|eot|><|sost|>http://stackoverflow.com/questions/13329787/pdo-cannot-connect-if-password-contains-spaces<|eost|><|sor|>So now every single bug in PHP and related libraries/functionality is a "lol"?
This was faulty code/parsing but it would have behaved the same way in other languages when coded with the same logic. This is was not a PHP language inconsistency just a bug in a function call that was fixed (a year ago).
You could also work around it by escaping the string yourself.
<|eor|><|sor|>> So now every single bug in PHP and related libraries/functionality is a "lol"?
When it's as basic as this, yep.
> You could also work around it by escaping the string yourself.
How PHPesque.
<|eor|><|sor|>I thought we were in /r/phpapologists<|eor|><|sor|>Almost every single post has a few people arguing that "this isn't a *real* lol". Do these people not know what this sub is for?<|eor|><|eoss|><|endoftext|> | 14 |
lolphp | Sheepshow | cune4fb | <|soss|><|sot|>When you try to connect to a Postgresql database with a password containing 1 or more spaces, pdo will fail to connect<|eot|><|sost|>http://stackoverflow.com/questions/13329787/pdo-cannot-connect-if-password-contains-spaces<|eost|><|sor|>So now every single bug in PHP and related libraries/functionality is a "lol"?
This was faulty code/parsing but it would have behaved the same way in other languages when coded with the same logic. This is was not a PHP language inconsistency just a bug in a function call that was fixed (a year ago).
You could also work around it by escaping the string yourself.
<|eor|><|sor|>> So now every single bug in PHP and related libraries/functionality is a "lol"?
When it's as basic as this, yep.
> You could also work around it by escaping the string yourself.
How PHPesque.
<|eor|><|sor|>I thought we were in /r/phpapologists<|eor|><|eoss|><|endoftext|> | 10 |
lolphp | ozamosi | cunhamf | <|soss|><|sot|>When you try to connect to a Postgresql database with a password containing 1 or more spaces, pdo will fail to connect<|eot|><|sost|>http://stackoverflow.com/questions/13329787/pdo-cannot-connect-if-password-contains-spaces<|eost|><|sor|>So now every single bug in PHP and related libraries/functionality is a "lol"?
This was faulty code/parsing but it would have behaved the same way in other languages when coded with the same logic. This is was not a PHP language inconsistency just a bug in a function call that was fixed (a year ago).
You could also work around it by escaping the string yourself.
<|eor|><|sor|>> So now every single bug in PHP and related libraries/functionality is a "lol"?
When it's as basic as this, yep.
> You could also work around it by escaping the string yourself.
How PHPesque.
<|eor|><|sor|>I thought we were in /r/phpapologists<|eor|><|sor|>I'm very, very disappointed that's not a real sub right now.<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | thelordofcheese | cumxk68 | <|soss|><|sot|>When you try to connect to a Postgresql database with a password containing 1 or more spaces, pdo will fail to connect<|eot|><|sost|>http://stackoverflow.com/questions/13329787/pdo-cannot-connect-if-password-contains-spaces<|eost|><|sor|>It's not a bug, it's a feature!
Seriously, why are PHP bugs considered sacred and never fixed?<|eor|><|sor|>https://bugs.php.net/bug.php?id=62479
They seem to go straight on to fix it, not arguing about whether it should be fixed or not... Who's considering it sacred and arguing to not fix it?<|eor|><|sor|>There are some bugs in PHP they refuse to fix because people are used to it<|eor|><|sor|>This is why they should have made default namespaces for versions with the option of setting namespaces for individual documents when they introduced namespaces, and then fixed all the issues.<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | mort96 | cumwnzg | <|soss|><|sot|>When you try to connect to a Postgresql database with a password containing 1 or more spaces, pdo will fail to connect<|eot|><|sost|>http://stackoverflow.com/questions/13329787/pdo-cannot-connect-if-password-contains-spaces<|eost|><|sor|>It's not a bug, it's a feature!
Seriously, why are PHP bugs considered sacred and never fixed?<|eor|><|sor|>https://bugs.php.net/bug.php?id=62479
They seem to go straight on to fix it, not arguing about whether it should be fixed or not... Who's considering it sacred and arguing to not fix it?<|eor|><|sor|>There are some bugs in PHP they refuse to fix because people are used to it<|eor|><|sor|>That may be true, but I don't see how that's relevant to this particular bug.<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | svens_ | 2ktgh2 | <|sols|><|sot|>PHP Type Coercion at it again. Be careful when comparing hashes. [x-post]<|eot|><|sol|>https://eval.in/108854<|eol|><|eols|><|endoftext|> | 39 |
lolphp | Banane9 | clomr9v | <|sols|><|sot|>PHP Type Coercion at it again. Be careful when comparing hashes. [x-post]<|eot|><|sol|>https://eval.in/108854<|eol|><|sor|>I think it's funny how they try to explain this shit by saying "oh it's in the documentation".
Any beginner would fall for this, unless anyone tells them to always use ===<|eor|><|eols|><|endoftext|> | 15 |
lolphp | ismtrn | clolbea | <|sols|><|sot|>PHP Type Coercion at it again. Be careful when comparing hashes. [x-post]<|eot|><|sol|>https://eval.in/108854<|eol|><|sor|>Why on earth would be convert two strings to numbers to compare them? WHY? It is especially fucked up when your mapping into numbers isn't even injective.<|eor|><|eols|><|endoftext|> | 15 |
lolphp | svens_ | cloj5uu | <|sols|><|sot|>PHP Type Coercion at it again. Be careful when comparing hashes. [x-post]<|eot|><|sol|>https://eval.in/108854<|eol|><|soopr|>[Here's](http://www.reddit.com/r/PHP/comments/2krumr/what_in_gods_name_is_going_on_here/) the discussion on /r/php, for those of you who don't subscribe to it.<|eoopr|><|eols|><|endoftext|> | 11 |
lolphp | ThisIsADogHello | clpded6 | <|sols|><|sot|>PHP Type Coercion at it again. Be careful when comparing hashes. [x-post]<|eot|><|sol|>https://eval.in/108854<|eol|><|soopr|>[Here's](http://www.reddit.com/r/PHP/comments/2krumr/what_in_gods_name_is_going_on_here/) the discussion on /r/php, for those of you who don't subscribe to it.<|eoopr|><|sor|>Good god, the amount of apologism in there is baffling. Extra baffling is the people saying essentially "it's documented, and I understood what it said, therefore you're an idiot for not understanding it."<|eor|><|eols|><|endoftext|> | 6 |
lolphp | Gnolfo | clp79ey | <|sols|><|sot|>PHP Type Coercion at it again. Be careful when comparing hashes. [x-post]<|eot|><|sol|>https://eval.in/108854<|eol|><|sor|>Why on earth would be convert two strings to numbers to compare them? WHY? It is especially fucked up when your mapping into numbers isn't even injective.<|eor|><|sor|>[deleted]<|eor|><|sor|>If it were injective it wouldn't ruin the string equality. In that case they could convert it to whatever the fuck they wanted. When an equality test between the strings "1.0" and "1.00" maps both into the same element before comparing, it is a shitty equality test.<|eor|><|sor|>String -> number conversion shouldn't be injective. That's not what php is doing wrong in this instance. "1.0" and "1.00" casting into the same float or whatever is definitely the behavior you want... when you want to cast. It's their implicit coercion rules running amok that breaks the intended equality test, and hence the added complexity: "For equality checks use == or ===, depending on your current definition of equality".<|eor|><|eols|><|endoftext|> | 5 |
lolphp | DoubleNabla | 2hgz0t | <|sols|><|sot|>PDO emulates prepared statements using mysql_real_escape_string(), which does a great job as you'd expect...<|eot|><|sol|>http://stackoverflow.com/questions/134099/are-pdo-prepared-statements-sufficient-to-prevent-sql-injection/12202218#12202218<|eol|><|eols|><|endoftext|> | 33 |
lolphp | Various_Pickles | cksn4l7 | <|sols|><|sot|>PDO emulates prepared statements using mysql_real_escape_string(), which does a great job as you'd expect...<|eot|><|sol|>http://stackoverflow.com/questions/134099/are-pdo-prepared-statements-sufficient-to-prevent-sql-injection/12202218#12202218<|eol|><|sor|> mysql_our_timestamps_didnt_have_timezones_for_a_decade_sry_kthx<|eor|><|eols|><|endoftext|> | 21 |
lolphp | pilif | ckt5waq | <|sols|><|sot|>PDO emulates prepared statements using mysql_real_escape_string(), which does a great job as you'd expect...<|eot|><|sol|>http://stackoverflow.com/questions/134099/are-pdo-prepared-statements-sufficient-to-prevent-sql-injection/12202218#12202218<|eol|><|sor|>The real WTF is MySQL:
> An alternative is `utf8`, which is also not vulnerable and can support the whole of the Unicode Basic Multilingual Plane.
Only in MySQL a character encoding called 'utf8' would not in-fact be utf-8.
Doesn't surprise me in the least.<|eor|><|eols|><|endoftext|> | 14 |
lolphp | DoubleNabla | cksjy2p | <|sols|><|sot|>PDO emulates prepared statements using mysql_real_escape_string(), which does a great job as you'd expect...<|eot|><|sol|>http://stackoverflow.com/questions/134099/are-pdo-prepared-statements-sufficient-to-prevent-sql-injection/12202218#12202218<|eol|><|soopr|>Found in /r/php (https://www.reddit.com/r/PHP/comments/2h2xer/php_moronic_monday_22092014/ckp486a).
Also, it looks like we're going to need a `mysql_real_real_escape_string`.<|eoopr|><|eols|><|endoftext|> | 11 |
lolphp | cythrawll | cksx7cq | <|sols|><|sot|>PDO emulates prepared statements using mysql_real_escape_string(), which does a great job as you'd expect...<|eot|><|sol|>http://stackoverflow.com/questions/134099/are-pdo-prepared-statements-sufficient-to-prevent-sql-injection/12202218#12202218<|eol|><|sor|>to be fair they aren't talking about the PHP `mysql_real_escape_string()` but the C version in the MySQL API.
Stupid that it emulates prepared statements by default. What's the point of that?<|eor|><|sor|>This one actually was MySQL's fault as well. When PDO first came out, real prepared statements broke the query cache. And PHP devs thought the gotcha was worth defaulting to real statements. Now MySQL's has had that fixed for years. But there is enough behavior differences that make it difficult to switch the default without potentiallly breaking code in obscure ways.
Any way I highly suggest turning emulation off in the first place.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | poizan42 | ckueah5 | <|sols|><|sot|>PDO emulates prepared statements using mysql_real_escape_string(), which does a great job as you'd expect...<|eot|><|sol|>http://stackoverflow.com/questions/134099/are-pdo-prepared-statements-sufficient-to-prevent-sql-injection/12202218#12202218<|eol|><|sor|>The real WTF is MySQL:
> An alternative is `utf8`, which is also not vulnerable and can support the whole of the Unicode Basic Multilingual Plane.
Only in MySQL a character encoding called 'utf8' would not in-fact be utf-8.
Doesn't surprise me in the least.<|eor|><|sor|>You wish. In fact Oracle has the exact same problem. The real utf8 is called al32utf8 in Oracle databases...<|eor|><|eols|><|endoftext|> | 10 |
lolphp | Various_Pickles | cktrhm8 | <|sols|><|sot|>PDO emulates prepared statements using mysql_real_escape_string(), which does a great job as you'd expect...<|eot|><|sol|>http://stackoverflow.com/questions/134099/are-pdo-prepared-statements-sufficient-to-prevent-sql-injection/12202218#12202218<|eol|><|sor|> mysql_our_timestamps_didnt_have_timezones_for_a_decade_sry_kthx<|eor|><|sor|>You *still* can't store a datetime with a timezone in MySQL. Every datetime is given and expected in a *connection-wide* timezone, but stored in UTC. It's a big fat gotcha.<|eor|><|sor|>A recorded "time" is [completely fucking meaningless without a timezone](https://www.youtube.com/watch?v=-5wpm-gesOY&list=TL7CMuKm2PEMUzqui-z9CP29YV2dhO2y3x).<|eor|><|eols|><|endoftext|> | 6 |
lolphp | frezik | cl1ucma | <|sols|><|sot|>PDO emulates prepared statements using mysql_real_escape_string(), which does a great job as you'd expect...<|eot|><|sol|>http://stackoverflow.com/questions/134099/are-pdo-prepared-statements-sufficient-to-prevent-sql-injection/12202218#12202218<|eol|><|sor|>to be fair they aren't talking about the PHP `mysql_real_escape_string()` but the C version in the MySQL API.
Stupid that it emulates prepared statements by default. What's the point of that?<|eor|><|sor|>This one actually was MySQL's fault as well. When PDO first came out, real prepared statements broke the query cache. And PHP devs thought the gotcha was worth defaulting to real statements. Now MySQL's has had that fixed for years. But there is enough behavior differences that make it difficult to switch the default without potentiallly breaking code in obscure ways.
Any way I highly suggest turning emulation off in the first place.<|eor|><|sor|>I've always been impressed with how PHP and MySQL combine to create a singularity of suck.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | DoubleNabla | cktib9y | <|sols|><|sot|>PDO emulates prepared statements using mysql_real_escape_string(), which does a great job as you'd expect...<|eot|><|sol|>http://stackoverflow.com/questions/134099/are-pdo-prepared-statements-sufficient-to-prevent-sql-injection/12202218#12202218<|eol|><|sor|>On a sidenote. Can anybody explain why setting the encoding is done with the command `SET NAMES`?!?!<|eor|><|soopr|>The [standard](http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt) says:
> The default character set **name** [...] can subsequently be changed by the successful execution of a <set names statement>.
That was, of course, the most descriptive command they could come up with. Bonus points for "NAME**s**" affecting the name of a single thing.<|eoopr|><|eols|><|endoftext|> | 5 |
lolphp | allthediamonds | 2ettnx | <|sols|><|sot|>The joys of using `array_intersect`<|eot|><|sol|>https://eval.in/184830<|eol|><|eols|><|endoftext|> | 35 |
lolphp | allthediamonds | ck2u88w | <|sols|><|sot|>The joys of using `array_intersect`<|eot|><|sol|>https://eval.in/184830<|eol|><|soopr|>For some goddamn reason, `array_intersect` compares values by strict equality of those values *when casted to string*.<|eoopr|><|eols|><|endoftext|> | 18 |
lolphp | andsens | ck2wgpy | <|sols|><|sot|>The joys of using `array_intersect`<|eot|><|sol|>https://eval.in/184830<|eol|><|soopr|>For some goddamn reason, `array_intersect` compares values by strict equality of those values *when casted to string*.<|eoopr|><|sor|>Heh, yeah. I stumbled upon that fuck-up as well about a month ago. We wound using [Underscore.php](http://brianhaveri.github.io/Underscore.php/) instead, especially because the names actually make sense now.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | allthediamonds | ck3m3rl | <|sols|><|sot|>The joys of using `array_intersect`<|eot|><|sol|>https://eval.in/184830<|eol|><|soopr|>For some goddamn reason, `array_intersect` compares values by strict equality of those values *when casted to string*.<|eoopr|><|sor|>[deleted]<|eor|><|soopr|>Yep, just like with everything else, there are workarounds.<|eoopr|><|eols|><|endoftext|> | 6 |
lolphp | TortoiseWrath | 2bdolv | <|sols|><|sot|>PHP 5.6 to include variadic functions. We have now caught up to ALGOL 68 in functionality.<|eot|><|sol|>http://php.net/manual/en/migration56.new-features.php<|eol|><|eols|><|endoftext|> | 36 |
lolphp | nikic | cj4n0sn | <|sols|><|sot|>PHP 5.6 to include variadic functions. We have now caught up to ALGOL 68 in functionality.<|eot|><|sol|>http://php.net/manual/en/migration56.new-features.php<|eol|><|sor|>Note: PHP has always had [variadic functions](http://php.net/func_get_args), this is just a more convenient and clear way to implement them.
The only thing this adds which was not possible previously, are *by-ref* variadics for userland functions.<|eor|><|eols|><|endoftext|> | 21 |
lolphp | ajmarks | cj4bcl5 | <|sols|><|sot|>PHP 5.6 to include variadic functions. We have now caught up to ALGOL 68 in functionality.<|eot|><|sol|>http://php.net/manual/en/migration56.new-features.php<|eol|><|sor|>But they still don't have named arguments (because Rasmatazz thinks they're ugly or something), so you can't use variadic features unless you specify all optional arguments, and you can't use it well as a pass-through to another function.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | h0rst_ | cj4nla3 | <|sols|><|sot|>PHP 5.6 to include variadic functions. We have now caught up to ALGOL 68 in functionality.<|eot|><|sol|>http://php.net/manual/en/migration56.new-features.php<|eol|><|sor|>But they still don't have named arguments (because Rasmatazz thinks they're ugly or something), so you can't use variadic features unless you specify all optional arguments, and you can't use it well as a pass-through to another function.<|eor|><|sor|>But at least you have a method to use the default value: https://wiki.php.net/rfc/skipparams
I don't think I could think of an uglier way of doing this.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | ajmarks | cj4udep | <|sols|><|sot|>PHP 5.6 to include variadic functions. We have now caught up to ALGOL 68 in functionality.<|eot|><|sol|>http://php.net/manual/en/migration56.new-features.php<|eol|><|sor|>What's the use of variadic functions?<|eor|><|sor|>In Python, I use them all the time as wrappers. For example, consider this:
def retry_call(func, max_tries=10, exc_list=(IOError, ValueError), *args, **kwargs):
for i in range(max_tries):
try:
return func(*args, **kwargs)
except exc_list as exc:
if i + 1 < max_tries:
log_error(exc, args, kwargs)
else:
raise
I have a function that tries to call (and return) `func` up to max_tries times, catching and logging only those exceptions specified by the third argument, passing on anything after it to the `func` as arguments. In fact, because Python takes named arguments, I could do `retry_call(requests.get, url='http://foo.bar')` or `retry_call(requests.get, 100, url='http://foo.bar', proxies=proxy_info)`.<|eor|><|sor|>also very useful with decorators, but... PHP doesn't have decorators.<|eor|><|sor|>I would pay serious money to see the stupid way PHP decides to implement decorators.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | ajmarks | cj4o6s1 | <|sols|><|sot|>PHP 5.6 to include variadic functions. We have now caught up to ALGOL 68 in functionality.<|eot|><|sol|>http://php.net/manual/en/migration56.new-features.php<|eol|><|sor|>But they still don't have named arguments (because Rasmatazz thinks they're ugly or something), so you can't use variadic features unless you specify all optional arguments, and you can't use it well as a pass-through to another function.<|eor|><|sor|>But at least you have a method to use the default value: https://wiki.php.net/rfc/skipparams
I don't think I could think of an uglier way of doing this.<|eor|><|sor|>I just threw up a little in my mouth.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | infinull | cj4u22h | <|sols|><|sot|>PHP 5.6 to include variadic functions. We have now caught up to ALGOL 68 in functionality.<|eot|><|sol|>http://php.net/manual/en/migration56.new-features.php<|eol|><|sor|>What's the use of variadic functions?<|eor|><|sor|>In Python, I use them all the time as wrappers. For example, consider this:
def retry_call(func, max_tries=10, exc_list=(IOError, ValueError), *args, **kwargs):
for i in range(max_tries):
try:
return func(*args, **kwargs)
except exc_list as exc:
if i + 1 < max_tries:
log_error(exc, args, kwargs)
else:
raise
I have a function that tries to call (and return) `func` up to max_tries times, catching and logging only those exceptions specified by the third argument, passing on anything after it to the `func` as arguments. In fact, because Python takes named arguments, I could do `retry_call(requests.get, url='http://foo.bar')` or `retry_call(requests.get, 100, url='http://foo.bar', proxies=proxy_info)`.<|eor|><|sor|>also very useful with decorators, but... PHP doesn't have decorators.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | Sarcastinator | cj4btj8 | <|sols|><|sot|>PHP 5.6 to include variadic functions. We have now caught up to ALGOL 68 in functionality.<|eot|><|sol|>http://php.net/manual/en/migration56.new-features.php<|eol|><|sor|>Constants can't be expressions?!
lol php.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | ajmarks | cj4e0c5 | <|sols|><|sot|>PHP 5.6 to include variadic functions. We have now caught up to ALGOL 68 in functionality.<|eot|><|sol|>http://php.net/manual/en/migration56.new-features.php<|eol|><|sor|>What's the use of variadic functions?<|eor|><|sor|>In Python, I use them all the time as wrappers. For example, consider this:
def retry_call(func, max_tries=10, exc_list=(IOError, ValueError), *args, **kwargs):
for i in range(max_tries):
try:
return func(*args, **kwargs)
except exc_list as exc:
if i + 1 < max_tries:
log_error(exc, args, kwargs)
else:
raise
I have a function that tries to call (and return) `func` up to max_tries times, catching and logging only those exceptions specified by the third argument, passing on anything after it to the `func` as arguments. In fact, because Python takes named arguments, I could do `retry_call(requests.get, url='http://foo.bar')` or `retry_call(requests.get, 100, url='http://foo.bar', proxies=proxy_info)`.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | nikic | cj5c6lh | <|sols|><|sot|>PHP 5.6 to include variadic functions. We have now caught up to ALGOL 68 in functionality.<|eot|><|sol|>http://php.net/manual/en/migration56.new-features.php<|eol|><|sor|>But they still don't have named arguments (because Rasmatazz thinks they're ugly or something), so you can't use variadic features unless you specify all optional arguments, and you can't use it well as a pass-through to another function.<|eor|><|sor|>But at least you have a method to use the default value: https://wiki.php.net/rfc/skipparams
I don't think I could think of an uglier way of doing this.<|eor|><|sor|>Whatever gave you the idea that that proposal was implemented? It wasn't.
There's also a proposal and implementation for named arguments lying around: https://wiki.php.net/rfc/named_params<|eor|><|eols|><|endoftext|> | 7 |
lolphp | Serialk | 20yfrt | <|sols|><|sot|>"Hack": No matter how hard you try, a nice-looking PHP is still PHP.<|eot|><|sol|>http://hacklang.org/<|eol|><|eols|><|endoftext|> | 32 |
lolphp | HelloAnnyong | cg83ra8 | <|sols|><|sot|>"Hack": No matter how hard you try, a nice-looking PHP is still PHP.<|eot|><|sol|>http://hacklang.org/<|eol|><|sor|>To be fair, once you make it static typed and eliminate the coercion, you will have taken a lot of lol out of PHP. That said, there's still enough lol left for twelve languages. <|eor|><|sor|>That's what I'd expect from it. PHP gets ternary operator wrong? Flag as error. Coercion in PHP is wonky? Flag as error. Just refuse to compile any of the broken aspects of the language, like "lint" for PHP.
And since it's PHP, you won't have much left. So then add back *new* anything you're missing.
And because there's still a decent amount of overlap, porting code from PHP to Hack will be easier than porting to anything else. Heck, it might make it easier to port to something else than porting directly from PHP.<|eor|><|sor|>There's a science fiction short story about a VR world running on a supercomputer. As more and more customers plug into it, it starts running out of space and processing power, so its creators tell it to optimize itself on the fly, by removing parts of the experience that don't contribute to the end result.
It starts removing idle moments, unmemorable experiences, boring memories. But eventually it figures out it can just remove the entire experience altogether and skip to the end result which is everyone's deaths.
I imagine a PHP linter would eventually be something like that,
> Error: code in between `<?php` `?>` tags<|eor|><|eols|><|endoftext|> | 42 |
lolphp | ajmarks | cg7yvya | <|sols|><|sot|>"Hack": No matter how hard you try, a nice-looking PHP is still PHP.<|eot|><|sol|>http://hacklang.org/<|eol|><|sor|>To be fair, once you make it static typed and eliminate the coercion, you will have taken a lot of lol out of PHP. That said, there's still enough lol left for twelve languages. <|eor|><|eols|><|endoftext|> | 35 |
lolphp | cparen | cg81vk5 | <|sols|><|sot|>"Hack": No matter how hard you try, a nice-looking PHP is still PHP.<|eot|><|sol|>http://hacklang.org/<|eol|><|sor|>To be fair, once you make it static typed and eliminate the coercion, you will have taken a lot of lol out of PHP. That said, there's still enough lol left for twelve languages. <|eor|><|sor|>That's what I'd expect from it. PHP gets ternary operator wrong? Flag as error. Coercion in PHP is wonky? Flag as error. Just refuse to compile any of the broken aspects of the language, like "lint" for PHP.
And since it's PHP, you won't have much left. So then add back *new* anything you're missing.
And because there's still a decent amount of overlap, porting code from PHP to Hack will be easier than porting to anything else. Heck, it might make it easier to port to something else than porting directly from PHP.<|eor|><|eols|><|endoftext|> | 18 |
lolphp | tdammers | cg8670i | <|sols|><|sot|>"Hack": No matter how hard you try, a nice-looking PHP is still PHP.<|eot|><|sol|>http://hacklang.org/<|eol|><|sor|>To be fair, once you make it static typed and eliminate the coercion, you will have taken a lot of lol out of PHP. That said, there's still enough lol left for twelve languages. <|eor|><|sor|>That's what I'd expect from it. PHP gets ternary operator wrong? Flag as error. Coercion in PHP is wonky? Flag as error. Just refuse to compile any of the broken aspects of the language, like "lint" for PHP.
And since it's PHP, you won't have much left. So then add back *new* anything you're missing.
And because there's still a decent amount of overlap, porting code from PHP to Hack will be easier than porting to anything else. Heck, it might make it easier to port to something else than porting directly from PHP.<|eor|><|sor|>There's a science fiction short story about a VR world running on a supercomputer. As more and more customers plug into it, it starts running out of space and processing power, so its creators tell it to optimize itself on the fly, by removing parts of the experience that don't contribute to the end result.
It starts removing idle moments, unmemorable experiences, boring memories. But eventually it figures out it can just remove the entire experience altogether and skip to the end result which is everyone's deaths.
I imagine a PHP linter would eventually be something like that,
> Error: code in between `<?php` `?>` tags<|eor|><|sor|>:-) but seriously, php didn't get *everything* wrong. Otherwise you could just derive the inverse programming language from it and all of Programming Language Theory would be complete -- and I wouldn't grant PHP such an honor.
In all seriousness, it's certainly better than trying to program in [Intercal]( http://en.m.wikipedia.org/wiki/INTERCAL). It was intended for slap-dash programming, and it's well suited for it. As others have said before in this sub, PHP isn't the villian. Rather, *industry* is the villian for having adopted PHP so heavily when someone really ought to have known better.<|eor|><|sor|>It's more subtle than that. PHP got a few crucial things right:
* Exist at the right moment in time
* Provide a very subtle bridge from writing static HTML pages to server-side scripting (no other language I know of makes this as simple as changing the extension to '.php' and throwing in a few `<?php ?>` "tags)
* Somehow make it onto every shitty shared hosting service in the world
* Be loud and attract lots of highschoolers, hobbyists, and boss' nephews to spread the gospel.<|eor|><|eols|><|endoftext|> | 18 |
lolphp | cparen | cg84030 | <|sols|><|sot|>"Hack": No matter how hard you try, a nice-looking PHP is still PHP.<|eot|><|sol|>http://hacklang.org/<|eol|><|sor|>To be fair, once you make it static typed and eliminate the coercion, you will have taken a lot of lol out of PHP. That said, there's still enough lol left for twelve languages. <|eor|><|sor|>That's what I'd expect from it. PHP gets ternary operator wrong? Flag as error. Coercion in PHP is wonky? Flag as error. Just refuse to compile any of the broken aspects of the language, like "lint" for PHP.
And since it's PHP, you won't have much left. So then add back *new* anything you're missing.
And because there's still a decent amount of overlap, porting code from PHP to Hack will be easier than porting to anything else. Heck, it might make it easier to port to something else than porting directly from PHP.<|eor|><|sor|>There's a science fiction short story about a VR world running on a supercomputer. As more and more customers plug into it, it starts running out of space and processing power, so its creators tell it to optimize itself on the fly, by removing parts of the experience that don't contribute to the end result.
It starts removing idle moments, unmemorable experiences, boring memories. But eventually it figures out it can just remove the entire experience altogether and skip to the end result which is everyone's deaths.
I imagine a PHP linter would eventually be something like that,
> Error: code in between `<?php` `?>` tags<|eor|><|sor|>:-) but seriously, php didn't get *everything* wrong. Otherwise you could just derive the inverse programming language from it and all of Programming Language Theory would be complete -- and I wouldn't grant PHP such an honor.
In all seriousness, it's certainly better than trying to program in [Intercal]( http://en.m.wikipedia.org/wiki/INTERCAL). It was intended for slap-dash programming, and it's well suited for it. As others have said before in this sub, PHP isn't the villian. Rather, *industry* is the villian for having adopted PHP so heavily when someone really ought to have known better.<|eor|><|eols|><|endoftext|> | 15 |
lolphp | allthediamonds | cg874f7 | <|sols|><|sot|>"Hack": No matter how hard you try, a nice-looking PHP is still PHP.<|eot|><|sol|>http://hacklang.org/<|eol|><|sor|>To be fair, once you make it static typed and eliminate the coercion, you will have taken a lot of lol out of PHP. That said, there's still enough lol left for twelve languages. <|eor|><|sor|>That's what I'd expect from it. PHP gets ternary operator wrong? Flag as error. Coercion in PHP is wonky? Flag as error. Just refuse to compile any of the broken aspects of the language, like "lint" for PHP.
And since it's PHP, you won't have much left. So then add back *new* anything you're missing.
And because there's still a decent amount of overlap, porting code from PHP to Hack will be easier than porting to anything else. Heck, it might make it easier to port to something else than porting directly from PHP.<|eor|><|sor|>There's a science fiction short story about a VR world running on a supercomputer. As more and more customers plug into it, it starts running out of space and processing power, so its creators tell it to optimize itself on the fly, by removing parts of the experience that don't contribute to the end result.
It starts removing idle moments, unmemorable experiences, boring memories. But eventually it figures out it can just remove the entire experience altogether and skip to the end result which is everyone's deaths.
I imagine a PHP linter would eventually be something like that,
> Error: code in between `<?php` `?>` tags<|eor|><|sor|>:-) but seriously, php didn't get *everything* wrong. Otherwise you could just derive the inverse programming language from it and all of Programming Language Theory would be complete -- and I wouldn't grant PHP such an honor.
In all seriousness, it's certainly better than trying to program in [Intercal]( http://en.m.wikipedia.org/wiki/INTERCAL). It was intended for slap-dash programming, and it's well suited for it. As others have said before in this sub, PHP isn't the villian. Rather, *industry* is the villian for having adopted PHP so heavily when someone really ought to have known better.<|eor|><|sor|>It's more subtle than that. PHP got a few crucial things right:
* Exist at the right moment in time
* Provide a very subtle bridge from writing static HTML pages to server-side scripting (no other language I know of makes this as simple as changing the extension to '.php' and throwing in a few `<?php ?>` "tags)
* Somehow make it onto every shitty shared hosting service in the world
* Be loud and attract lots of highschoolers, hobbyists, and boss' nephews to spread the gospel.<|eor|><|sor|>> Somehow make it onto every shitty shared hosting service in the world
We can (and should) blame Apache for that.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | cbraga | cg8dbht | <|sols|><|sot|>"Hack": No matter how hard you try, a nice-looking PHP is still PHP.<|eot|><|sol|>http://hacklang.org/<|eol|><|sor|>They certainly picked the right name for their project
<|eor|><|eols|><|endoftext|> | 9 |
lolphp | Innominate8 | cg8qj0q | <|sols|><|sot|>"Hack": No matter how hard you try, a nice-looking PHP is still PHP.<|eot|><|sol|>http://hacklang.org/<|eol|><|sor|>To be fair, once you make it static typed and eliminate the coercion, you will have taken a lot of lol out of PHP. That said, there's still enough lol left for twelve languages. <|eor|><|sor|>Once you take that first step and break backwards compatibility, suddenly fixing the rest of the language becomes possible.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | mirhagk | cg887sn | <|sols|><|sot|>"Hack": No matter how hard you try, a nice-looking PHP is still PHP.<|eot|><|sol|>http://hacklang.org/<|eol|><|sor|>To be fair, once you make it static typed and eliminate the coercion, you will have taken a lot of lol out of PHP. That said, there's still enough lol left for twelve languages. <|eor|><|sor|>That's what I'd expect from it. PHP gets ternary operator wrong? Flag as error. Coercion in PHP is wonky? Flag as error. Just refuse to compile any of the broken aspects of the language, like "lint" for PHP.
And since it's PHP, you won't have much left. So then add back *new* anything you're missing.
And because there's still a decent amount of overlap, porting code from PHP to Hack will be easier than porting to anything else. Heck, it might make it easier to port to something else than porting directly from PHP.<|eor|><|sor|>There's a science fiction short story about a VR world running on a supercomputer. As more and more customers plug into it, it starts running out of space and processing power, so its creators tell it to optimize itself on the fly, by removing parts of the experience that don't contribute to the end result.
It starts removing idle moments, unmemorable experiences, boring memories. But eventually it figures out it can just remove the entire experience altogether and skip to the end result which is everyone's deaths.
I imagine a PHP linter would eventually be something like that,
> Error: code in between `<?php` `?>` tags<|eor|><|sor|>:-) but seriously, php didn't get *everything* wrong. Otherwise you could just derive the inverse programming language from it and all of Programming Language Theory would be complete -- and I wouldn't grant PHP such an honor.
In all seriousness, it's certainly better than trying to program in [Intercal]( http://en.m.wikipedia.org/wiki/INTERCAL). It was intended for slap-dash programming, and it's well suited for it. As others have said before in this sub, PHP isn't the villian. Rather, *industry* is the villian for having adopted PHP so heavily when someone really ought to have known better.<|eor|><|sor|>It's more subtle than that. PHP got a few crucial things right:
* Exist at the right moment in time
* Provide a very subtle bridge from writing static HTML pages to server-side scripting (no other language I know of makes this as simple as changing the extension to '.php' and throwing in a few `<?php ?>` "tags)
* Somehow make it onto every shitty shared hosting service in the world
* Be loud and attract lots of highschoolers, hobbyists, and boss' nephews to spread the gospel.<|eor|><|sor|>> no other language I know of makes this as simple as changing the extension to '.php' and throwing in a few <?php ?> "tags
[Classic ASP](https://en.wikipedia.org/wiki/Active_Server_Pages) supports a very similar syntax, and has a lot of the same fundamental problems as PHP (it's inability to scale, the ease of making critical security bugs). Coldfusion markup also works as does java server pages, lasso as well as many others.
What these don't have is a very large install base. <|eor|><|eols|><|endoftext|> | 6 |
lolphp | lisp-case | 1z4i00 | <|sols|><|sot|>Mcrypt: "Catastrophic crypto failure? That's worth a warning. Maybe."<|eot|><|sol|>http://www.leaseweblabs.com/2014/02/aes-php-mcrypt-key-padding/<|eol|><|eols|><|endoftext|> | 35 |
lolphp | lisp-case | cfqh9fu | <|sols|><|sot|>Mcrypt: "Catastrophic crypto failure? That's worth a warning. Maybe."<|eot|><|sol|>http://www.leaseweblabs.com/2014/02/aes-php-mcrypt-key-padding/<|eol|><|soopr|>Okay, lessons learned from reading this article:
Don't use Mcrypt.
Seriously, look at this API:
> AES-256 is different from RIJNDAEL-256. The 256 in AES refers to the key size, where the 256 in RIJNDAEL refers to block size. AES-256 is RIJNDAEL-128 when used with a 256 bit key.
So we can infer that the constants don't actually line up to algorithms as they are referred to in practice. Not even for AES, the most official (and thus most widespread) modern cipher. *Okay.*
> if you feed Mcrypt a smaller key [than the cipher is expecting] it will automatically pad it to an acceptable size using zero bytes.
So your key generation fucked up and you aren't actually getting the guarantees you thought you were, but Mcrypt will "helpfully" encrypt things anyway, in the limit providing you with no security whatsoever. And this doesn't even generate a warning.
> Mcrypt accepts any size of plain text and solves this [block-size] issue for you by automatically padding it with zero bytes.
Oh good, it defaults to the kind of padding you can't deterministically reverse . How "helpful". (Again, no warning.)
> If the initialization vector does not have the right size (16 bytes), then Mcrypt outputs a warning and uses an empty initialization vector.
*Catastrophic failure* generating a *warning*, Part The Second. In a lot of ways this is even *worse* than the key length thing, since if you ended up with a shorter key than you expected you probably still have *some* security; meanwhile a cryptosystem that repeats IVs can generally be considered "completely broken".
Okay, how much worse can this get? Let's look at the rest of the API *oh God*
> If the self test succeeds it returns FALSE. In case of an error, it returns TRUE.
In other words *exactly the opposite* of what a nave user (i.e. me, having never looked at this API before) would expect. That's great.
ECB is an option. This is a horrible idea.
OFB with partial feedback is an option, despite being another bad idea. At least they recommend against this one.
All available modes of operation are malleable; you get to add authentication yourself. (Encrypt, then MAC. Always in that order.)
No CTR mode, despite being the best-regarded non-authenticated mode of operation in current practice.
No padding functions. You get to do that yourself, too. Hope you don't accidentally introduce a padding oracle.
No key derivation functions. Another thing you get to do yourself.
Non-copypaste-safe example: 3DES in ECB mode, no KDF, no MAC. Oh, also no error checking. Probably strings the primitives through the API correctly, but it's doing just about everything else wrong.
Speaking of stringing primitives through the API, that looks like a *ridiculous* number of things that can go wrong. Is there a particular reason it takes this many lines to do `$ciphertext = encrypt($cipher, $key, $plaintext);`? Or at most, `$ciphertext = encrypt($cipher, derive_key($work_factor, $password), $plaintext);`?
Tl;dr: run^as^fast^as^you^can
Edit: how do acronyms work<|eoopr|><|eols|><|endoftext|> | 19 |
lolphp | iopq | cfqxled | <|sols|><|sot|>Mcrypt: "Catastrophic crypto failure? That's worth a warning. Maybe."<|eot|><|sol|>http://www.leaseweblabs.com/2014/02/aes-php-mcrypt-key-padding/<|eol|><|sor|>People always scoff when I do my scripting in bash or perl.
Coincidently those are two languages that halt execution on error.<|eor|><|sor|>People always scoff when I do my scripting in Haskell.
Coincidentally that's the language that homomorphism endofunctor monoid<|eor|><|eols|><|endoftext|> | 13 |
lolphp | ChoHag | cfqt4hv | <|sols|><|sot|>Mcrypt: "Catastrophic crypto failure? That's worth a warning. Maybe."<|eot|><|sol|>http://www.leaseweblabs.com/2014/02/aes-php-mcrypt-key-padding/<|eol|><|sor|>People always scoff when I do my scripting in bash or perl.
Coincidently those are two languages that halt execution on error.<|eor|><|sor|>Well bash only does that if you use set -e<|eor|><|sor|>You always use set -e. Just like you always run perl with warnings and strict.
Right?
Right.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | nikic | cfs2eo6 | <|sols|><|sot|>Mcrypt: "Catastrophic crypto failure? That's worth a warning. Maybe."<|eot|><|sol|>http://www.leaseweblabs.com/2014/02/aes-php-mcrypt-key-padding/<|eol|><|sor|>People always scoff when I do my scripting in bash or perl.
Coincidently those are two languages that halt execution on error.<|eor|><|sor|>People always scoff when I do my scripting in Haskell.
Coincidentally that's the language that homomorphism endofunctor monoid<|eor|><|sor|>You mean to say zygohistomorphic prepromorphisms, right? Homomorphisms are *so* amateur...
<|eor|><|eols|><|endoftext|> | 8 |
lolphp | n3xg3n | cfqqacs | <|sols|><|sot|>Mcrypt: "Catastrophic crypto failure? That's worth a warning. Maybe."<|eot|><|sol|>http://www.leaseweblabs.com/2014/02/aes-php-mcrypt-key-padding/<|eol|><|soopr|>Okay, lessons learned from reading this article:
Don't use Mcrypt.
Seriously, look at this API:
> AES-256 is different from RIJNDAEL-256. The 256 in AES refers to the key size, where the 256 in RIJNDAEL refers to block size. AES-256 is RIJNDAEL-128 when used with a 256 bit key.
So we can infer that the constants don't actually line up to algorithms as they are referred to in practice. Not even for AES, the most official (and thus most widespread) modern cipher. *Okay.*
> if you feed Mcrypt a smaller key [than the cipher is expecting] it will automatically pad it to an acceptable size using zero bytes.
So your key generation fucked up and you aren't actually getting the guarantees you thought you were, but Mcrypt will "helpfully" encrypt things anyway, in the limit providing you with no security whatsoever. And this doesn't even generate a warning.
> Mcrypt accepts any size of plain text and solves this [block-size] issue for you by automatically padding it with zero bytes.
Oh good, it defaults to the kind of padding you can't deterministically reverse . How "helpful". (Again, no warning.)
> If the initialization vector does not have the right size (16 bytes), then Mcrypt outputs a warning and uses an empty initialization vector.
*Catastrophic failure* generating a *warning*, Part The Second. In a lot of ways this is even *worse* than the key length thing, since if you ended up with a shorter key than you expected you probably still have *some* security; meanwhile a cryptosystem that repeats IVs can generally be considered "completely broken".
Okay, how much worse can this get? Let's look at the rest of the API *oh God*
> If the self test succeeds it returns FALSE. In case of an error, it returns TRUE.
In other words *exactly the opposite* of what a nave user (i.e. me, having never looked at this API before) would expect. That's great.
ECB is an option. This is a horrible idea.
OFB with partial feedback is an option, despite being another bad idea. At least they recommend against this one.
All available modes of operation are malleable; you get to add authentication yourself. (Encrypt, then MAC. Always in that order.)
No CTR mode, despite being the best-regarded non-authenticated mode of operation in current practice.
No padding functions. You get to do that yourself, too. Hope you don't accidentally introduce a padding oracle.
No key derivation functions. Another thing you get to do yourself.
Non-copypaste-safe example: 3DES in ECB mode, no KDF, no MAC. Oh, also no error checking. Probably strings the primitives through the API correctly, but it's doing just about everything else wrong.
Speaking of stringing primitives through the API, that looks like a *ridiculous* number of things that can go wrong. Is there a particular reason it takes this many lines to do `$ciphertext = encrypt($cipher, $key, $plaintext);`? Or at most, `$ciphertext = encrypt($cipher, derive_key($work_factor, $password), $plaintext);`?
Tl;dr: run^as^fast^as^you^can
Edit: how do acronyms work<|eoopr|><|sor|>>> AES-256 is different from RIJNDAEL-256. The 256 in AES refers to the key size, where the 256 in RIJNDAEL refers to block size. AES-256 is RIJNDAEL-128 when used with a 256 bit key.
>
> So we can infer that the constants don't actually line up to algorithms as they are referred to in practice. Not even for AES, the most official (and thus most widespread) modern cipher. Okay.
This is technically correct though... AES is/are specific members of Rijndael cipher family, but it is not the same thing.
To quote the [wikipedia page for AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard):
> The Advanced Encryption Standard (AES) is a specification for the encryption of electronic data established by the U.S. National Institute of Standards and Technology (NIST) in 2001. It is based on the Rijndael cipher developed by two Belgian cryptographers, Joan Daemen and Vincent Rijmen, who submitted a proposal to NIST during the AES selection process. **Rijndael is a family of ciphers with different key and block sizes. For AES, NIST selected three members of the Rijndael family, each with a block size of 128 bits, but three different key lengths: 128, 192 and 256 bits.**
(emphasis added)
That said, it's definitely confusing. (Especially because who uses arbitrary members of the Rijndael family?)
>> If the self test succeeds it returns FALSE. In case of an error, it returns TRUE.
> In other words exactly the opposite of what a nave user (i.e. me, having never looked at this API before) would expect. That's great.
This is probably some C background leaking through
> ECB is an option. This is a horrible idea.
ECB is necessary if you want to implement other cipher modes (and is likely just part of the internal API being exposed for completeness/convenience)
Not defending it, but these aren't totally insane things.
<|eor|><|eols|><|endoftext|> | 5 |
lolphp | tavianator | cfqoair | <|sols|><|sot|>Mcrypt: "Catastrophic crypto failure? That's worth a warning. Maybe."<|eot|><|sol|>http://www.leaseweblabs.com/2014/02/aes-php-mcrypt-key-padding/<|eol|><|sor|>People always scoff when I do my scripting in bash or perl.
Coincidently those are two languages that halt execution on error.<|eor|><|sor|>Well bash only does that if you use set -e<|eor|><|eols|><|endoftext|> | 5 |
lolphp | ajmarks | cfqver5 | <|sols|><|sot|>Mcrypt: "Catastrophic crypto failure? That's worth a warning. Maybe."<|eot|><|sol|>http://www.leaseweblabs.com/2014/02/aes-php-mcrypt-key-padding/<|eol|><|sor|>People always scoff when I do my scripting in bash or perl.
Coincidently those are two languages that halt execution on error.<|eor|><|sor|>Python...<|eor|><|eols|><|endoftext|> | 5 |
lolphp | Torandi | 174coe | <|soss|><|sot|>Member variables for NULL? No problem!<|eot|><|sost|>At work I'm fixing bugs and implementing smaller features in a horrible php spaghetti monster. One of the gems I found was this:
$row = NULL;
$row->product = "foobar";
At first I was just perplexed that this would work, I then realized that $row would be cast to a stdClass when trying to assign members of it, but this is really a horrible way of doing that.
This actually prints a notice, but in this case the notices goes to a log file that is flooded with warnings and notices.<|eost|><|eoss|><|endoftext|> | 39 |
lolphp | Tjoppen | c82358y | <|soss|><|sot|>Member variables for NULL? No problem!<|eot|><|sost|>At work I'm fixing bugs and implementing smaller features in a horrible php spaghetti monster. One of the gems I found was this:
$row = NULL;
$row->product = "foobar";
At first I was just perplexed that this would work, I then realized that $row would be cast to a stdClass when trying to assign members of it, but this is really a horrible way of doing that.
This actually prints a notice, but in this case the notices goes to a log file that is flooded with warnings and notices.<|eost|><|sor|>PHP: Errors aren't<|eor|><|eoss|><|endoftext|> | 24 |
lolphp | Legolas-the-elf | c825o4p | <|soss|><|sot|>Member variables for NULL? No problem!<|eot|><|sost|>At work I'm fixing bugs and implementing smaller features in a horrible php spaghetti monster. One of the gems I found was this:
$row = NULL;
$row->product = "foobar";
At first I was just perplexed that this would work, I then realized that $row would be cast to a stdClass when trying to assign members of it, but this is really a horrible way of doing that.
This actually prints a notice, but in this case the notices goes to a log file that is flooded with warnings and notices.<|eost|><|sor|>Objective-C does a similar thing. Sending a message to `nil` (the equivalent of calling a method on `NULL`) evaluates to `nil` itself (more or less).
It's got good points and bad points. It does simplify a lot of logic, but it can also make mistakes more elusive. Everybody with any experience in Objective-C is very aware of how `nil` is treated though.
PHP's approach, however, is the worst of both worlds. It's not intentionally designed to work this way, so it's unexpected behaviour for developers and you get lots of notices. But it doesn't blow up immediately like other languages can, so you don't get the benefit of failing fast either.
<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | mejicat | 138nnh | <|sols|><|sot|>"else if" is an alias for "elseif", but if you're using the colon syntax it becomes a parse error<|eot|><|sol|>http://uk.php.net/manual/en/control-structures.elseif.php<|eol|><|eols|><|endoftext|> | 37 |
lolphp | audaxxx | c71triy | <|sols|><|sot|>"else if" is an alias for "elseif", but if you're using the colon syntax it becomes a parse error<|eot|><|sol|>http://uk.php.net/manual/en/control-structures.elseif.php<|eol|><|sor|>And the first comment is
> Note that } elseif() { is somewhat faster than } else if() {
I am sure, this is very often the performance bottleneck.<|eor|><|eols|><|endoftext|> | 17 |
lolphp | Porges | c71wqx8 | <|sols|><|sot|>"else if" is an alias for "elseif", but if you're using the colon syntax it becomes a parse error<|eot|><|sol|>http://uk.php.net/manual/en/control-structures.elseif.php<|eol|><|sor|>And the first comment is
> Note that } elseif() { is somewhat faster than } else if() {
I am sure, this is very often the performance bottleneck.<|eor|><|sor|>Also shows the naivity in these sorts of benchmarks.
The performance difference is due to the order of the tests; swap the order and you'll get the opposite results.<|eor|><|sor|>http://www.phpbench.com/
I always cry a little bit when I look at that page. Always remember: The while loop is faster than a for loop.<|eor|><|sor|>The emphasis on microbenchmarks in the PHP community is bizarre. You're using PHP. If you were concerned about performance, you wouldn't be.<|eor|><|eols|><|endoftext|> | 17 |
lolphp | mejicat | c71x7kn | <|sols|><|sot|>"else if" is an alias for "elseif", but if you're using the colon syntax it becomes a parse error<|eot|><|sol|>http://uk.php.net/manual/en/control-structures.elseif.php<|eol|><|sor|>Do not use the colon syntax. Problem solved.<|eor|><|soopr|>I think a better solution is not using PHP.<|eoopr|><|eols|><|endoftext|> | 16 |
lolphp | Mattho | c71rtjm | <|sols|><|sot|>"else if" is an alias for "elseif", but if you're using the colon syntax it becomes a parse error<|eot|><|sol|>http://uk.php.net/manual/en/control-structures.elseif.php<|eol|><|sor|>Wello, *else if* is just *else { if* so it makes sense. You can only have one statement/block after the else (without a block) and *if (x) {}* is a single statement while *if (xx) foo();* is not. Or not? What?<|eor|><|eols|><|endoftext|> | 8 |
lolphp | barubary | c71zyzs | <|sols|><|sot|>"else if" is an alias for "elseif", but if you're using the colon syntax it becomes a parse error<|eot|><|sol|>http://uk.php.net/manual/en/control-structures.elseif.php<|eol|><|sor|>And in some languages it's elif and then I'm just all confused.
I wish the Emperor Of Programming Languages would just decree once and for all which one we're to use.<|eor|><|sor|>* elif: Python, Bash
* elsif: Perl, Ruby
* elseif: PHP
Enjoy.<|eor|><|sor|>The C preprocessor also uses `#elif`.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | kezabelle | c71xvmm | <|sols|><|sot|>"else if" is an alias for "elseif", but if you're using the colon syntax it becomes a parse error<|eot|><|sol|>http://uk.php.net/manual/en/control-structures.elseif.php<|eol|><|sor|>And in some languages it's elif and then I'm just all confused.
I wish the Emperor Of Programming Languages would just decree once and for all which one we're to use.<|eor|><|sor|>* elif: Python, Bash
* elsif: Perl, Ruby
* elseif: PHP
Enjoy.<|eor|><|sor|>And for the first time ever, PHP had the more sensible, saner choice.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | more_exercise | c74y4i4 | <|sols|><|sot|>"else if" is an alias for "elseif", but if you're using the colon syntax it becomes a parse error<|eot|><|sol|>http://uk.php.net/manual/en/control-structures.elseif.php<|eol|><|sor|>Do not use the colon syntax. Problem solved.<|eor|><|soopr|>I think a better solution is not using PHP.<|eoopr|><|sor|>Which would implicitly allow you to not use the colon syntax. Double win!<|eor|><|eols|><|endoftext|> | 7 |
lolphp | leoel | c7214dq | <|sols|><|sot|>"else if" is an alias for "elseif", but if you're using the colon syntax it becomes a parse error<|eot|><|sol|>http://uk.php.net/manual/en/control-structures.elseif.php<|eol|><|sor|>And the first comment is
> Note that } elseif() { is somewhat faster than } else if() {
I am sure, this is very often the performance bottleneck.<|eor|><|sor|>Also shows the naivity in these sorts of benchmarks.
The performance difference is due to the order of the tests; swap the order and you'll get the opposite results.<|eor|><|sor|>http://www.phpbench.com/
I always cry a little bit when I look at that page. Always remember: The while loop is faster than a for loop.<|eor|><|sor|>The emphasis on microbenchmarks in the PHP community is bizarre. You're using PHP. If you were concerned about performance, you wouldn't be.<|eor|><|sor|>Naive tools for a naive language, it seems coherent.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | kingguru | c7294f2 | <|sols|><|sot|>"else if" is an alias for "elseif", but if you're using the colon syntax it becomes a parse error<|eot|><|sol|>http://uk.php.net/manual/en/control-structures.elseif.php<|eol|><|sor|>And the first comment is
> Note that } elseif() { is somewhat faster than } else if() {
I am sure, this is very often the performance bottleneck.<|eor|><|sor|>Also shows the naivity in these sorts of benchmarks.
The performance difference is due to the order of the tests; swap the order and you'll get the opposite results.<|eor|><|sor|>http://www.phpbench.com/
I always cry a little bit when I look at that page. Always remember: The while loop is faster than a for loop.<|eor|><|sor|>That page is hilarious, but a bit scary considering that there are people out there who actually takes these benchmarks seriously.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | Altreus | c71vzpz | <|sols|><|sot|>"else if" is an alias for "elseif", but if you're using the colon syntax it becomes a parse error<|eot|><|sol|>http://uk.php.net/manual/en/control-structures.elseif.php<|eol|><|sor|>Wello, *else if* is just *else { if* so it makes sense. You can only have one statement/block after the else (without a block) and *if (x) {}* is a single statement while *if (xx) foo();* is not. Or not? What?<|eor|><|sor|>This is what I always assumed.
If `else if` _is_ an alias for `elseif` then this is stupid. But if `else if` is simply an `if` as the only statement to a braceless `else` then it makes perfect sense.
Note that single-statement control flow like this has its own problems:
if (x)
if (y)
foo()
else
bar()
The indentation says the else goes with the first if, but the rules, variously across languages, agree, disagree or don't specify. Perl doesn't let you do this, so it avoids the problem neatly. That's why you can't do `else if` in Perl.
This is known as the shift-reduce conflict. http://docs.freebsd.org/info/bison/bison.info.Shift_Reduce.html<|eor|><|eols|><|endoftext|> | 5 |
lolphp | audaxxx | c71up4i | <|sols|><|sot|>"else if" is an alias for "elseif", but if you're using the colon syntax it becomes a parse error<|eot|><|sol|>http://uk.php.net/manual/en/control-structures.elseif.php<|eol|><|sor|>And the first comment is
> Note that } elseif() { is somewhat faster than } else if() {
I am sure, this is very often the performance bottleneck.<|eor|><|sor|>Also shows the naivity in these sorts of benchmarks.
The performance difference is due to the order of the tests; swap the order and you'll get the opposite results.<|eor|><|sor|>http://www.phpbench.com/
I always cry a little bit when I look at that page. Always remember: The while loop is faster than a for loop.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | petdance | pi1gy | <|sols|><|sot|>PHP silently converts any spaces in field names to underscores. Surprise!<|eot|><|sol|>http://www.phpbuilder.com/board/showthread.php?t=10353238<|eol|><|eols|><|endoftext|> | 37 |
lolphp | RobOplawar | c3pj9ec | <|sols|><|sot|>PHP silently converts any spaces in field names to underscores. Surprise!<|eot|><|sol|>http://www.phpbuilder.com/board/showthread.php?t=10353238<|eol|><|sor|>I just wrote a test script because surely this can't be true in php 5.3. It is. >_>
You know, sometimes it can be really hard to defend this language. <|eor|><|eols|><|endoftext|> | 13 |
lolphp | petdance | c3pjq2c | <|sols|><|sot|>PHP silently converts any spaces in field names to underscores. Surprise!<|eot|><|sol|>http://www.phpbuilder.com/board/showthread.php?t=10353238<|eol|><|soopr|>Turns out it's more than just spaces.
http://php.net/manual/en/language.variables.external.php
The full list of field-name characters that PHP converts to _ (underscore) is the following (not just dot):
chr(32) ( ) (space)
chr(46) (.) (dot)
chr(91) ([) (open square bracket)
chr(128) - chr(159) (various)
PHP irreversibly modifies field names containing these characters in an attempt to maintain compatibility with the deprecated register_globals feature.<|eoopr|><|eols|><|endoftext|> | 11 |
lolphp | infinull | c3ppqnv | <|sols|><|sot|>PHP silently converts any spaces in field names to underscores. Surprise!<|eot|><|sol|>http://www.phpbuilder.com/board/showthread.php?t=10353238<|eol|><|sor|>I just wrote a test script because surely this can't be true in php 5.3. It is. >_>
You know, sometimes it can be really hard to defend this language. <|eor|><|sor|>Join the rest of us in bashing it.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | sloat | c3pmyqg | <|sols|><|sot|>PHP silently converts any spaces in field names to underscores. Surprise!<|eot|><|sol|>http://www.phpbuilder.com/board/showthread.php?t=10353238<|eol|><|sor|>It would be better if it failed but what language allows you to make variables or function definitions with spaces?<|eor|><|sor|>None that I know of, but PHP is changing a hash key in this case because of an old, removed feature that would automatically convert GET and POST data to global variables.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | infinull | c3ppqxl | <|sols|><|sot|>PHP silently converts any spaces in field names to underscores. Surprise!<|eot|><|sol|>http://www.phpbuilder.com/board/showthread.php?t=10353238<|eol|><|sor|>It would be better if it failed but what language allows you to make variables or function definitions with spaces?<|eor|><|sor|>None that I know of, but PHP is changing a hash key in this case because of an old, removed feature that would automatically convert GET and POST data to global variables.<|eor|><|sor|>Technically it's not removed, just disabled by default.
Note: name of the feature (for convenient googling & whatnot) is register globals<|eor|><|eols|><|endoftext|> | 5 |
lolphp | yxpow | m87tyd | <|soss|><|sot|>Implicit conversions with []<|eot|><|sost|>Not sure if this has been posted here before, but using `$c[]` when `empty($c) === true` overwrites the value of `$c`:
$c = false;
$c[] = 2;
works without any errors, but:
$c = false;
array_push($c, 2);
produces a type error.
Of course, the same thing happens if `$c` isn't "defined" or is null...<|eost|><|eoss|><|endoftext|> | 35 |
lolphp | funtek | grgmacb | <|soss|><|sot|>Implicit conversions with []<|eot|><|sost|>Not sure if this has been posted here before, but using `$c[]` when `empty($c) === true` overwrites the value of `$c`:
$c = false;
$c[] = 2;
works without any errors, but:
$c = false;
array_push($c, 2);
produces a type error.
Of course, the same thing happens if `$c` isn't "defined" or is null...<|eost|><|sor|>It's possible that it is to allow to work:
$a = [];
$a["key1"][] = 123;
$a["key1"] will automatically become an array and it won't throw an error. Stupid but sometimes useful<|eor|><|eoss|><|endoftext|> | 5 |
lolphp | SerdanKK | ia4xwn | <|soss|><|sot|>Named parameters are cool, but PHP variables aren't typed so the implementation is completely broken.<|eot|><|sost|>[https://3v4l.org/P2XSm](https://3v4l.org/P2XSm)
Someone please tell me wth they're thinking. If this ships I'll have to put up another "don't use this feature" sign at work.
[C# equivalent](https://dotnetfiddle.net/1ptTml)
I've been strangely optimistic about PHP lately, so I suppose *something* had to come up.
​
EDIT: Someone on internals agrees: [https://externals.io/message/111161#111178](https://externals.io/message/111161#111178)
Andreas, you're my hero, despite your futile efforts.
EDIT2: I'm intrigued by the down-votes. I think the feature is *obviously* broken, so if you disagree what's your reasoning?<|eost|><|eoss|><|endoftext|> | 33 |
lolphp | yawkat | g1laj1m | <|soss|><|sot|>Named parameters are cool, but PHP variables aren't typed so the implementation is completely broken.<|eot|><|sost|>[https://3v4l.org/P2XSm](https://3v4l.org/P2XSm)
Someone please tell me wth they're thinking. If this ships I'll have to put up another "don't use this feature" sign at work.
[C# equivalent](https://dotnetfiddle.net/1ptTml)
I've been strangely optimistic about PHP lately, so I suppose *something* had to come up.
​
EDIT: Someone on internals agrees: [https://externals.io/message/111161#111178](https://externals.io/message/111161#111178)
Andreas, you're my hero, despite your futile efforts.
EDIT2: I'm intrigued by the down-votes. I think the feature is *obviously* broken, so if you disagree what's your reasoning?<|eost|><|sor|>Isn't this exactly what you'd expect in a dynamic language? Python does the same thing. Type hints are no substitute for a static language, they can't really participate in resolving.
Or are PHP type hints stronger than python ones?<|eor|><|eoss|><|endoftext|> | 11 |
lolphp | SerdanKK | g1l2cir | <|soss|><|sot|>Named parameters are cool, but PHP variables aren't typed so the implementation is completely broken.<|eot|><|sost|>[https://3v4l.org/P2XSm](https://3v4l.org/P2XSm)
Someone please tell me wth they're thinking. If this ships I'll have to put up another "don't use this feature" sign at work.
[C# equivalent](https://dotnetfiddle.net/1ptTml)
I've been strangely optimistic about PHP lately, so I suppose *something* had to come up.
​
EDIT: Someone on internals agrees: [https://externals.io/message/111161#111178](https://externals.io/message/111161#111178)
Andreas, you're my hero, despite your futile efforts.
EDIT2: I'm intrigued by the down-votes. I think the feature is *obviously* broken, so if you disagree what's your reasoning?<|eost|><|sor|>1. What does this have to do with "typed PHP variables"?
2. This was discussed to death. It's a trade off. The alternative is to merge param names from all parents (super classes and interfaces) which comes with more complexity and a performance penalty. Ultimately Nikita decided it wasn't worth it.<|eor|><|soopr|>1. Seriously? Hennings explains it in the thread I linked to. If it was possible to associate a type with the variable itself there wouldn't be a problem, *as demonstrated by C#*.
2. It was discussed to death and it's still broken. Is that supposed to reassure me? Seriously, I actually put some amount of effort into this and you're just going to respond with "it was considered so shut up". I fucking well know it was considered. I happen to respect Nikita a great deal, but I also happen to think the current implementation is a colossal mistake.
I'd rather not have the feature at all than deal with the current implementation. Actually expend a minimum of effort in addressing my concerns or go away.<|eoopr|><|eoss|><|endoftext|> | 10 |
lolphp | eMZi0767 | g1l0urw | <|soss|><|sot|>Named parameters are cool, but PHP variables aren't typed so the implementation is completely broken.<|eot|><|sost|>[https://3v4l.org/P2XSm](https://3v4l.org/P2XSm)
Someone please tell me wth they're thinking. If this ships I'll have to put up another "don't use this feature" sign at work.
[C# equivalent](https://dotnetfiddle.net/1ptTml)
I've been strangely optimistic about PHP lately, so I suppose *something* had to come up.
​
EDIT: Someone on internals agrees: [https://externals.io/message/111161#111178](https://externals.io/message/111161#111178)
Andreas, you're my hero, despite your futile efforts.
EDIT2: I'm intrigued by the down-votes. I think the feature is *obviously* broken, so if you disagree what's your reasoning?<|eost|><|sor|>In .NET (and most other languages/runtimes like that, I imagine), named arguments are translated into positional ones at compile-time, and ultimately the call then relies on positioning and type of arguments passed.
I suppose it would be interesting to compare PHP to Python in this regard, since they're both interpreted languages, where such changes are not lost between code and runtime.<|eor|><|eoss|><|endoftext|> | 8 |
lolphp | yawkat | g1lcmfd | <|soss|><|sot|>Named parameters are cool, but PHP variables aren't typed so the implementation is completely broken.<|eot|><|sost|>[https://3v4l.org/P2XSm](https://3v4l.org/P2XSm)
Someone please tell me wth they're thinking. If this ships I'll have to put up another "don't use this feature" sign at work.
[C# equivalent](https://dotnetfiddle.net/1ptTml)
I've been strangely optimistic about PHP lately, so I suppose *something* had to come up.
​
EDIT: Someone on internals agrees: [https://externals.io/message/111161#111178](https://externals.io/message/111161#111178)
Andreas, you're my hero, despite your futile efforts.
EDIT2: I'm intrigued by the down-votes. I think the feature is *obviously* broken, so if you disagree what's your reasoning?<|eost|><|sor|>Isn't this exactly what you'd expect in a dynamic language? Python does the same thing. Type hints are no substitute for a static language, they can't really participate in resolving.
Or are PHP type hints stronger than python ones?<|eor|><|soopr|>I don't have any experience with Python, but I'd expect they are similar enough.
My problem with this is that if PHP being dynamic means that it can't be implemented in a sensible way, then it shouldn't be implemented at all.
The current implementation leads to fragile code that'll be difficult to reason about, even with the use of static analysis.<|eoopr|><|sor|>> The current implementation leads to fragile code that'll be difficult to reason about, even with the use of static analysis.
Dynamic typing in a nutshell? :)<|eor|><|eoss|><|endoftext|> | 8 |
lolphp | elcapitanoooo | g1kmdxb | <|soss|><|sot|>Named parameters are cool, but PHP variables aren't typed so the implementation is completely broken.<|eot|><|sost|>[https://3v4l.org/P2XSm](https://3v4l.org/P2XSm)
Someone please tell me wth they're thinking. If this ships I'll have to put up another "don't use this feature" sign at work.
[C# equivalent](https://dotnetfiddle.net/1ptTml)
I've been strangely optimistic about PHP lately, so I suppose *something* had to come up.
​
EDIT: Someone on internals agrees: [https://externals.io/message/111161#111178](https://externals.io/message/111161#111178)
Andreas, you're my hero, despite your futile efforts.
EDIT2: I'm intrigued by the down-votes. I think the feature is *obviously* broken, so if you disagree what's your reasoning?<|eost|><|sor|>Sooo another half baked feature copied from some other language..<|eor|><|eoss|><|endoftext|> | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.