« first day (1569 days earlier)      last day (3382 days later) » 

3:01 PM
I wonder if someone built a webserver with swift
 
@Danack durrrrrrr
Yeah I'm fucking stupid...
 
I hate flight delays...
I just want to go home. Why can't I just go home.
 
3:12 PM
Lol
 
mehhh
oa-res-26-240:php-src ajf$ sapi/cli/php -r 'function foobar(): int { return; } var_dump(foobar());'

Catchable fatal error: Return value of foobar() must be of the type integer, null returned in Command line code on line 1
oa-res-26-240:php-src ajf$ sapi/cli/php -r 'function foobar(): int { } var_dump(foobar());'

Catchable fatal error: Return value of foobar() must be of the type integer, none returned in Command line code on line 1
Interesting.
So return; is the same as return null;.
 
yes
obviously..?
 
No, it's not obvious for return types
 
well.. you think return; should return zero when in a function with return type int or what?
 
No
I think the error message should be none returned not null returned
IMO, function foobar(): ?int { return; } shouldn't be valid, but function foobar(): ?int { return NULL; } should
 
3:19 PM
return; was always the same as return null;
IMO
wasn't it?
 
Sure, but it doesn't make sense to treat them the same for the purposes of return types IMO
@ircmaxell You always have invaluable insights, how do you feel?
You know how @rasmus said he didn't care about memleaks and would just restart apache every 100 requests? Well... http://www.reddit.com/r/PHP/comments/2u86o6/windows_preventing_phpcgi_from_quitting_at_500/
 
@FlorianMargaine I don't know if it's a goldilocks middle ground, or not all that useful because at that point I really just want separate VMs anyway.
 
kelunik@kelunik:~$ php7 -r 'function foo () : integer { return 42; } var_dump(foo());'
Catchable fatal error:  Return value of foo() must be an instance of integer, integer returned in Command line code on line 1
Maybe that error message should be improved.
 
I am trying to run a shell script located on server, I've been seeking help for last 6 days but not able to understand . I used the link superuser.com/questions/292818/… , people here have told me its fatal and I've given my response on how i could make it a bit secure. Time is running out for me and I'm stuck at redirection in mybash script. Can someone help without joking on me.
Last time people were sharing some pics mocking at me. I am a follower of stackoverflow but finding it very disappointing. stackoverflow.com/questions/28206235/…
 
3:35 PM
Pictures? What pictures? Are they cat pictures?
 
hmm ... tomorrow will be kinda interesting
 
@kelunik Planning on it.
 
user895378
@AndreaFaulds I really don't want to see nullable return types, personally.
 
@rdlowrey Huh, why not?
Useful in many situations...
 
user895378
Because they don't sit well with me. I think they defeat the purpose of a typed return.
 
3:41 PM
@rdlowrey That's personal preference I guess...
 
user895378
If I have to do a boolean check on the result then the return type has kind of wasted my time.
 
user895378
PHP already has a mechanism for that: don't add a return type.
 
@rdlowrey I don't see how.
 
user895378
Because I still have to check what I got back from the function.
 
user895378
All you did was narrow down what the result might be.
 
3:43 PM
Sure, but not to see if it's correct
You can simply act on the value
 
user895378
Does it matter why I have to check it though?
 
user895378
It's just a personal preference, but I've always disliked nullable return types. I think it's a bad idea in general.
 
user895378
It would require some serious convincing for me not to vote no on any nullable return types RFC.
 
@Leri Can you give an example where returning null would be more appropriate than throwing an exception?
 
@Danack Repository methods.
 
3:48 PM
@Leri God no. If you're doing getUser($userId) then throwing a 'UserNotFoundException' is far more preferable than returning null.
 
oa-res-26-240:php-src ajf$ sapi/cli/php -r 'function foobar(): int { return 1.0; } var_dump(foobar());'
float(1)
oa-res-26-240:php-src ajf$ sapi/cli/php -r 'declare(strict_types=1); function foobar(): int { return 1.0; } var_dump(foobar());'

Catchable fatal error: Return value of foobar() must be of the type integer, float returned in Command line code on line 1
 
Otherwise the calling code has to both check the error and duplicate the error generation code.
 
// Possible usage of ? modifier for both parameters and return types
class BinaryTree {
    public $value;
    private $right;
    private $left;

