subreddit
stringclasses
7 values
author
stringlengths
3
20
id
stringlengths
5
7
content
stringlengths
67
30.4k
score
int64
0
140k
lolphp
squiggleslash
f341aed
<|soss|><|sot|>What even is variable interpolation<|eot|><|sost|> <?php define('foo', 'bar'); $foo = array('yes'); $b = 'no'; echo "r1: $foo[0]\n"; echo "r2: ${foo[0]}\n"; echo "r3: ${ foo[0]}\n"; echo "r4: ${foo[0] }\n"; echo "r5: ${foo [0]}\n"; echo "r6: ${foo[0 ]}\n"; echo "r7: ${ foo [ 0 ] }\n"; Output: r1: yes r2: yes r3: no r4: yes r5: no r6: yes r7: no ([Live demo](https://3v4l.org/SrLF1)) I don't even know anymore. PS: I also tried `"$foo[0 ]"`, but that's a syntax error, obviously: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting ']' The `unexpected ''` part is slightly worrying: If you don't expect empty substrings to show up everywhere in a string, you may have issues parsing anything at all. \\\_()_/<|eost|><|sor|>We need an Obfuscated PHP Code Contest to go with the [C](http://www.ioccc.org/) one. Hats off to the poster, that is probably some of the most evil code I've ever seen and it took me a while to figure out why it was using the value of $b...<|eor|><|eoss|><|endoftext|>
13
lolphp
Targren
f350eas
<|soss|><|sot|>What even is variable interpolation<|eot|><|sost|> <?php define('foo', 'bar'); $foo = array('yes'); $b = 'no'; echo "r1: $foo[0]\n"; echo "r2: ${foo[0]}\n"; echo "r3: ${ foo[0]}\n"; echo "r4: ${foo[0] }\n"; echo "r5: ${foo [0]}\n"; echo "r6: ${foo[0 ]}\n"; echo "r7: ${ foo [ 0 ] }\n"; Output: r1: yes r2: yes r3: no r4: yes r5: no r6: yes r7: no ([Live demo](https://3v4l.org/SrLF1)) I don't even know anymore. PS: I also tried `"$foo[0 ]"`, but that's a syntax error, obviously: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting ']' The `unexpected ''` part is slightly worrying: If you don't expect empty substrings to show up everywhere in a string, you may have issues parsing anything at all. \\\_()_/<|eost|><|sor|>Seriously, can someone explain to me where the actual fuck the `no` is coming from? > `T_ENCAPSED_AND_WHITESPACE` I guess as a bonus lol, what does *encapsed* mean? Neither [Merriam-Webster](https://www.merriam-webster.com/dictionary/encapsed) nor [Oxford](https://www.lexico.com/en/search?utf8=%E2%9C%93&filter=dictionary&dictionary=en&query=encapsed) seem to know <|eor|><|soopr|>> can someone explain to me where the actual fuck the `no` is coming from? Nothing easier than that! ${ foo [ 0 ] } // define('foo', 'bar') // foo ==> 'bar' ${ 'bar' [ 0 ] } // 'bar'[0] ==> 'b' ${ 'b' } // ${'b'} ==> $b $b // $b = 'no' 'no'<|eoopr|><|sor|>I want to cry now...<|eor|><|eoss|><|endoftext|>
12
lolphp
Miserable_Fuck
f35oiiv
<|soss|><|sot|>What even is variable interpolation<|eot|><|sost|> <?php define('foo', 'bar'); $foo = array('yes'); $b = 'no'; echo "r1: $foo[0]\n"; echo "r2: ${foo[0]}\n"; echo "r3: ${ foo[0]}\n"; echo "r4: ${foo[0] }\n"; echo "r5: ${foo [0]}\n"; echo "r6: ${foo[0 ]}\n"; echo "r7: ${ foo [ 0 ] }\n"; Output: r1: yes r2: yes r3: no r4: yes r5: no r6: yes r7: no ([Live demo](https://3v4l.org/SrLF1)) I don't even know anymore. PS: I also tried `"$foo[0 ]"`, but that's a syntax error, obviously: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting ']' The `unexpected ''` part is slightly worrying: If you don't expect empty substrings to show up everywhere in a string, you may have issues parsing anything at all. \\\_()_/<|eost|><|sor|>PHP just hates throwing exceptions. If you give it bad input, it FINDS A WAY to get it to run. It's just terrible really.<|eor|><|sor|>> it FINDS A WAY to get it to run I never understood/liked that shit. Even as a beginner.<|eor|><|eoss|><|endoftext|>
5
lolphp
D1551D3N7
92u55q
<|sols|><|sot|>PHP getopts() makes boolean options False when they are used<|eot|><|sol|>https://secure.php.net/manual/en/function.getopt.php<|eol|><|eols|><|endoftext|>
67
lolphp
mikeputerbaugh
e392tpz
<|sols|><|sot|>PHP getopts() makes boolean options False when they are used<|eot|><|sol|>https://secure.php.net/manual/en/function.getopt.php<|eol|><|sor|>Not an intuitive or logical behavior, not the same functionality of the C function of the same name, not adequately explained in text ofthe function documentation --- this is a genuine lolphp by all measures.<|eor|><|eols|><|endoftext|>
33
lolphp
chinahawk
e38l56d
<|sols|><|sot|>PHP getopts() makes boolean options False when they are used<|eot|><|sol|>https://secure.php.net/manual/en/function.getopt.php<|eol|><|sor|>true<|eor|><|eols|><|endoftext|>
10
lolphp
sproingie
e44ek33
<|sols|><|sot|>PHP getopts() makes boolean options False when they are used<|eot|><|sol|>https://secure.php.net/manual/en/function.getopt.php<|eol|><|sor|>true<|eor|><|sor|>False<|eor|><|sor|>FileNotFound<|eor|><|eols|><|endoftext|>
7
lolphp
amunak
3fmesq
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|eols|><|endoftext|>
64
lolphp
KeinBaum
ctqaicx
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>Even better is the [documentaion](http://de2.php.net/manual/en/function.empty.php): >Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false. Just ... what?<|eor|><|eols|><|endoftext|>
47
lolphp
prewk
ctqapmp
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>Even better is the [documentaion](http://de2.php.net/manual/en/function.empty.php): >Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false. Just ... what?<|eor|><|sor|>That's a much better lolphp :)<|eor|><|eols|><|endoftext|>
22
lolphp
prewk
ctq1rs8
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>Do you mean `'0' // == false - because fuck you, that's why`? What are you trying to prove? Casting a string into a string(?) and then checking its falsyness to give an example of PHP's funny type juggling? What would you rather have it return?<|eor|><|eols|><|endoftext|>
21
lolphp
ajmarks
ctqdqet
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>Even better is the [documentaion](http://de2.php.net/manual/en/function.empty.php): >Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false. Just ... what?<|eor|><|sor|>That's a much better lolphp :)<|eor|><|sor|>Just be glad it's not in Hebrew. In 7.2 they're going to change it to reik().<|eor|><|eols|><|endoftext|>
18
lolphp
TheBuzzSaw
ctpyxt5
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>This is [well documented](https://secure.php.net/manual/en/function.empty.php#refsect1-function.empty-returnvalues) and well discussed. By now most people should know that with PHP's type juggling `'0' == false == ''`.<|eor|><|sor|>Being well documented is _not_ a valid defense... of anything, really.<|eor|><|eols|><|endoftext|>
17
lolphp
the_cornell
ctqovwl
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>Do you mean `'0' // == false - because fuck you, that's why`? What are you trying to prove? Casting a string into a string(?) and then checking its falsyness to give an example of PHP's funny type juggling? What would you rather have it return?<|eor|><|sor|>The integer 0 or the string "0" aren't "empty" according to the documentation: > A variable is considered empty if it does not exist or if its value equals FALSE. This should return false.<|eor|><|sor|>> This should return false. That is not true. According to the documentation for `empty`: > No warning is generated if the variable does not exist. That means empty() is essentially the concise equivalent to !isset($var) || $var == false. Notice that last line? `... || $var == false`. If it were `$var === false`, you would be correct. But an integer `0` or a string `'0'` both `== false`. Example: [http://ideone.com/WUbVSE](http://ideone.com/WUbVSE) --- **Edit:** I'm not saying that `'0' == FALSE` isn't lolphp enough on its own, just pointing out that the documentation clearly says `==` *not* `===`.<|eor|><|eols|><|endoftext|>
16
lolphp
amunak
ctpyeht
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>This is [well documented](https://secure.php.net/manual/en/function.empty.php#refsect1-function.empty-returnvalues) and well discussed. By now most people should know that with PHP's type juggling `'0' == false == ''`.<|eor|><|soopr|>I know it's documented, but it's extremly annoying - especially when you are checking for user-entered data or something. And while 0 == false == '' makes at least some sense, '0' certainly does not. At that point you could argue that "\t" and ' ' and ' ' should all weakly equal to false, since it is all basically null/empty. And funnily enough ' ' is not considered empty.<|eoopr|><|eols|><|endoftext|>
12
lolphp
weirdasianfaces
ctpxk88
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>This is [well documented](https://secure.php.net/manual/en/function.empty.php#refsect1-function.empty-returnvalues) and well discussed. By now most people should know that with PHP's type juggling `'0' == false == ''`.<|eor|><|eols|><|endoftext|>
10
lolphp
phoshi
ctqvl9k
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>Do you mean `'0' // == false - because fuck you, that's why`? What are you trying to prove? Casting a string into a string(?) and then checking its falsyness to give an example of PHP's funny type juggling? What would you rather have it return?<|eor|><|sor|>The integer 0 or the string "0" aren't "empty" according to the documentation: > A variable is considered empty if it does not exist or if its value equals FALSE. This should return false.<|eor|><|sor|>> This should return false. That is not true. According to the documentation for `empty`: > No warning is generated if the variable does not exist. That means empty() is essentially the concise equivalent to !isset($var) || $var == false. Notice that last line? `... || $var == false`. If it were `$var === false`, you would be correct. But an integer `0` or a string `'0'` both `== false`. Example: [http://ideone.com/WUbVSE](http://ideone.com/WUbVSE) --- **Edit:** I'm not saying that `'0' == FALSE` isn't lolphp enough on its own, just pointing out that the documentation clearly says `==` *not* `===`.<|eor|><|sor|>Documented insanity is still insanity, and indeed is one of PHP's major problems. Astonishing behaviour doesn't get less astonishing just because it's written down. <|eor|><|eols|><|endoftext|>
10
lolphp
KeinBaum
ctqo1io
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>Even better is the [documentaion](http://de2.php.net/manual/en/function.empty.php): >Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false. Just ... what?<|eor|><|sor|>I almost feel like they went out of their way to have it do that<|eor|><|sor|>Right? At what point when developing that did they think that that was a good idea. Who in their right minds would think that `trim($name) == false` was a sensible thing to write? And how did they manage to design something that only works on variables? It just doesn't make any sense.<|eor|><|eols|><|endoftext|>
8
lolphp
vita10gy
ctqm59w
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>TRWTF is that a query function is not called is_empty.<|eor|><|sor|>Even if it was it would have been isemp() or something else goofy.<|eor|><|eols|><|endoftext|>
7
lolphp
wutf
ctqw5k4
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>Even better is the [documentaion](http://de2.php.net/manual/en/function.empty.php): >Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false. Just ... what?<|eor|><|sor|>I almost feel like they went out of their way to have it do that<|eor|><|sor|>Right? At what point when developing that did they think that that was a good idea. Who in their right minds would think that `trim($name) == false` was a sensible thing to write? And how did they manage to design something that only works on variables? It just doesn't make any sense.<|eor|><|sor|>I assume `empty` is simply not a function, but a grammar construct. Just like `array`.<|eor|><|eols|><|endoftext|>
7
lolphp
amunak
cu4uzzs
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>Sorry, but what is wrong? This is in Documentation described. http://php.net/manual/pl/types.comparisons.php <|eor|><|soopr|>The fact that *it's even a thing*. (Thankfully) most of PHP's oddities and bad design decisions are documented, but that doesn't make them right. A string that contains more than the terminating null character should never *ever* be considered empty. '0' being empty makes as much sense as 'false' being empty (which isn't the case).<|eoopr|><|eols|><|endoftext|>
6
lolphp
domstersch
ctqxju0
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>Even better is the [documentaion](http://de2.php.net/manual/en/function.empty.php): >Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false. Just ... what?<|eor|><|sor|>I almost feel like they went out of their way to have it do that<|eor|><|sor|>Right? At what point when developing that did they think that that was a good idea. Who in their right minds would think that `trim($name) == false` was a sensible thing to write? And how did they manage to design something that only works on variables? It just doesn't make any sense.<|eor|><|sor|>I assume `empty` is simply not a function, but a grammar construct. Just like `array`.<|eor|><|sor|>Yeah, I think it sort of had to have been, because of the way it doesn't raise warnings on undefined variables (it's 'special' in the same way that `isset()` is).<|eor|><|eols|><|endoftext|>
6
lolphp
squiggleslash
ctqb2rm
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>This is [well documented](https://secure.php.net/manual/en/function.empty.php#refsect1-function.empty-returnvalues) and well discussed. By now most people should know that with PHP's type juggling `'0' == false == ''`.<|eor|><|soopr|>I know it's documented, but it's extremly annoying - especially when you are checking for user-entered data or something. And while 0 == false == '' makes at least some sense, '0' certainly does not. At that point you could argue that "\t" and ' ' and ' ' should all weakly equal to false, since it is all basically null/empty. And funnily enough ' ' is not considered empty.<|eoopr|><|sor|>Who uses empty() for validation? LOL<|eor|><|sor|>[deleted]<|eor|><|sor|>So if user submits "0" in a text field you assume the field is empty?<|eor|><|sor|>No, PHP does. What happens is this: - We write code that tests for an empty field using empty() - Everything looks OK until that first time we see a zero - F@$#. Now we have to go through and change every empty() to === '' Leaving us with the question of what's the point of "empty()", beyond testing that an array is empty (I assume empty(array("0")) isn't true...) It seems to be a completely useless function.<|eor|><|eols|><|endoftext|>
6
lolphp
the_cornell
ctrjqkm
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>Do you mean `'0' // == false - because fuck you, that's why`? What are you trying to prove? Casting a string into a string(?) and then checking its falsyness to give an example of PHP's funny type juggling? What would you rather have it return?<|eor|><|sor|>The integer 0 or the string "0" aren't "empty" according to the documentation: > A variable is considered empty if it does not exist or if its value equals FALSE. This should return false.<|eor|><|sor|>> This should return false. That is not true. According to the documentation for `empty`: > No warning is generated if the variable does not exist. That means empty() is essentially the concise equivalent to !isset($var) || $var == false. Notice that last line? `... || $var == false`. If it were `$var === false`, you would be correct. But an integer `0` or a string `'0'` both `== false`. Example: [http://ideone.com/WUbVSE](http://ideone.com/WUbVSE) --- **Edit:** I'm not saying that `'0' == FALSE` isn't lolphp enough on its own, just pointing out that the documentation clearly says `==` *not* `===`.<|eor|><|sor|>Documented insanity is still insanity, and indeed is one of PHP's major problems. Astonishing behaviour doesn't get less astonishing just because it's written down. <|eor|><|sor|>What you said might be the point of this post -- and I definitely agree with what you said regarding PHP's issues as a whole, but it was not the point of the comment I was replying to. Ziggy said that *according to the docs*, "empty('0')" should equal FALSE. But that is not true. According for the _docs_, "empty()" is essentially a shortcut for "!isset($var) || $var == FALSE". Which means that, again, according to the docs, "empty('0')" *should* equal TRUE because '0' _does_ == FALSE. <|eor|><|sor|>I feel like the synopsis at the top should be modified to say: > A variable is considered empty if it does not exist or if its value coerces to FALSE. Because "equals FALSE" to me means "has the identity of FALSE", and the string comprised of the byte `0x30` does not equal boolean FALSE (`0b0`). Then it should be changed to `maybe_empty()` :)<|eor|><|sor|>I promise, I do get the point. PHP is a crazy language with ridiculous idiosyncrasies. I was only pointing out that the documentation is not wrong. Seriously, I wasn't hounding you or anything. I believe we can all commiserate about PHP together! :)<|eor|><|eols|><|endoftext|>
6
lolphp
captainramen
ctqbw1a
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>TRWTF is that a query function is not called is_empty.<|eor|><|eols|><|endoftext|>
5
lolphp
LastElemental
ctqnj2u
<|sols|><|sot|>empty((string) '0'); // === true - because fuck you, that's why<|eot|><|sol|>http://ideone.com/ZqytvO<|eol|><|sor|>Even better is the [documentaion](http://de2.php.net/manual/en/function.empty.php): >Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false. Just ... what?<|eor|><|sor|>I almost feel like they went out of their way to have it do that<|eor|><|eols|><|endoftext|>
5
lolphp
ajmarks
1s8r1j
<|sols|><|sot|>Now Python can have the reliability of PHP (x-post /r/Python)<|eot|><|sol|>https://github.com/ajalt/fuckitpy<|eol|><|eols|><|endoftext|>
61
lolphp
tdammers
cdvavl9
<|sols|><|sot|>Now Python can have the reliability of PHP (x-post /r/Python)<|eot|><|sol|>https://github.com/ajalt/fuckitpy<|eol|><|sor|>Admirable attempt, but not quite there yet. In order to compete with PHP, we need at least the following: * Two more independent and non-optional error handling systems next to the exception system, such that the available libraries and language built-ins randomly use either one * Non-maskable fatal errors for relatively benign error conditions, such as trying to call a method that doesn't exist (right now, Python just throws an exception that you can catch at will - this is obviously no good, a severe crime like this must be punished) * A multi-faceted system for the configuration of the error handling systems; it has to be so complex that you can't rely on anything whatsoever. * Some sort of syntax quirk that causes a script to produce really confusing errors saying something about "headers already sent" when you add whitespace in strategic positions. * When a web application is detected, we need a way of exposing the HTTP response body as STDOUT/STDERR from anywhere in any Python script. But at least we already have utterly confusing scoping rules in Python. That's a start.<|eor|><|eols|><|endoftext|>
32
lolphp
jamwaffles
cdwkujj
<|sols|><|sot|>Now Python can have the reliability of PHP (x-post /r/Python)<|eot|><|sol|>https://github.com/ajalt/fuckitpy<|eol|><|sor|>Admirable attempt, but not quite there yet. In order to compete with PHP, we need at least the following: * Two more independent and non-optional error handling systems next to the exception system, such that the available libraries and language built-ins randomly use either one * Non-maskable fatal errors for relatively benign error conditions, such as trying to call a method that doesn't exist (right now, Python just throws an exception that you can catch at will - this is obviously no good, a severe crime like this must be punished) * A multi-faceted system for the configuration of the error handling systems; it has to be so complex that you can't rely on anything whatsoever. * Some sort of syntax quirk that causes a script to produce really confusing errors saying something about "headers already sent" when you add whitespace in strategic positions. * When a web application is detected, we need a way of exposing the HTTP response body as STDOUT/STDERR from anywhere in any Python script. But at least we already have utterly confusing scoping rules in Python. That's a start.<|eor|><|sor|>You forgot Hebrew error messages. Clearly the most important part.<|eor|><|eols|><|endoftext|>
18
lolphp
aftli
cdvgqu0
<|sols|><|sot|>Now Python can have the reliability of PHP (x-post /r/Python)<|eot|><|sol|>https://github.com/ajalt/fuckitpy<|eol|><|sor|>Inside tests.py: def test_context_manager(): with fuckit: pass assert 'P' != 'NP' # proof is left as an excercise for the reader<|eor|><|sor|>I lol'd at this one: assert weight('your mom') > weight('a truck full of McDoubles') assert 'that was a pretty sick burn'<|eor|><|eols|><|endoftext|>
14
lolphp
tdammers
cdx8x34
<|sols|><|sot|>Now Python can have the reliability of PHP (x-post /r/Python)<|eot|><|sol|>https://github.com/ajalt/fuckitpy<|eol|><|sor|>Admirable attempt, but not quite there yet. In order to compete with PHP, we need at least the following: * Two more independent and non-optional error handling systems next to the exception system, such that the available libraries and language built-ins randomly use either one * Non-maskable fatal errors for relatively benign error conditions, such as trying to call a method that doesn't exist (right now, Python just throws an exception that you can catch at will - this is obviously no good, a severe crime like this must be punished) * A multi-faceted system for the configuration of the error handling systems; it has to be so complex that you can't rely on anything whatsoever. * Some sort of syntax quirk that causes a script to produce really confusing errors saying something about "headers already sent" when you add whitespace in strategic positions. * When a web application is detected, we need a way of exposing the HTTP response body as STDOUT/STDERR from anywhere in any Python script. But at least we already have utterly confusing scoping rules in Python. That's a start.<|eor|><|sor|>>Some sort of syntax quirk that causes a script to produce really confusing errors saying something about "headers already sent" when you add whitespace in strategic positions. I was working on a project that used php, it took me a lot of time to debug that one. Never even figured out what was causing it. Seriuosly, whitespace?<|eor|><|sor|>Yes. PHP noobs often end their scripts with `?>`, because the symmetry between `<?php` at the beginning and `?>` feels like it should make sense; however, if you include some whitespace after the `?>`, PHP interprets it as literal output (depending on a bunch of highly unmemorizable rules), and any literal output, just like `print` or `echo` statements, triggers any pending HTTP headers to be sent; once that happens, trying to set more headers produces the "headers already sent" error. The great thing about this is that it makes for incredibly obscure action-at-a-distance bugs: the point that triggers it (a completely innocent call to `header()`) is completely unrelated to the cause, and that cause is "invisible". It's the perfect crime.<|eor|><|eols|><|endoftext|>
11
lolphp
neslinesli93
cdve8pk
<|sols|><|sot|>Now Python can have the reliability of PHP (x-post /r/Python)<|eot|><|sol|>https://github.com/ajalt/fuckitpy<|eol|><|sor|>Inside tests.py: def test_context_manager(): with fuckit: pass assert 'P' != 'NP' # proof is left as an excercise for the reader<|eor|><|eols|><|endoftext|>
10
lolphp
Sarcastinator
cdxdnd9
<|sols|><|sot|>Now Python can have the reliability of PHP (x-post /r/Python)<|eot|><|sol|>https://github.com/ajalt/fuckitpy<|eol|><|sor|>Admirable attempt, but not quite there yet. In order to compete with PHP, we need at least the following: * Two more independent and non-optional error handling systems next to the exception system, such that the available libraries and language built-ins randomly use either one * Non-maskable fatal errors for relatively benign error conditions, such as trying to call a method that doesn't exist (right now, Python just throws an exception that you can catch at will - this is obviously no good, a severe crime like this must be punished) * A multi-faceted system for the configuration of the error handling systems; it has to be so complex that you can't rely on anything whatsoever. * Some sort of syntax quirk that causes a script to produce really confusing errors saying something about "headers already sent" when you add whitespace in strategic positions. * When a web application is detected, we need a way of exposing the HTTP response body as STDOUT/STDERR from anywhere in any Python script. But at least we already have utterly confusing scoping rules in Python. That's a start.<|eor|><|sor|>>Some sort of syntax quirk that causes a script to produce really confusing errors saying something about "headers already sent" when you add whitespace in strategic positions. I was working on a project that used php, it took me a lot of time to debug that one. Never even figured out what was causing it. Seriuosly, whitespace?<|eor|><|sor|>Yes. PHP noobs often end their scripts with `?>`, because the symmetry between `<?php` at the beginning and `?>` feels like it should make sense; however, if you include some whitespace after the `?>`, PHP interprets it as literal output (depending on a bunch of highly unmemorizable rules), and any literal output, just like `print` or `echo` statements, triggers any pending HTTP headers to be sent; once that happens, trying to set more headers produces the "headers already sent" error. The great thing about this is that it makes for incredibly obscure action-at-a-distance bugs: the point that triggers it (a completely innocent call to `header()`) is completely unrelated to the cause, and that cause is "invisible". It's the perfect crime.<|eor|><|sor|>Some text editors add BOM which will also produce this error.<|eor|><|eols|><|endoftext|>
10
lolphp
Holkr
cdv1bve
<|sols|><|sot|>Now Python can have the reliability of PHP (x-post /r/Python)<|eot|><|sol|>https://github.com/ajalt/fuckitpy<|eol|><|sor|>While this is jest, this part stands out as kinda useful: >###As a context manager### >Use fuckit as a context manager to save yourself from having to type out try/except block to silence exceptions yourself. > with fuckit: some_code >This is functionally equivalent to the following: > try: some_code except Exception: pass >The context manager form of fuckit can't allow the code to continue past an error like the decorator and import forms can. If you want the code to continue after an exception, wrap the code block in a function and use the decorator instead.<|eor|><|eols|><|endoftext|>
8
lolphp
infinull
cdvgtk0
<|sols|><|sot|>Now Python can have the reliability of PHP (x-post /r/Python)<|eot|><|sol|>https://github.com/ajalt/fuckitpy<|eol|><|sor|>from tests.py def test_chaining(): fuckit(fuckit('fuckit')) assert 'false' # Good thing this isn't PHP see: https://github.com/ajalt/fuckitpy/blob/master/tests.py#L11<|eor|><|eols|><|endoftext|>
6
lolphp
tdammers
cdwqsh3
<|sols|><|sot|>Now Python can have the reliability of PHP (x-post /r/Python)<|eot|><|sol|>https://github.com/ajalt/fuckitpy<|eol|><|sor|>Admirable attempt, but not quite there yet. In order to compete with PHP, we need at least the following: * Two more independent and non-optional error handling systems next to the exception system, such that the available libraries and language built-ins randomly use either one * Non-maskable fatal errors for relatively benign error conditions, such as trying to call a method that doesn't exist (right now, Python just throws an exception that you can catch at will - this is obviously no good, a severe crime like this must be punished) * A multi-faceted system for the configuration of the error handling systems; it has to be so complex that you can't rely on anything whatsoever. * Some sort of syntax quirk that causes a script to produce really confusing errors saying something about "headers already sent" when you add whitespace in strategic positions. * When a web application is detected, we need a way of exposing the HTTP response body as STDOUT/STDERR from anywhere in any Python script. But at least we already have utterly confusing scoping rules in Python. That's a start.<|eor|><|sor|>You forgot Hebrew error messages. Clearly the most important part.<|eor|><|sor|>Hebrew error messages are a nice-to-have, great to give the whole thing a bit of a professional touch, but they're not required for a rock-solid error handling system. Misleading error messages in what looks like plain English but really isn't are much more robust anyway.<|eor|><|eols|><|endoftext|>
6
lolphp
tdammers
cdz0ljt
<|sols|><|sot|>Now Python can have the reliability of PHP (x-post /r/Python)<|eot|><|sol|>https://github.com/ajalt/fuckitpy<|eol|><|sor|>Admirable attempt, but not quite there yet. In order to compete with PHP, we need at least the following: * Two more independent and non-optional error handling systems next to the exception system, such that the available libraries and language built-ins randomly use either one * Non-maskable fatal errors for relatively benign error conditions, such as trying to call a method that doesn't exist (right now, Python just throws an exception that you can catch at will - this is obviously no good, a severe crime like this must be punished) * A multi-faceted system for the configuration of the error handling systems; it has to be so complex that you can't rely on anything whatsoever. * Some sort of syntax quirk that causes a script to produce really confusing errors saying something about "headers already sent" when you add whitespace in strategic positions. * When a web application is detected, we need a way of exposing the HTTP response body as STDOUT/STDERR from anywhere in any Python script. But at least we already have utterly confusing scoping rules in Python. That's a start.<|eor|><|sor|>>Some sort of syntax quirk that causes a script to produce really confusing errors saying something about "headers already sent" when you add whitespace in strategic positions. I was working on a project that used php, it took me a lot of time to debug that one. Never even figured out what was causing it. Seriuosly, whitespace?<|eor|><|sor|>Yes. PHP noobs often end their scripts with `?>`, because the symmetry between `<?php` at the beginning and `?>` feels like it should make sense; however, if you include some whitespace after the `?>`, PHP interprets it as literal output (depending on a bunch of highly unmemorizable rules), and any literal output, just like `print` or `echo` statements, triggers any pending HTTP headers to be sent; once that happens, trying to set more headers produces the "headers already sent" error. The great thing about this is that it makes for incredibly obscure action-at-a-distance bugs: the point that triggers it (a completely innocent call to `header()`) is completely unrelated to the cause, and that cause is "invisible". It's the perfect crime.<|eor|><|sor|>Some PMs and dev team managers actually *insist* on the presence of `?>` in all scripts, but further mandate that the final newline of the file is removed. When it is explained that the `?>` can simply be left out to avoid the problem altogether, they make threats and repeat their insistence that it's mandatory.<|eor|><|sor|>Situations like these are when you brush up your resume and head for greener pastures...<|eor|><|sor|>Yeah, I got "laid off." I'm much happier now.<|eor|><|sor|>"You can't quit! I'm firing you!"<|eor|><|eols|><|endoftext|>
5
lolphp
SjaakRake
m0kucy
<|sols|><|sot|>DateTimeInterface::ISO8601 - Note: This format is not compatible with ISO-8601.<|eot|><|sol|>https://www.php.net/manual/en/class.datetimeinterface.php#datetime.constants.iso8601<|eol|><|eols|><|endoftext|>
63
lolphp
ZiggyTheHamster
gq9esfm
<|sols|><|sot|>DateTimeInterface::ISO8601 - Note: This format is not compatible with ISO-8601.<|eot|><|sol|>https://www.php.net/manual/en/class.datetimeinterface.php#datetime.constants.iso8601<|eol|><|sor|>There was an RFC (not sure if it was called that back then) that discussed this. Some ppl wanted REAL_ISO8601, but after a heated debate they agreed on ATOM instead.<|eor|><|sor|>`REAL_ISO8601` is considerably less stupid than `ATOM`. `STRICT_ISO8601` is even better, because it makes it look like the old format is a permissive interpretation of the spec...which is a nice way of saying they didn't pay ISO for the spec when they added it originally and winged it.<|eor|><|eols|><|endoftext|>
24
lolphp
elcapitanoooo
gq8zy9s
<|sols|><|sot|>DateTimeInterface::ISO8601 - Note: This format is not compatible with ISO-8601.<|eot|><|sol|>https://www.php.net/manual/en/class.datetimeinterface.php#datetime.constants.iso8601<|eol|><|sor|>There was an RFC (not sure if it was called that back then) that discussed this. Some ppl wanted REAL_ISO8601, but after a heated debate they agreed on ATOM instead.<|eor|><|eols|><|endoftext|>
17
lolphp
Takeoded
gq90vyk
<|sols|><|sot|>DateTimeInterface::ISO8601 - Note: This format is not compatible with ISO-8601.<|eot|><|sol|>https://www.php.net/manual/en/class.datetimeinterface.php#datetime.constants.iso8601<|eol|><|sor|>has been discussed countless times before, and before someone comes saying "it doesn't really break the specs", yes it fking does. quoting ISO8601:2004 section 4.3.3: > For reduced accuracy, decimal or expanded representations of date and time of day, any of the > representations in 4.1.2 (calendar dates), 4.1.3 (ordinal dates) or 4.1.4 (week dates) followed immediately by > the time designator [T] may be combined with any of the representations in 4.2.2.2 through 4.2.2.4 (local time), > 4.2.4 (UTC of day) or 4.2.5.2 (local time and the difference from UTC) provided that > (...skipped stuff...) > d) the expression shall either be completely in basic format, in which case the minimum number of > separators necessary for the required expression is used, or completely in extended format, in which case > additional separators shall be used in accordance with 4.1 and 4.2. php's constant does exactly what the d section says isn't legal, `1970-01-01T01:00:00` is extended format, and `+0100` is basic format, breaking the `the expression shall either be completely in basic format, in which case the minimum number of separators necessary for the required expression is used, or completely in extended format` -part. (discussed more in-depth [here](https://www.reddit.com/r/lolphp/comments/idui3p/breakingtofix_in_array_for_php8_ok_breakingtofix/g2cjz2g/?utm_source=reddit&utm_medium=web2x&context=3) )<|eor|><|eols|><|endoftext|>
17
lolphp
Takeoded
gq91gwu
<|sols|><|sot|>DateTimeInterface::ISO8601 - Note: This format is not compatible with ISO-8601.<|eot|><|sol|>https://www.php.net/manual/en/class.datetimeinterface.php#datetime.constants.iso8601<|eol|><|sor|>There was an RFC (not sure if it was called that back then) that discussed this. Some ppl wanted REAL_ISO8601, but after a heated debate they agreed on ATOM instead.<|eor|><|sor|>> REAL_ISO8601 haha that's gold. FWIW `var_dump(DateTime::ATOM === DateTime::RFC3339);` => `bool(true)`<|eor|><|eols|><|endoftext|>
8
lolphp
supereater14
8zn3zj
<|sols|><|sot|>Admitting their own faults.<|eot|><|sol|>https://twitter.com/official_php/status/1019024916811866113?s=19<|eol|><|eols|><|endoftext|>
64
lolphp
SaraMG
e2kjd2b
<|sols|><|sot|>Admitting their own faults.<|eot|><|sol|>https://twitter.com/official_php/status/1019024916811866113?s=19<|eol|><|sor|>(_) I prefer to call that ( _)>- Self-deprecating humor (_)<|eor|><|eols|><|endoftext|>
25
lolphp
girst
e2k20xd
<|sols|><|sot|>Admitting their own faults.<|eot|><|sol|>https://twitter.com/official_php/status/1019024916811866113?s=19<|eol|><|sor|>that twitter account is quite ... something: > Searching in strings using integers (which are cast to their ascii ordinal values???) now deprecated in PHP 7.3 [(s)](https://twitter.com/official_php/status/1018948342074806277) --- >\#RFC sorta-kinda half-passes. >array\_key\_(first|last)(): 18 for, 14 against. >array\_value\_(first|last)(): 15 for, 18 against. [(s)](https://twitter.com/official_php/status/1019023703286472704)<|eor|><|eols|><|endoftext|>
13
lolphp
bj_christianson
e2k8vuu
<|sols|><|sot|>Admitting their own faults.<|eot|><|sol|>https://twitter.com/official_php/status/1019024916811866113?s=19<|eol|><|sor|>that twitter account is quite ... something: > Searching in strings using integers (which are cast to their ascii ordinal values???) now deprecated in PHP 7.3 [(s)](https://twitter.com/official_php/status/1018948342074806277) --- >\#RFC sorta-kinda half-passes. >array\_key\_(first|last)(): 18 for, 14 against. >array\_value\_(first|last)(): 15 for, 18 against. [(s)](https://twitter.com/official_php/status/1019023703286472704)<|eor|><|sor|>> Undocumented functions? Not on my watch! Undocumented mbstring alias functions deprecated in PHP 7.3. #RFC passes 37:1 (there's always someone, isn't there?) Yes. Yes, there is.<|eor|><|eols|><|endoftext|>
8
lolphp
shitcanz
5kj176
<|soss|><|sot|>Laravel Elixir is renaming the project. In part because of name confusion with Elixir-lang. New name is "MIX" https://laravel-news.com/laravel-elixir-to-laravel-mix For those who don't know: "MIX" is the Elixir lang build tool. HAHAH!<|eot|><|sost|><|eost|><|eoss|><|endoftext|>
60
lolphp
Conradfr
dboainm
<|soss|><|sot|>Laravel Elixir is renaming the project. In part because of name confusion with Elixir-lang. New name is "MIX" https://laravel-news.com/laravel-elixir-to-laravel-mix For those who don't know: "MIX" is the Elixir lang build tool. HAHAH!<|eot|><|sost|><|eost|><|sor|>As a PHP dev currently trying Elixir that's funny. But where is it said it's because of Elixir-lang?<|eor|><|eoss|><|endoftext|>
15
lolphp
porkslow
dbobskd
<|soss|><|sot|>Laravel Elixir is renaming the project. In part because of name confusion with Elixir-lang. New name is "MIX" https://laravel-news.com/laravel-elixir-to-laravel-mix For those who don't know: "MIX" is the Elixir lang build tool. HAHAH!<|eot|><|sost|><|eost|><|sor|>Why not just use Node.js directly instead of a thin PHP wrapper around it?<|eor|><|eoss|><|endoftext|>
13
lolphp
dwcmwa
dbplmlb
<|soss|><|sot|>Laravel Elixir is renaming the project. In part because of name confusion with Elixir-lang. New name is "MIX" https://laravel-news.com/laravel-elixir-to-laravel-mix For those who don't know: "MIX" is the Elixir lang build tool. HAHAH!<|eot|><|sost|><|eost|><|sor|>Why not just name it "Left Pad"?<|eor|><|eoss|><|endoftext|>
6
lolphp
ealf
51kqyu
<|sols|><|sot|>Let's just say don't use parse_url for your oauth implementation<|eot|><|sol|>https://3v4l.org/GqOOI<|eol|><|eols|><|endoftext|>
63
lolphp
sloat
d7cutpa
<|sols|><|sot|>Let's just say don't use parse_url for your oauth implementation<|eot|><|sol|>https://3v4l.org/GqOOI<|eol|><|sor|>It seems that filter_var with FILTER_VALIDATE_URL validates according to RFC2396, [although somewhat incorrectly](https://3v4l.org/EkfBM). The 3rd URL and "tel:" URIs should be valid as near as I can tell. The [documentation for parse_url](http://php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-seealso) contains a link to RFC3986, implying that parse_url is compliant with the newer RFC. It is not compliant.<|eor|><|eols|><|endoftext|>
22
lolphp
graingert
d7dz68y
<|sols|><|sot|>Let's just say don't use parse_url for your oauth implementation<|eot|><|sol|>https://3v4l.org/GqOOI<|eol|><|sor|>`parse_url` is a mess. It probably needs a ground-up rewrite.<|eor|><|sor|>Just shell out to `python3 -c __import__(urllib.parse")...'`<|eor|><|eols|><|endoftext|>
18
lolphp
the_alias_of_andrea
d7d3pgk
<|sols|><|sot|>Let's just say don't use parse_url for your oauth implementation<|eot|><|sol|>https://3v4l.org/GqOOI<|eol|><|sor|>`parse_url` is a mess. It probably needs a ground-up rewrite.<|eor|><|eols|><|endoftext|>
13
lolphp
stesch
d7i0fjj
<|sols|><|sot|>Let's just say don't use parse_url for your oauth implementation<|eot|><|sol|>https://3v4l.org/GqOOI<|eol|><|sor|>So I dug into this with my limited knowledge of the PHP bug tracker. I found this hilarious issue, please read the comments: https://bugs.php.net/bug.php?id=54369 Just to get you started, this is what the poor schmucks defending RFC compliance have to resort to: > I'm not sure why you'd think users of parse_url would expect the reported outcome - that is simply not a valid hostname (not in RFC1738 nor in RFC3986) **Spoiler** It all ends with the bug behaviour being kept because they don't want to break backwards compatibility!<|eor|><|sor|>It's time for `real_parse_url()`. <|eor|><|eols|><|endoftext|>
12
lolphp
ealf
d7dx55b
<|sols|><|sot|>Let's just say don't use parse_url for your oauth implementation<|eot|><|sol|>https://3v4l.org/GqOOI<|eol|><|sor|>It seems that filter_var with FILTER_VALIDATE_URL validates according to RFC2396, [although somewhat incorrectly](https://3v4l.org/EkfBM). The 3rd URL and "tel:" URIs should be valid as near as I can tell. The [documentation for parse_url](http://php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-seealso) contains a link to RFC3986, implying that parse_url is compliant with the newer RFC. It is not compliant.<|eor|><|soopr|>Oh god 'http://foo.com?@bar.com/': VALID scheme(http) host(bar.com) user(foo.com?) path(/) <|eoopr|><|eols|><|endoftext|>
9
lolphp
kmag2
d7mbnqv
<|sols|><|sot|>Let's just say don't use parse_url for your oauth implementation<|eot|><|sol|>https://3v4l.org/GqOOI<|eol|><|sor|>`parse_url` is a mess. It probably needs a ground-up rewrite.<|eor|><|sor|>Works as expected. Will not fix. If you want RFC3986 URL validation, set PARSE_URL_NEW_NEW=3968 in php.ini and use mysql_real_parse_url()<|eor|><|eols|><|endoftext|>
8
lolphp
kmag2
d7mbua6
<|sols|><|sot|>Let's just say don't use parse_url for your oauth implementation<|eot|><|sol|>https://3v4l.org/GqOOI<|eol|><|sor|>So I dug into this with my limited knowledge of the PHP bug tracker. I found this hilarious issue, please read the comments: https://bugs.php.net/bug.php?id=54369 Just to get you started, this is what the poor schmucks defending RFC compliance have to resort to: > I'm not sure why you'd think users of parse_url would expect the reported outcome - that is simply not a valid hostname (not in RFC1738 nor in RFC3986) **Spoiler** It all ends with the bug behaviour being kept because they don't want to break backwards compatibility!<|eor|><|sor|>It's time for `real_parse_url()`. <|eor|><|sor|>They already beat you to it. mysql_real_parse_url() is already a thing. The insane thing is that with the PHP, you can't be sure if I'm pulling your chain without checking documentation. Twice. Because PHP core devs. Edit: to be honest, if they think these bugs are so vital to correct functioning of the ecosystem, they should have a bug_fixed() function that takes an integer argument. Once a PHP bug tracker issue is verified to be a genuine bug, it gets assigned an official bug number that gets linked from the (potentially duplicate) reported issues. You report a bug, and work around it. When it gets acknowledged as a genuine bug, you wrap your workaround in if ( bug_fixed( 1234 ) ) { ... } else { ... } you have two entries in php.ini ... one for bugfixes to turn off, and one for bugfixes to force on. Most bug fixes would be enabled by default in the next point release, but in rare cases the bug fixes might need to wait for the next major release to be enabled by default. Once a bug has been enabled by default for two major releases without the world nearly ending, retire the ability to re-enable the bug. Every release has a list of new bug fixes included, so if you run into issues when upgrading, you first look at the list of newly fixed bugs and re-enable those bugs to see if your issue is due to depending upon buggy behavior. (Okay, technically all PHP code, including Hello World, relies upon buggy behavior, but you know what I mean.) If you really need to preserve buggy behavior, this is the way to slowly retire your bugs without the world ending. In the case of mysql_escape_string(), the real fix is to have the C++ fix throw an exception that says "Use parameterized queries instead". You turn this on this bugfix by default in PHP 9, but people are able to disable it. By PHP 11, you can just make mysql_escape_string() throw unconditionally or remove it all together. In PHP 10, you start the same process for mysql_real_escape_string(), since it's still an ugly broken hack that is fixed much more elegantly by parameterized queries.<|eor|><|eols|><|endoftext|>
7
lolphp
emilvikstrom
d7fcwed
<|sols|><|sot|>Let's just say don't use parse_url for your oauth implementation<|eot|><|sol|>https://3v4l.org/GqOOI<|eol|><|sor|>So I dug into this with my limited knowledge of the PHP bug tracker. I found this hilarious issue, please read the comments: https://bugs.php.net/bug.php?id=54369 Just to get you started, this is what the poor schmucks defending RFC compliance have to resort to: > I'm not sure why you'd think users of parse_url would expect the reported outcome - that is simply not a valid hostname (not in RFC1738 nor in RFC3986) **Spoiler** It all ends with the bug behaviour being kept because they don't want to break backwards compatibility!<|eor|><|eols|><|endoftext|>
6
lolphp
bs4h
2ykfex
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|eols|><|endoftext|>
63
lolphp
DoctorWaluigiTime
cpapmdy
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>[deleted]<|eor|><|sor|>Because when I see types being used like *every strongly typed language in existance*, I'm supposed to go to the manual and read about all its quirks about how it actually goes against the grain. But then, it is PHP, so yeah it is generally good to read the pages from top to bottom with any new thing you're trying to use.<|eor|><|eols|><|endoftext|>
26
lolphp
TheBuzzSaw
cpaja81
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>I just don't understand PHP enthusiasts. PHP has the *worst* of every language. PHP only _complicates_ programming. It simplifies nothing. It bewilders me that code line count is the sole metric for language quality. I'd much rather read 5 verbose lines than 1 compact line with a dozen layers of implied behavior. This link only emphasizes the horror. Why doesn't the language shield the developer from these discrepancies? If I have to think this much about my variables and objects, I'll just use a more rigorous language like C# or Java.<|eor|><|eols|><|endoftext|>
24
lolphp
DoctorWaluigiTime
cpax4o0
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>[deleted]<|eor|><|sor|>Because when I see types being used like *every strongly typed language in existance*, I'm supposed to go to the manual and read about all its quirks about how it actually goes against the grain. But then, it is PHP, so yeah it is generally good to read the pages from top to bottom with any new thing you're trying to use.<|eor|><|sor|>You're failing to realize that PHP *isn't a strongly-typed language*. So yes, when you see types being used *in a weakly-typed language* you really need to read the manual to see how it works.<|eor|><|sor|>When you create a syntax of `MyFunction(string myVariable)` you are indeed leading programmers by the nose that they can, in fact, pass a string to that function. No amount of weasel-wording will change that.<|eor|><|sor|>If programmers make assumptions about the inter workings of the language by just looking at code, then they are not very good programmers. Stop making stupid excuses.<|eor|><|sor|>if I see `MyFunction(string myVariable)` and I call it using `MyFunction("myString")` *and* `"myString"` is identified via `var_dump("myString")` as `string(8) "myString"` then there is no excuse. Especially when the error is "Argument 1 passed to MyFunction() must be an instance of string, string given." That's just downright misleading.<|eor|><|eols|><|endoftext|>
23
lolphp
Sarcastinator
cpbdmmh
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>I just don't understand PHP enthusiasts. PHP has the *worst* of every language. PHP only _complicates_ programming. It simplifies nothing. It bewilders me that code line count is the sole metric for language quality. I'd much rather read 5 verbose lines than 1 compact line with a dozen layers of implied behavior. This link only emphasizes the horror. Why doesn't the language shield the developer from these discrepancies? If I have to think this much about my variables and objects, I'll just use a more rigorous language like C# or Java.<|eor|><|sor|>Ah, but it has the worst of *every* language. Like with C++, I really like the amount of options, and that I can choose *how* to fuck up my project this time. Shielded languages are for chumps. And java lovers. Edit: and to clarify my stance: PHP does a lot of things bad, but at least it does a lot of things.<|eor|><|sor|>> Like with C++, I really like the amount of options, and that I can choose how to fuck up my project this time C++ doesn't try to hold your hand at all, and everybody knows it. It's a big part of C++'s appeal. PHP does but it's just that PHP has very small hands and they are very greasy for some reason.<|eor|><|eols|><|endoftext|>
20
lolphp
DoctorWaluigiTime
cpauos2
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>[deleted]<|eor|><|sor|>Because when I see types being used like *every strongly typed language in existance*, I'm supposed to go to the manual and read about all its quirks about how it actually goes against the grain. But then, it is PHP, so yeah it is generally good to read the pages from top to bottom with any new thing you're trying to use.<|eor|><|sor|>You're failing to realize that PHP *isn't a strongly-typed language*. So yes, when you see types being used *in a weakly-typed language* you really need to read the manual to see how it works.<|eor|><|sor|>When you create a syntax of `MyFunction(string myVariable)` you are indeed leading programmers by the nose that they can, in fact, pass a string to that function. No amount of weasel-wording will change that.<|eor|><|eols|><|endoftext|>
19
lolphp
cite-reader
cpbndxw
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>The real wtf here is that type hints are not at all resolved to an actual class name. I mean, why is the following allowed, when no myclass type exists ? function wtf(myclass $s){ echo "something!"; } <|eor|><|sor|>Because PHP does not know how to assemble an application. There's no meaningful distinction between compile time and run time, like there is in Common Lisp or Perl, to pick two aggressively dynamic languages that have such a thing. PHP's classes don't exist until they're loaded, dynamically, by run-time code. When does that code run? Who knows! Old apps will `require_once` all the things they need up front, but the newer style is to register "autoloaders": arbitrary code that loads up unknown classes the first time the engine encounters it. (This is presumably inspired by Java's classloader feature, given that the rest of the PHP object system is a half-assed clone of Java's.) For, um, *reasons,* a type hint doesn't count as important enough to fire up the autoloader. I've blocked the conversation that I learned this in from my memory, so I couldn't tell you whether those reasons are convincing or not.<|eor|><|eols|><|endoftext|>
18
lolphp
DoctorWaluigiTime
cpazzvp
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>[deleted]<|eor|><|sor|>Because when I see types being used like *every strongly typed language in existance*, I'm supposed to go to the manual and read about all its quirks about how it actually goes against the grain. But then, it is PHP, so yeah it is generally good to read the pages from top to bottom with any new thing you're trying to use.<|eor|><|sor|>You're failing to realize that PHP *isn't a strongly-typed language*. So yes, when you see types being used *in a weakly-typed language* you really need to read the manual to see how it works.<|eor|><|sor|>When you create a syntax of `MyFunction(string myVariable)` you are indeed leading programmers by the nose that they can, in fact, pass a string to that function. No amount of weasel-wording will change that.<|eor|><|sor|>If programmers make assumptions about the inter workings of the language by just looking at code, then they are not very good programmers. Stop making stupid excuses.<|eor|><|sor|>if I see `MyFunction(string myVariable)` and I call it using `MyFunction("myString")` *and* `"myString"` is identified via `var_dump("myString")` as `string(8) "myString"` then there is no excuse. Especially when the error is "Argument 1 passed to MyFunction() must be an instance of string, string given." That's just downright misleading.<|eor|><|sor|>Yes, the error message is misleading. However, I am pointing out the fundamental mistake of assuming how a thing works based on your previous experience. I'm no trying to defend the choices made in PHP. You simply have to consult the documentation. Especially in the case of PHP. In the specific case, the fact that the language is not strong typed should raise a flag about looking up how the feature works before using it.<|eor|><|sor|>"You simply have to consult the documentation" is no excuse for taking a paradigm that exists all over the place, then inserting behavior that is nonintuitive and contradictory to that other way of doing things. It's the baloney argument that occurs whenever something quirky or wrong happens in PHP. "But it's documented!" Bad documented behavior is still bad behavior. It does not matter that PHP is not strongly typed. PHP hinting is supposed to lock down the types. That's what it's for. And it does not, because of bad design. "Consult the documentation" does not change that.<|eor|><|eols|><|endoftext|>
15
lolphp
willfe42
cpban6e
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>[deleted]<|eor|><|sor|>Because when I see types being used like *every strongly typed language in existance*, I'm supposed to go to the manual and read about all its quirks about how it actually goes against the grain. But then, it is PHP, so yeah it is generally good to read the pages from top to bottom with any new thing you're trying to use.<|eor|><|sor|>You're failing to realize that PHP *isn't a strongly-typed language*. So yes, when you see types being used *in a weakly-typed language* you really need to read the manual to see how it works.<|eor|><|sor|>When you create a syntax of `MyFunction(string myVariable)` you are indeed leading programmers by the nose that they can, in fact, pass a string to that function. No amount of weasel-wording will change that.<|eor|><|sor|>You're just confused. You're incorrectly assuming that the word "string" is reserved in PHP. It's not because PHP is a weakly-typed language. If a developer decides to call a class "string" then an object of that type will be required in your example. It's as simple as that.<|eor|><|sor|>I think _you're_ confused. It's okay; PHP is a wart-ridden language, so it's easy to become confused. According to the [right fine manual](http://php.net/manual/en/language.types.type-juggling.php), `int`, `integer`, `bool`, `boolean`, `float`, `double`, `real`, `string`, `array`, `object` and `unset` (lol) are all reserved keywords, at least inside parenthesis where they're used as typecasts.<|eor|><|eols|><|endoftext|>
13
lolphp
myaut
cpb9mw2
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>[deleted]<|eor|><|sor|>Because when I see types being used like *every strongly typed language in existance*, I'm supposed to go to the manual and read about all its quirks about how it actually goes against the grain. But then, it is PHP, so yeah it is generally good to read the pages from top to bottom with any new thing you're trying to use.<|eor|><|sor|>You're failing to realize that PHP *isn't a strongly-typed language*. So yes, when you see types being used *in a weakly-typed language* you really need to read the manual to see how it works.<|eor|><|sor|>When you create a syntax of `MyFunction(string myVariable)` you are indeed leading programmers by the nose that they can, in fact, pass a string to that function. No amount of weasel-wording will change that.<|eor|><|sor|>You're just confused. You're incorrectly assuming that the word "string" is reserved in PHP. It's not because PHP is a weakly-typed language. If a developer decides to call a class "string" then an object of that type will be required in your example. It's as simple as that.<|eor|><|sor|>> You're incorrectly assuming that the word "string" is reserved in PHP. That's actually reveals more fundamental lolphp. Languages that support more or less RTTI dynamicness usually have two categories of types: Primitive and Object. I.e. one of differences between Scala and Java is that Scala replaced all Primitive types with Object (Reference) ones. Primitive types are support one set of features, Object - another (usually a superset). PHP has: * Zend "primitive" types (that don't have reserved keyword) * Zend stdClass() and similiar * Userspace classes And of course, various PHP features have own rules on how they handle these categories: * new on stdClass() may return NULL, but on Userspace classes it never does that * Type hinting - looks like it covers callable, array (seem to be Zend Primitive?) and Userspace classes<|eor|><|eols|><|endoftext|>
12
lolphp
DoctorWaluigiTime
cpb2r7a
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>[deleted]<|eor|><|sor|>Because when I see types being used like *every strongly typed language in existance*, I'm supposed to go to the manual and read about all its quirks about how it actually goes against the grain. But then, it is PHP, so yeah it is generally good to read the pages from top to bottom with any new thing you're trying to use.<|eor|><|sor|>You're failing to realize that PHP *isn't a strongly-typed language*. So yes, when you see types being used *in a weakly-typed language* you really need to read the manual to see how it works.<|eor|><|sor|>When you create a syntax of `MyFunction(string myVariable)` you are indeed leading programmers by the nose that they can, in fact, pass a string to that function. No amount of weasel-wording will change that.<|eor|><|sor|>But *nobody* writes `myFunction(string $var)` in PHP, so you're entire point is moot.<|eor|><|sor|>Nobody uses typehinting? Nobody would *like* to use typehinting with string, int, et al? They don't use it, because it doesn't work. : p I would love to use it, and when I first came across typehinting, that was the first thing I tried to do. But then PHP came in, tapped on my shoulder, and said "yeah, a string isn't a string, didn't you know?"<|eor|><|eols|><|endoftext|>
9
lolphp
Rolegros
cpbf8ss
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>The real wtf here is that type hints are not at all resolved to an actual class name. I mean, why is the following allowed, when no myclass type exists ? function wtf(myclass $s){ echo "something!"; } <|eor|><|eols|><|endoftext|>
8
lolphp
DoctorWaluigiTime
cpbbi63
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>[deleted]<|eor|><|sor|>Because when I see types being used like *every strongly typed language in existance*, I'm supposed to go to the manual and read about all its quirks about how it actually goes against the grain. But then, it is PHP, so yeah it is generally good to read the pages from top to bottom with any new thing you're trying to use.<|eor|><|sor|>You're failing to realize that PHP *isn't a strongly-typed language*. So yes, when you see types being used *in a weakly-typed language* you really need to read the manual to see how it works.<|eor|><|sor|>When you create a syntax of `MyFunction(string myVariable)` you are indeed leading programmers by the nose that they can, in fact, pass a string to that function. No amount of weasel-wording will change that.<|eor|><|sor|>But *nobody* writes `myFunction(string $var)` in PHP, so you're entire point is moot.<|eor|><|sor|>Nobody uses typehinting? Nobody would *like* to use typehinting with string, int, et al? They don't use it, because it doesn't work. : p I would love to use it, and when I first came across typehinting, that was the first thing I tried to do. But then PHP came in, tapped on my shoulder, and said "yeah, a string isn't a string, didn't you know?"<|eor|><|sor|>Except it will work in PHP7 when type hints are added. What you're doing is pressing the NOS button without any Nitrous installed. Of course it's not gonna work. <|eor|><|sor|>And PHP was the one who made the car that has a NOS button, but didn't install the Nitrous.<|eor|><|eols|><|endoftext|>
7
lolphp
OneWingedShark
cpaocr5
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>I just don't understand PHP enthusiasts. PHP has the *worst* of every language. PHP only _complicates_ programming. It simplifies nothing. It bewilders me that code line count is the sole metric for language quality. I'd much rather read 5 verbose lines than 1 compact line with a dozen layers of implied behavior. This link only emphasizes the horror. Why doesn't the language shield the developer from these discrepancies? If I have to think this much about my variables and objects, I'll just use a more rigorous language like C# or Java.<|eor|><|sor|>> PHP only complicates programming. It simplifies nothing. I'd much rather read 5 verbose lines than 1 compact line with a dozen layers of implied behavior. > > > I'll just use a more rigorous language like C# or Java. PHP pretty much cemented my love for Ada. About the only thing that's at all 'nicer' in PHP is (A) the ability to use an Array as an as-hoc record, and (B) the sheer amount of libraries/APIs available. [And if we're being serious (A) can be very much "*more trouble than it's worth*".] (Funnily enough, I've done prototyping for several internal-use utilities in Ada and then translated/reimplemented in PHP [because that's what the client needed/wanted].)<|eor|><|eols|><|endoftext|>
6
lolphp
OneWingedShark
cpb6m83
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>[deleted]<|eor|><|sor|>Because when I see types being used like *every strongly typed language in existance*, I'm supposed to go to the manual and read about all its quirks about how it actually goes against the grain. But then, it is PHP, so yeah it is generally good to read the pages from top to bottom with any new thing you're trying to use.<|eor|><|sor|>You're failing to realize that PHP *isn't a strongly-typed language*. So yes, when you see types being used *in a weakly-typed language* you really need to read the manual to see how it works.<|eor|><|sor|>When you create a syntax of `MyFunction(string myVariable)` you are indeed leading programmers by the nose that they can, in fact, pass a string to that function. No amount of weasel-wording will change that.<|eor|><|sor|>But *nobody* writes `myFunction(string $var)` in PHP, so you're entire point is moot.<|eor|><|sor|>Nobody uses typehinting? Nobody would *like* to use typehinting with string, int, et al? They don't use it, because it doesn't work. : p I would love to use it, and when I first came across typehinting, that was the first thing I tried to do. But then PHP came in, tapped on my shoulder, and said "yeah, a string isn't a string, didn't you know?"<|eor|><|sor|>Nobody uses type hinting for primitives in PHP because it's *not* a feature of PHP. Nor is it in other dynamic languages, like Ruby, Python, or JavaScript. I honestly don't see what point your trying to make, as this isn't a bug, or even a lolphp. However, primitive type hints are under discussion. https://wiki.php.net/rfc/scalar_type_hints_v5<|eor|><|sor|>> Nobody uses type hinting for primitives in PHP because it's not a feature of PHP. ***Nor is it in other dynamic languages, like Ruby, Python, or JavaScript.*** Not quite true; LISP. LISP has some nice features WRT handling types. ([Type-predicates](https://www.gnu.org/software/emacs/manual/html_node/elisp/Type-Predicates.html), [type specifiers](http://www.lispworks.com/documentation/lw51/CLHS/Body/04_bc.htm), and [the exception system](http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html))<|eor|><|eols|><|endoftext|>
6
lolphp
gu3st12
cpbj190
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>Because when I see types being used like *every strongly typed language in existance*, I'm supposed to go to the manual and read about all its quirks about how it actually goes against the grain. But then, it is PHP, so yeah it is generally good to read the pages from top to bottom with any new thing you're trying to use.<|eor|><|sor|>You're failing to realize that PHP *isn't a strongly-typed language*. So yes, when you see types being used *in a weakly-typed language* you really need to read the manual to see how it works.<|eor|><|sor|>When you create a syntax of `MyFunction(string myVariable)` you are indeed leading programmers by the nose that they can, in fact, pass a string to that function. No amount of weasel-wording will change that.<|eor|><|sor|>But *nobody* writes `myFunction(string $var)` in PHP, so you're entire point is moot.<|eor|><|sor|>Nobody uses typehinting? Nobody would *like* to use typehinting with string, int, et al? They don't use it, because it doesn't work. : p I would love to use it, and when I first came across typehinting, that was the first thing I tried to do. But then PHP came in, tapped on my shoulder, and said "yeah, a string isn't a string, didn't you know?"<|eor|><|sor|>Except it will work in PHP7 when type hints are added. What you're doing is pressing the NOS button without any Nitrous installed. Of course it's not gonna work. <|eor|><|sor|>And PHP was the one who made the car that has a NOS button, but didn't install the Nitrous.<|eor|><|sor|>Except the "NOS" button you've been pressing wasn't actually for Nitrous, it was the rear defogger. <|eor|><|eols|><|endoftext|>
6
lolphp
cite-reader
cpfv58u
<|sols|><|sot|>Static type checking? Of course!<|eot|><|sol|>http://stackoverflow.com/questions/4103480/really-php-argument-1-passed-to-my-function-must-be-an-instance-of-string-s<|eol|><|sor|>The real wtf here is that type hints are not at all resolved to an actual class name. I mean, why is the following allowed, when no myclass type exists ? function wtf(myclass $s){ echo "something!"; } <|eor|><|sor|>Because PHP does not know how to assemble an application. There's no meaningful distinction between compile time and run time, like there is in Common Lisp or Perl, to pick two aggressively dynamic languages that have such a thing. PHP's classes don't exist until they're loaded, dynamically, by run-time code. When does that code run? Who knows! Old apps will `require_once` all the things they need up front, but the newer style is to register "autoloaders": arbitrary code that loads up unknown classes the first time the engine encounters it. (This is presumably inspired by Java's classloader feature, given that the rest of the PHP object system is a half-assed clone of Java's.) For, um, *reasons,* a type hint doesn't count as important enough to fire up the autoloader. I've blocked the conversation that I learned this in from my memory, so I couldn't tell you whether those reasons are convincing or not.<|eor|><|sor|>[removed]<|eor|><|sor|>I know this. One of the many, *many* ways I disagree with the general PHP community is that I consider the rejection of all execution models other than Ye Olde CGI a rather enormous misfeature. In other languages, I can write a FastCGI app that does its setup work *once.* I can do fancy things that require interacting directly with the fCGI context object. That isn't possible in PHP, unless you cheat with C extensions.<|eor|><|eols|><|endoftext|>
5
lolphp
nanashi_
1zfy0t
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|eols|><|endoftext|>
63
lolphp
ZorbaTHut
cftcdco
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>"Let's send some money somewhere! Didn't work? Don't bother asking why, just send more money" I also rather enjoy the use of floating-point to store financial data.<|eor|><|eols|><|endoftext|>
40
lolphp
ZorbaTHut
cfth536
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>"Let's send some money somewhere! Didn't work? Don't bother asking why, just send more money" I also rather enjoy the use of floating-point to store financial data.<|eor|><|sor|> if ($bean->Coins > (500*100000000)) { // more than 500 coins on this host, shuffle some~ These two lines made it look like they were using ints rather than floating point.<|eor|><|sor|>But if you look a bit higher: $bean->Coins = (int)round($info['balance'] * 100000000); Nope! Floating-point.<|eor|><|eols|><|endoftext|>
24
lolphp
ajmarks
cftcs14
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>Did i just look at 1700 lines of code with basically zero documentation?<|eor|><|eols|><|endoftext|>
22
lolphp
ZorbaTHut
cfthird
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>"Let's send some money somewhere! Didn't work? Don't bother asking why, just send more money" I also rather enjoy the use of floating-point to store financial data.<|eor|><|sor|> if ($bean->Coins > (500*100000000)) { // more than 500 coins on this host, shuffle some~ These two lines made it look like they were using ints rather than floating point.<|eor|><|sor|>But if you look a bit higher: $bean->Coins = (int)round($info['balance'] * 100000000); Nope! Floating-point.<|eor|><|sor|>Oh jesus fuck. That single line says everything.<|eor|><|sor|>My favorite part is the round(). "Hmm, we've got a gigantic pile of horse dung in the middle of this room. Should we clean it up?" "Nah, just toss this throw rug over it. See? Looks great!"<|eor|><|eols|><|endoftext|>
22
lolphp
phoshi
cftitc8
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>Did i just look at 1700 lines of code with basically zero documentation?<|eor|><|sor|>Welcome to the real world<|eor|><|sor|>The real world has lots of documentation. The problem is that nobody knows where it is, and when you do eventually find it it's wrong.<|eor|><|eols|><|endoftext|>
21
lolphp
merreborn
cfth75a
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>"Let's send some money somewhere! Didn't work? Don't bother asking why, just send more money" I also rather enjoy the use of floating-point to store financial data.<|eor|><|sor|> if ($bean->Coins > (500*100000000)) { // more than 500 coins on this host, shuffle some~ These two lines made it look like they were using ints rather than floating point.<|eor|><|sor|>But if you look a bit higher: $bean->Coins = (int)round($info['balance'] * 100000000); Nope! Floating-point.<|eor|><|sor|>Oh jesus fuck. That single line says everything.<|eor|><|eols|><|endoftext|>
21
lolphp
SquireCD
cftcype
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>Holy shit. To be fair to PHP, you can be an idiot in any language. But... holy shit. <|eor|><|eols|><|endoftext|>
19
lolphp
Darkimmortal
cftq1zv
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>Does no one stop to question whether this is really mtgox code?<|eor|><|eols|><|endoftext|>
17
lolphp
skeeto
cftw3y3
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>"Let's send some money somewhere! Didn't work? Don't bother asking why, just send more money" I also rather enjoy the use of floating-point to store financial data.<|eor|><|sor|>> I also rather enjoy the use of floating-point to store financial data. Unfortunately this part isn't actually MtGox's fault. The [bitcoind JSON RPC API](https://en.bitcoin.it/wiki/API_reference_(JSON-RPC\)) reports quantities in floating-point. They were handling it internally as an integer like they were supposed to be doing. <|eor|><|sor|>No it doesn't! JSON is just text, and bitcoin does not use floating point to handle amounts.<|eor|><|sor|>Unless you're prepared to write your own custom JSON parser, and then build a JSON-RPC library on top of it, you'll be handling quantities as floats at some point when using the API. Since the dynamic range of double precision covers all possible bitcoin quantities at full precision it's not a limiting factor. The [bitcoin wiki has a whole page dedicated this issue](https://en.bitcoin.it/wiki/Proper_Money_Handling_(JSON-RPC\)) to help people do it right. > If you are writing software that uses the JSON-RPC interface you need to be aware of possible floating-point conversion issues. I've had to deal with it in my own bitcoin projects. I wrote RES's bitcoin module, after all. <|eor|><|eols|><|endoftext|>
17
lolphp
aaarrrggh
cftkudy
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>And this is why I'm scared of leaving my current job. Imagine inheriting a piece of shit like this. I don't know what MT.gox is, but I wouldn't want to be a client of theirs after reading this fucking piece of shit. This is written by devs who don't know what they're fucking doing.<|eor|><|eols|><|endoftext|>
13
lolphp
midir
cfto87h
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>I'm hesitant to ask, but what's actually bad about this code?<|eor|><|eols|><|endoftext|>
13
lolphp
ZorbaTHut
cftmcpz
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>And this is why I'm scared of leaving my current job. Imagine inheriting a piece of shit like this. I don't know what MT.gox is, but I wouldn't want to be a client of theirs after reading this fucking piece of shit. This is written by devs who don't know what they're fucking doing.<|eor|><|sor|>At my current job, I'd say about 2/3 of the coders who worked on the codebase were great, and half the remainder were pretty good. The rest, though . . . oh god. The good news is that I've made a reputation as the guy that can refactor anything to be sane. It's kind of fun work, to be honest. Like incinerating hornet nests.<|eor|><|eols|><|endoftext|>
13
lolphp
merreborn
cftgii4
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>"Let's send some money somewhere! Didn't work? Don't bother asking why, just send more money" I also rather enjoy the use of floating-point to store financial data.<|eor|><|sor|> if ($bean->Coins > (500*100000000)) { // more than 500 coins on this host, shuffle some~ These two lines made it look like they were using ints rather than floating point.<|eor|><|eols|><|endoftext|>
12
lolphp
aaarrrggh
cftl9ql
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>Did i just look at 1700 lines of code with basically zero documentation?<|eor|><|sor|>Depends what you mean by docs. Comments aren't everything. I'd be more concerned with the general shittyness, and the lack of tests to back this shit up. It's a bag of wank, if you want the correct technical term.<|eor|><|eols|><|endoftext|>
12
lolphp
classhero
cftpekl
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>Holy shit. To be fair to PHP, you can be an idiot in any language. But... holy shit. <|eor|><|sor|>It looks like he started with Java as his first language<|eor|><|sor|>Yeah, I was wondering if there was some reason he was calling random shit "beans". I mean, he's not even using DI here.. (well, I guess he could be with that DB::DAO garbage..)<|eor|><|eols|><|endoftext|>
12
lolphp
idontlikethisname
cftnh3h
<|sols|><|sot|>Sample of Mt.Gox source code<|eot|><|sol|>http://pastebin.com/W8B3CGiN<|eol|><|sor|>Dear venezuelan government: I hate you for blocking pastebin.com.<|eor|><|sor|>what the fuck? why would anyone block pastebin<|eor|><|sor|>Haha, everyone gets surprised. I'll quote one of my previous comments: > As you may know, the government is blocking websites at will, and sometimes it is not very smart about it. [Last year they blocked bit.ly](http://blog.bitly.com/post/69096442727/bitly-is-blocked-in-venezuela-and-why-we-care), I'm guessing they caught something and thought bit.ly was the host. This year [they blocked pastebin](https://twitter.com/pastebin/status/435879980707225600). I know some people of the opposition were using it to pass messages around. I guess they figured "well, we'll block it all!".<|eor|><|eols|><|endoftext|>
11
lolphp
nick_
1x76bm
<|soss|><|sot|>$dateTime = new DateTime("0000-00-00 00:00:00");<|eot|><|sost|>November 30, -1 LEST WE FORGET In PHP's language the syntaxes blow Between the better languages, row on row, That mark our place; and in the interwebs The Apaches, still bravely serving, run Scarce heard amid the users below. We are the Developers. Short days ago We lived, wrote code, saw sunrise glow, Loved C++ and were loved, and now we die() In PHP's syntax. Take up our quarrel with the foe: To you from failing HTTP requests we throw The torch; be yours to hold it high. If ye break faith with us who die() We shall not sleep, though problems grow In PHP's syntax. <|eost|><|eoss|><|endoftext|>
61
lolphp
poizan42
cf8q9kh
<|soss|><|sot|>$dateTime = new DateTime("0000-00-00 00:00:00");<|eot|><|sost|>November 30, -1 LEST WE FORGET In PHP's language the syntaxes blow Between the better languages, row on row, That mark our place; and in the interwebs The Apaches, still bravely serving, run Scarce heard amid the users below. We are the Developers. Short days ago We lived, wrote code, saw sunrise glow, Loved C++ and were loved, and now we die() In PHP's syntax. Take up our quarrel with the foe: To you from failing HTTP requests we throw The torch; be yours to hold it high. If ye break faith with us who die() We shall not sleep, though problems grow In PHP's syntax. <|eost|><|sor|>http://3v4l.org/hsFC0 The output for 5.2.0 - 5.2.17 is the real wtf.<|eor|><|eoss|><|endoftext|>
16
lolphp
suspiciously_calm
cf8r1ts
<|soss|><|sot|>$dateTime = new DateTime("0000-00-00 00:00:00");<|eot|><|sost|>November 30, -1 LEST WE FORGET In PHP's language the syntaxes blow Between the better languages, row on row, That mark our place; and in the interwebs The Apaches, still bravely serving, run Scarce heard amid the users below. We are the Developers. Short days ago We lived, wrote code, saw sunrise glow, Loved C++ and were loved, and now we die() In PHP's syntax. Take up our quarrel with the foe: To you from failing HTTP requests we throw The torch; be yours to hold it high. If ye break faith with us who die() We shall not sleep, though problems grow In PHP's syntax. <|eost|><|sor|>Fast, insecure RNGs documented as such aren't WTF. Bad code written in PHP that is bad in its own right isn't ~~WTF~~ lolphp. This is WTF. Why is this getting downvoted while other non-WTFs get a pass?<|eor|><|eoss|><|endoftext|>
10
lolphp
nick_
cfctgh8
<|soss|><|sot|>$dateTime = new DateTime("0000-00-00 00:00:00");<|eot|><|sost|>November 30, -1 LEST WE FORGET In PHP's language the syntaxes blow Between the better languages, row on row, That mark our place; and in the interwebs The Apaches, still bravely serving, run Scarce heard amid the users below. We are the Developers. Short days ago We lived, wrote code, saw sunrise glow, Loved C++ and were loved, and now we die() In PHP's syntax. Take up our quarrel with the foe: To you from failing HTTP requests we throw The torch; be yours to hold it high. If ye break faith with us who die() We shall not sleep, though problems grow In PHP's syntax. <|eost|><|sor|>This *isn't* the WTF it seems. Date/time string parsing only returns even semi-sane results for formats it supports. This isn't even a PHP-exclusive issue.<|eor|><|soopr|>It's a stupid issue though. If a DateTime class can't do what you're asking, it shouldn't silently take on an incorrect state. It should throw an exception!<|eoopr|><|eoss|><|endoftext|>
9
lolphp
suspiciously_calm
cf8r3kq
<|soss|><|sot|>$dateTime = new DateTime("0000-00-00 00:00:00");<|eot|><|sost|>November 30, -1 LEST WE FORGET In PHP's language the syntaxes blow Between the better languages, row on row, That mark our place; and in the interwebs The Apaches, still bravely serving, run Scarce heard amid the users below. We are the Developers. Short days ago We lived, wrote code, saw sunrise glow, Loved C++ and were loved, and now we die() In PHP's syntax. Take up our quarrel with the foe: To you from failing HTTP requests we throw The torch; be yours to hold it high. If ye break faith with us who die() We shall not sleep, though problems grow In PHP's syntax. <|eost|><|sor|>http://3v4l.org/hsFC0 The output for 5.2.0 - 5.2.17 is the real wtf.<|eor|><|sor|>It should be 12:60pm, December 32nd, 65535.<|eor|><|eoss|><|endoftext|>
6
lolphp
Serialk
2n35d2
<|sols|><|sot|>When a PHP dev creates a troll issue for HHVM...<|eot|><|sol|>https://github.com/facebook/hhvm/issues/4290<|eol|><|eols|><|endoftext|>
60
lolphp
Serialk
cma0a0w
<|sols|><|sot|>When a PHP dev creates a troll issue for HHVM...<|eot|><|sol|>https://github.com/facebook/hhvm/issues/4290<|eol|><|sor|>> PHP programmers have got used to T_PAAMAYIM_NEKUDOTAYIM. Are you fuckin serious? Why in the blithering fuck are you defending mixing in random goddamn hebrew-named variables? edit: ugh. http://www.reddit.com/r/PHP/comments/1m26z1/t_paamayim_nekudotayim_v_sanity/<|eor|><|soopr|>> Are you fuckin serious? No. "troll issue".<|eoopr|><|eols|><|endoftext|>
22