    function right(): ?BinaryTree {
        return $this->right;
    }
    function left(): ?BinaryTree {
        return $this->left;
    }

    function setRight(?BinaryTree $t) {
        $this->right = $t;
    }
    function setLeft(?BinaryTree $t) {
        $this->left = $t;
    }
}
An example from the nullable types RFC.
 
@Danack That can easily end up in huge try/catch code which I find harder to follow than if/else branching. Personal preference also, i guess.
 
@Danack you'd need a userExists($userId); method too though, or the way to know if a user exists is catching an exception...
 
3:51 PM
If I could have function/method that could check if user exists, I'd agree with you.
But for repositories most of the time these kind of boolean calls are performance killers
 
@FlorianMargaine No, that functionality would be covered by the findBy..() functions which return a result set of matches.
 
@rdlowrey It makes sense with short circuit null-safe calls.
 
user895378
@kelunik So don't use a return type on those calls.
 
@AndreaFaulds shouldn't that be int(1) in the first sample?
 
@Danack hmm I see
 
user895378
3:53 PM
Allowing nullables just completely invalidates the whole point of a return type IMO.
 
@kelunik ...fuck, I missed that
 
@rdlowrey No, they still make sure it's ReturnType|null instead of simply mixed.
 
user895378
People are like, "zomg I can't live without strict return typing" ... then they're immediately like, "Oh wait, I want dynamic typing I need nullable return types" ... I mean WTF?
 
@Leri You shouldn't ever need to have try/catch blocks all over the place for this. If you are going to say a user's homepage (e.g. the stackoverflow profile page) if you do getUser($userID) for that page and it doesn't exist, then that is an exceptional event, and you shouldn't be handling that at a low level - the exception just needs to be thrown and then a 404 displayed.
 
user895378
@kelunik Which means I still have to check the result which defeats the whole purpose of a return type.
 
3:54 PM
@rdlowrey nullable return types isn't a dynamic thing
 
user895378
@AndreaFaulds no but it might as well be because you still have to check what it is before you can use it safely.
 
There may be cases where people need to determine whether something exists, but that is not the same as a get function.
 
@rdlowrey Static typing doesn't mean you don't have to check values
Only types
 
@AndreaFaulds null is not a valid value for an object.
 
@Danack It is for ?object.
Even in the most strongly, statically-typed languages like Haskell, this is necessary
 
3:55 PM
....
 
user895378
I've had this conversation many times ... there's really not anything anyone can say that will convince me nullable types are anything but a bad idea :)
 
Although Haskell is better as it forces you to check
As does Swift
 
@Danack there's nothing exceptional about that though, it's completely natural for users not to exist.
 
@rdlowrey You can still define it without ?.
 
If you're against nullables, you just end up with optionals
Which require checks, too.
 
3:57 PM
@PaulCrovella It's exceptional for you to go to a users page that doesn't exist. e.g. if I click on your avatar now, and you deleted your account before I managed to click through to your profile page, that would be a really rare event.
 
@Danack Makes sense but as you said: There may be cases where people need to determine whether something exists and for repositories I find it acceptable to have that in get methods to gain performance.
All I am saying that I should have possibility to use nullable return type. However, its usage should be discouraged.
 
@Leri Can you give me a scenario where you would want to i) load something from a DB by ID ii) not be sure whether it exists or not?
and iii) not have it's non-existence not be a surprise.
 
I'm with @rdlowrey on this one
 
@Danack all you're doing by clicking through my avatar is sending a bit of data to the server saying "I want to see the profile for this user id" - the profile page doesn't care whether you clicked through, or followed a malformed link from somewhere else, or just made it right up. There isn't anything exceptional about a user's input or expectations not matching up with reality.
 
@MarcelBurkhard They're always nullable in Java.
 
4:00 PM
Binary trees are a perfect example of where nullables or optionals are useful
 
@Danack Getting top comment of a post by post id is the simplest thing that got in my mind, atm. Post might not have any comments at all, in that case I'd expect result to null.
 
Why split it into ->isLeftNull() and ->getLeft()?
 
@PaulCrovella Yes there is. The exception comes from the fact that the client thinks something exists, makes a request for it, but then by the time the request arrives, the thing no longer exists. That is a disconnect in what at least one computer thinks is an accurate model of the data.
@Leri That should be covered by the find\* functions in a repository, which all return an array of stuff that match. And that array may be empty or not. But that is very different from the get* functions.
 
Is it bad practice that my website can request own API?
from same domain
0
Q: API Internal requests on own website?

I'll-Be-BackI want to develop a website and an App for Android and Apple. An App will fetch the data via API from our domain. Let say on our website, it will show a list of products or create user account; In the controller, I could use internal API request which will then fetch the data via MySQL rather t...

 
@I'll-Be-Back Depends.
 
4:05 PM
@PaulCrovella Or to put it another way, the server said that some userID existed. By the time we go to act on that information, it is no longer true. Data having been modified, invalidates any api call that was made because of that data.
 
@Danack I'd rather have getTopCommentByPostId rather than findTopCommentByPostId. because I am getting one not finding one. If you mean that I should have findCommentsByPostId and then find top one in result-set, I would not want that if I am just interested in top comment. I don't want my dbms return extra data, that I will discard.
 
It's not exceptional, it's 100% normal. The client's expectation can easily be based on some old link from some other site pointing to a user who deleted their account. It could also just have been a typo in that old link.
 
@Leri Which is why Doctrine has findoneby. Using a get method instead of a find method, and then wanting get to be nullable is just bad thinking.
 
@kelunik Can you expand a bit more details?
 
@I'll-Be-Back What does API::get('users'); do?
 
4:07 PM
@PaulCrovella "The client's expectation can easily be based on some old link from some other site pointing to a user who deleted their account. It could also just have been a typo in that old link." Both of those things are going to give error pages.
 
@Danack Yes, errors. Errors are not exceptions.
 
@Danack Agreed about naming but what should return of findOneBy be? An array/collection? I could argue about that.
 
Why have to have error detection code in your code, just throw an exception in the data retrieval and let the top level exception handler handle it.
@Leri In a perfect world, it should return a generic like array array<User>
So you know that any element of the array is a User.
 
@kelunik That call user API internally and then execute mysql query.
API::get is a method has been created before.
 
@kelunik I noticed that shortly after posting ^^
 
4:10 PM
@Danack Because passing around stack traces isn't necessary for flow control.
 
@Danack tbh, in real world I use Result objects that have success property.
 
@Danack Some array containing zero or one element, I can't see any benefit over ?User.
 
@kelunik If you're writing code that is expecting an array of elements back, then you always have to cater for the array containing 0 or more elements. If you are writing code that is expecting 1 element back, if it can return null, you now have to add code every where that method is called that handles whether it was null or not.
 
I'd still have to check if there are 0 elements and print some message.
 
I just really haven't seen a case where a getFooByID or other methods where I want a simple return type, wouldn't be more appropriate to have an exception.
 
4:15 PM
hmm ... now, what should I eat
 
@Danack To put it another way: bad user input isn't exceptional, it's the default state.
 
@kelunik "print some message." Although you can, you just need to make sure that your code that displays a result set can handle an empty set. But yeah, having a special case of "no results found" is appropriate.
 
So there's no difference to checking for null, apart from the lack of generics, so IDEs can't use the information with array<User>.
 
@I'll-Be-Back sounds like architectural clusterfuck
 
@PaulCrovella Whenever a user is passing you an ID, that ID never originates from the user. Even if the user is deciding which ID to pass in as a param, the list of IDs always originates from the server, e.g. "client list users that have name starting with dan" => client clicks on first in list => page is loaded with that usersID
If the information that the client is operating on is no longer valid, then yes it is an exceptional set of circumstances, and one the client could not have predicted.
@kelunik We definitely shouldn't fuck up the language just due to the limitations of IDEs.
/laters - need to do stuff
 
4:21 PM
@Danack You can't presume to know where the client got their information. It's not necessarily from you, and even if it was that doesn't mean it's unusual for the information to have been munged or invalidated between then and the request.
 
> Warning Stuck count for pid
-_-
PHP why are you doing this :/
stahp
 
Hmmmmmmm
I could implement weak return types
 
@AndreaFaulds agree return; should be "none"
 
Or be lazy and make them always strict for now
@NikiC and should fail a nullable typehint, right?
 
yes
 
4:27 PM
Yay, we agree! ^^
 
imho return; should be used iff the function returns void
 
It's just that return; has this completely different meaning
Yeah
 
I think you can fix this without discussion
 
Probably. /cc @LeviMorrison
 
@tereško why
 
4:36 PM
@I'll-Be-Back because only by your vague description I can tell that your "API" is violating at least 3 different OOP principles/practices
 
People asked me to join the PHP chat on StackOverflow. They forgot to mention that I need reputation to be allowed to speak. Hm.
 
@NikiC link to profile to he can has two upvotes and play?
 
He didn't post a link to his profile ^^
 
at the risk of sounding line an ars: it just might be that bashing SO's php chat room is much cooler on twitter now
 
user895378
It's very hip to bash SO chat room 11 in twitter PHP circles.
 
4:43 PM
lol
All the cool kids in JS are on IRC :/ I love the guys in the JS chat but all the big names are in small (and somewhat bigger) channels on IRC.
 
@BenjaminGruenbaum i cannot stand IRC anymore
 
irccloud is okish
 
no, I mean the format as whole
 
Here we go :)
btw, I also found out that if you can also use "explicit write access" to get rid of the reputation requirement
 
All better now.
@NikiC no, it only says that - it doesn't actually work.
 
4:54 PM
great ^^
@BenjaminGruenbaum ...
 
@NikiC seriously, try it - open a new user give them explicit write access and try to join. It'll say that they can talk but they won't be able to. There is an open bug about this in meta.se somewhere I think.
The only exception is mods that can allow this.
 
did somebody name call him xD better do a previous search
 
@rdlowrey did you end up actually using Aerys for anything?
 
user895378
@BenjaminGruenbaum click on over here real quick: dev.kelunik.com/rooms/1
 
4:59 PM
/me searches... all clear
 
I wonder if this works: @SebastianBergmann
(probably not)
 
somebody said he loves pear, that's offensive but doesn't count
2
 
:D
At least now he's one of the people pushing to stop distributing PEAR with PHP
2
 
@marcio that is offensive
 
PHPUnit still doesn't use namespaces
4
 
5:02 PM
@AndreaFaulds There was an issue recently about that - re supported versions and namespaces
iirc phpunit 5 will support only 5.6 and have namespaces
 
awesome
I remember your own Php-Parser didn't use namespaces for ages
 
@AndreaFaulds he had a strong motive, but is trying to move forward now:
 
@AndreaFaulds he had a strong motive, but is trying to move forward now:
 
@marcio You're late :P
 
5:04 PM
request timeout, is this chat made with PHP?
 
@marcio No, but this chat runs on Windows
4
 
ok, all explained
 
It's funny because it's true
 
What's up with the starring frenzy?
 
@salathe dunno
 
5:10 PM
Windows is pretty good with ASP.NET MVC and C# :D
 
People asked me to join the PHP chat on StackOverflow. They forgot to mention that I need reputation to be allowed to speak. Hm.
 
@Danack scroll up :P
 
github.com/sebastianbergmann/phpunit/issues/… <-- This actually sounds reasonable
Supporting only PHP 5.6 in PHPUnit 5 means that PHPUnit 5 can only be used with software that itself only supports PHP >= 5.6
 
@NikiC people with old versions of php don't use phpunit anyway.
 
@BenjaminGruenbaum there's many projects with extensive unit testing that support php 5.3
even by the time phpunit 5 is released I'd say that there will be rather few projects that have a requirement that's larger than php 5.4
 
5:17 PM
@NikiC meh, I guess for big projects it makes sense. Bluebird promises have unit tests all the way to IE6 and even run on netscape 7.
 
I wonder what the internet looks like through netscape today
 
I'm not sure why any unit test framework would use anything but callbacks, stuff like mocha is so much better than stuff like JUnit in terms of readability.
describe("the user interface", function(){
   it("does this thing", function(){
      // code that
   });
});
Valid php (I think) and so much nicer than JUnit syntax. Then again I have no idea what PHPUnit does and that might be nicer.
 
PHPUnit is similar to JUnit
Though a number of things are much better
E.g. PHPUnit has proper data providers
While JUnit (and only since recently) has an abomination called parametrized tests, where you drown in boilerplate code
@BenjaminGruenbaum I don't see anything appealing in that
Seems like unnecessary blabla to me
 
@NikiC Why? It's shorter, more readable and gives very useful stack traces.
 
@BenjaminGruenbaum what you wrote there doesn't yet actually do anything
Is this just different syntax for function testDoesThisThing()?
 
5:29 PM
Well, it's a passing unit test - of course it's just an example of syntax.
 
how do i execute a bash script with arguments given by user on the web
 
If yes, then I don't seem much difference
 
@NikiC yes, where things are not grouped by being in the same class and can nest easily and arbitrarily.
 
@user1977867 safely
 
I'm not saying there is a big difference, only that these tests will run on any PHP that has anonymous functions and the syntax is nicer. It's not like it's a deal breaker or anything.
 
5:31 PM
I like that things group by class, so there's to the most part a clear mapping between the class and its test
 
@crypticツ thanks, would you help me in this, and listen to what i have done till now
 
nope, g2g
 
ok, can some1 help me in this, running bash script triggered from web ui
0
Q: running bash script having subshell commands from php

user1977867I'm trying to execute a child script in bash through php shell_execute("$command") whose contents are like below. $command=$_GET['command']; $op2=shell_exec("$command"); echo "Command $command output is <pre> $op2 </pre>"; On submit I get Command /path/to/childscript some_pattern 20 usernam...

 
jsond vote is over, it passed :)
 
So no more RFC votes ... that's pretty rare recently
 
5:36 PM
@NikiC unit testing based on class is an anti-pattern IMO. A class is not always what consists of a unit nor vice versa IMO.
 
It's a reasonable first order approximation
 
probably "ReflectionParameter::getClassName()", "Deprecate INI set/get aliases", "Group Use Declarations", "Fix foreach behavior" and "pecl_http" will all end up being voted on the same fortnight though.
(it's moar accurate to say that things will start to be discussed when put to vote)
 
how can i give www-data the permission to run a shell script
the scrippt already has 777 permission
 
user895378
5:53 PM
@Leigh FYI I replied to your openssl_encrypt/decrypt() mail on the list but forgot to cc you on the email.
 
@user1977867 do you see in the apache logs any indication that php attempted to run it but failed with a permission error?
 
@BenjaminGruenbaum, strangely enough some part of my shell script gets executed and some does not and I'm sure its all about permission issue, could u plz check my question
 
I can, but it's not really interesting. Also your code is extremely risky.
$command=$_GET['command'];
$op2=shell_exec("$command"); // <- things you should never do
 
@BenjaminGruenbaum yes I intent to put a check on the pattern, that if it does not contain specific regex than dont execute
basically i have a script, which i wish to run using arguments from the web
 
@user1977867 yes, don't do that.
Use a switch and hard code the commands. Don't ever shell_exec anything that is not a constant.
 
6:02 PM
@BenjaminGruenbaum agreed, but currently problem is with running bash scripts. And i'll google how switch works in php <im vv newbie here> . Basically i can hardcode the script but I need arguments from user only (from web)
 
@user1977867 does your script run on the internet o_0? That's even worse I thought it was for something internal.
Also, you probably don't want to have a 777 permission mask on stuff
 
i'll remove exec command for sure, but still i need to run a script (path hardcoded) but with args from user
 
3 hours ago, by user1977867
Last time people were sharing some pics mocking at me. I am a follower of stackoverflow but finding it very disappointing. http://stackoverflow.com/questions/28206235/running-bash-script-having-subshell-‌​commands-from-php
 
@Danack yes thats me , and i'm into it for many hours, sorry for my poor slang but something do get off my head.
 
@user1977867 hard code the args and switch on the GET variable. Do not construct this string dynamically this sort of thing is hackers waiting to happen.
 
6:07 PM
no args can be varying , and thats what the script intents to do... work acc to given args
 
I wasn't really mocking you, it was a picture of a child juggling with knives ...
it was meant to be funny, and you were meant to listen to the advice that followed from several of us, you didn't, and are back asking the same questions ...
if anyone should be disappointed, it should be us or me ... but whatever, as I said the other day, good luck :)
 
So currently the situation lies that I have a bash script that needs to be executed using args given from the web. Spliting the problem into 2 parts...1. even if i hardcode everything which i tried doing , even then script doesnt run(some part of it). 2. how do i make it use args from client user
@JoeWatkins I dont know, 1. i tried asking you whats wrong if I parse the string and put checks on it, 2. I told that only authorised login has access to it. 3. I asked then whats the other way to do this securely. 4. I was told to modify my question, which i did then only. 5. Still I'm asking if thereis any way torun a shell script (lets forget its arguments for now)
 
6:23 PM
0
Q: If column1 is user then insert there otherwise insert in column 2

user4244510I want to make it so that if $_SESSION["user"] exists in App.Person1 then set that to null otherwise set App.Person2 to null. Here is my current query to unassign: update App set App.Person1 = NULL where App.Person1 = '" . addslashes(strip_tags($_SESSION["user"])) . "' and App.ID = '" . addslas...

 
7:37 PM
Does anyone know why ArrayObject doesn't have a usort method, only uasort?
 
user895378
Anyone have a domain name registrar preference? Going AFK. Just ping me if so.
 
@rdlowrey name.com
 
7:51 PM
@rdlowrey namecheap
 
aaaargh why do I use reddit
WHY
 
8:04 PM
because you hate yourself?
 
MAYBE
 
ello
 
8:27 PM
hey @AndreaFaulds do you have some insider knowledge on why there isn't a usort method on ArrayObject, only uasort ?
 
Because ArrayObject is an amalgamous nightmare of an array-object hybrid.
 
I quickly glanced at the src, and it looks like it wouldn't be so hard to implement? Having never done anything with the PHP src though, I'm probably missing something. I assumed there must be a reason it wan't added :D
 
@AndreaFaulds From a user-land perspective this has been the case since at least version 5, maybe even older than that.
 
@LeviMorrison Oh, I know that
I just don't think they should be considered the same for return type purposes
 
0
Q: .htaccess exception for subdomain not working

Lucas BI want to redirect the root of my website to a subfolder using .htaccess Should be: mysite.com -> Redirects to mysite.com/2015 mysite.com/something -> No Redirect sub.mysite.com -> No Redirect What currently happens is that sub.mysite.com is being redirected as well to mysite.com/2015. This i...

 
8:35 PM
@AydinHassan Because uasort is strictly more powerful?
 
Hi! Thanks to everyone who made it possible for me to speak here :-)
 
@nikic I guess so. but as the keys do not get altered, when comparing array's in a unit test after a uasort, I have to call array_values($arrObj->getArrayCopy()) in order to test order equality, and then I began to wonder why usort wasn't implemented, just curious
 
Hey @SebastianBergmann :)
 
@SebastianBergmann :-)
 
@SebastianBergmann Welcome! :-)
 
8:43 PM
@AydinHassan I'd guess it is because there are already 6 sorting methods in that class and adding another set that doesn't preserve keys (for at least asort, uasort, natsort, natcasesort) would be serious overkill ^^
I'd rather say that what is missing there is the equivalent of array_values. So that $arr->usort() would be the same as $arr->uasort()->values()
 
@NikiC makes sense, thanks for your insight :)
 
COuld somebody tell me what this means:
> By default, this function will block until the requested lock is acquired; this may be controlled (on non-Windows platforms) with the LOCK_NB option documented below.
LOCK_NB does actually work on windows
Is this a doc error or a PeeHaa error?
 
@PeeHaa doc error, works for me too
 
user895378
Define "works for me"
 
Is in it doesn't wait for the lock to be released
 
8:52 PM
@rdlowrey flock returns true, I'll check if the file is actually locked, wait a sec
 
user895378
Hold on, I'll test in windows and see if it works.
 
yeah file is locked
 
I have the feeling I am misreading what is being said on that man page tbh
 
@PeeHaa I think the "(not supported on Windows)" part doesn't mean it won't lock, it just doesn't block (block what?) while locking
 
@MarcelBurkhard The blocked part means it will wait till the lock is released
 
8:56 PM
@PeeHaa so you flock the file, and once its not locked anymore the script continues? Sounds weird
 
Not really that weird for most situations
 
aaaaaaawwwww :(
> /* bug for bug compatible with Unix */
:)
 

« first day (1569 days earlier)      last day (3382 days later) »