« first day (642 days earlier)      last day (4303 days later) » 

7:00 PM
You can't get to private/protected variables that way, I believ.
It was a poor choice for whoever implemented anonymous functions to not inherit the current scope.
 
are namespaces supposed to mimic your directory setup?
 
@Event_Horizon good lord does this guy love name droping
 
@Event_Horizon Most people do it that way.
 
user895378
@LeviMorrison No matter, I just moved my nifty array_map with closure operating on a private object method into a crappy foreach loop to fix it. Pushed -- should fix your issue.
 
Well, lots of tests failed/skipped.
But I did actually run a lot more tests.
A LOT more.
 
user895378
7:02 PM
@LeviMorrison All righty, keep hitting me with error messages as you're able to
 
I can work on some of these.
As a side note, you are losing the callable type-hint.
That's a good PHP 5.4 feature.
 
user895378
ohhhhh yeah
 
user895378
I definitely have that in places. I'll fix those now.
 
Why are you guys developing for 5.3+ over 5.4+?
 
i develope for 4.3 because im cool like that
 
7:05 PM
@Event_Horizon So I can actually use it right now.
 
user895378
5.3 is very ubiquitous and will continue to be so for a long time
 
Adoption of 5.4 will take a loooooooooooooong time
 
user895378
Yeah it really will
 
Escpecially with hosting companies in the picture
 
@PeeHaa I'm actually hoping when people 'adopt' a new PHP version it's higher than 5.4
 
7:06 PM
@LeviMorrison One can dream ;)
 
PHP 5.4 is nice, but it certainly isn't MUST UPGRADE>
I'm hoping 5.5 will bring even more changes (they don't have to be BIG changes, just good ones) and then people will have enough reason to upgrade.
 
nope
@LeviMorrison People may want to upgrade, but most people cannot (hosting companies). And they only think about the extra work for them
 
@PeeHaa That's what I'm saying. I'm hoping 5.5 will provide ENOUGH reason over 5.3 to go through the effort.
For instance, if all PHP 5.5 had over 5.3 was 5.4 features, list comprehensions/generators, slightly improved performance and fixed a lot more bugs, I would say it's worth it.
 
@LeviMorrison Well I'm hoping too, but considering the fact some people are still stuck with 5.2 I am afraid not in the near future
 
I routinely go through the effort of emailing my hosting provider asking for something above 5.3.1, but no luck yet :[
 
7:10 PM
@orourkek That's the reason I always had run my own server and now I'm on a VPS
 
But when 5.2 is THREE updates behind the master, people will start complaining, on the condition that those three releases provide useful improvements.
 
@PeeHaa I do enough sysadmin-y things at work, and I don't enjoy it enough to do it more at home :P
 
@orourkek Once it it setup it keeps running without much effort
 
true enough. Maybe one day I'll migrate all my stuff, but for now I'm happy enough with everything (even php 5.3.1)
 
:)
 
7:15 PM
Hey guys
 
@Truth jo
 
user895378
@LeviMorrison I think I've killed off any callable typehints now.
 
user895378
Once I got over the loss of the short array syntax, targeting 5.3 instead of 5.4 wasn't a big deal.
 
@rdlowrey There are a lot of array_combine complaints.
I'm going to push some stuff.
 
user895378
aha:
 
user895378
7:18 PM
> 5.4.0 Previous versions issued E_WARNING and returned FALSE for empty arrays.
 
user895378
Will fix that
 
@rdlowrey Losing traits wasn't a pain?
 
user895378
@MikeB I used traits just long enough to realize I never wanted to use traits.
 
@webarto
 
orly? How come?
 
7:19 PM
???????
 
user895378
I have yet to see a trait usage that isn't better accomplished by object composition or design improvement.
3
 
Too tan for traits!
Hi, by the way
 
@rdlowrey Wow. You actually used it
 
user895378
@GordonM Oh, I saw and bookmarked something that will hep you!
 
why does google think "date" is a synonym for "data" ??
 
7:20 PM
@rdlowrey Completely agree.
 
@rdlowrey I just filed the introduction of traits in the same bin as goto
 
I expect that there's a use for traits that I've not considered, but I can't think what it is. It feels more like a feature the dev team added because they were getting mocked about PHP not having mixins.
I don't get what's so bad about not having mixins.
@rdlowrey Really? Cool!
 
@GordonM Most of the 'uses' for traits seem to be poorly designed code.
 
user895378
@GordonM It definitely helped me. Instead of adding a method to your class just so you can mock the sending of headers, there are better options provided by phpunit.
 
user895378
3
Q: Test PHP headers with PHPunit

titelI'm trying to use PHPunit to test a class that outputs some custom headers. The problem is that on my machine this: <?php class HeadersTest extends PHPUnit_Framework_TestCase { public function testHeaders() { ob_start(); header('Location: foo'); $headers_li...

 
7:22 PM
I'm sure there are some valid code reuse things.
 
click
 
Also, I've thought about data-structures being implemented via traits.
 
OK, that's getting an upvote.
 
user895378
In particular, the @runInSeparateProcess annotation is $$$ for a few small, specific test cases.
 
For instance, saying ClassMembers IS a List<ClassStudent> doesn't make sense. It simply behaves like one.
 
user895378
7:23 PM
@LeviMorrison sounds valid
 
I'm not sure how it works out in practice.
Theoretically it sounds good.
 
Interesting post. Will definitely have to remember that. (I did think i tried the separate process thing though). Of course I've already rewritten my Session class to require an injected object that actually binds the session to the object, so... bit late. :) But thanks anyway.
@LeviMorrison If PHP had a richer collection of .... collections, it wouldn't be an issue, of course. :)
 
@GordonM It's something I'm keeping in mind for my PHP data-structures repository.
@rdlowrey I pushed a small change and it appears that all the remaining errors are because of array_combine.
Fix those up and I'll re-run.
 
user895378
@LeviMorrison in the process of
 
user895378
@LeviMorrison Pushed. All passing on my end.
 
7:30 PM
>OK, but incomplete or skipped tests! Tests: 409, Assertions: 601, Skipped: 12
 
user895378
woot. The Encoding package isn't used by any other packages, so those skipped tests aren't terribly important. I'm working on a mod_deflate style auto response encoding plugin to work alongside content-negotiation, but that's all it's used for at the moment.
 
Yeah, that run in separate process thing might not be the soluction. Runtime error: ?????????????????????????????????????????????????????????????? in (path to file under test).
Nice error message :)
 
@rdlowrey Also, it may be worth looking into removing the dependency for encodings.
 
user895378
@LeviMorrison How else can you use content-negotiation?
 
@rdlowrey I'm not sure what you mean?
 
user895378
7:34 PM
you need the gz functions to encode/decode gzip data
 
@rdlowrey Oh, that one case needs the functions.
 
user895378
Part of content negotiation is the Accept-Encoding header. In it, clients can say "I can decode responses if you send them to me in gzip/deflate/etc"
 
user895378
It's extremely valuable to decrease the bandwidth and time used to send messages back and forth and almost nobody uses it.
 
@rdlowrey But can the dependency of the extension be removed?
 
user895378
I'm trying to make it so easy that you'd be stupid not to use it.
 
user895378
7:36 PM
Well, I don't personally know how to go about writing custom functions to encode and decode gzip and deflate data
 
Let's be honest: the fewer extensions one needs greatly increases usability and adoption.
 
user895378
And that's an uber-standard module.
 
user895378
It comes pre-packaged with WINDOWS php
 
Well, that's fine.
 
I got mad at javascript.
gist: Javascript F U, 2012-07-19 19:36:21Z
    function FF() { return "F"; };                     function UU(){                 return "U";};
    var i,F,f=FF();                                    j=0,U=[],u=UU(),               i = 0,F=[],
    F[i++]=f,                                            U[j++]=u,                     U[j++]=u,
    F[i++]=f,                                            U[j++]=u,                     U[j++]=u,
    F[i++]=f,                                            U[j++]=u,                     U[j++]=u,
    F[i++]=f,                                            U[j++]=u,                     U[j++]=u,
    F[i++]=f,                                            U[j++]=u,                     U[j++]=u,
    F[i++]=f,                                            U[j++]=u,                     U[j++]=u,
    F[i++]=f,                                            U[j++]=u,                     U[j++]=u,
    D = function(a,b){return a+b},                       U[j++]=u,                     U[j++]=u,
    F[i++]=f,                                            U[j++]=u,                     U[j++]=u,
    F[i++]=f,                                            U[j++]=u,                     U[j++]=u,
    F[i++]=f,                                            U[j++]=u,                     U[j++]=u,
    F[i++]=f,                                            U[j++]=u,                     U[j++]=u,
    F[i++]=f,                                            U[j++]=u,                     U[j++]=u,
    F[i++]=f,                                            U[j++]=u,                     U[j++]=u,
    F[i++]=f,                                            console.log(D(F.join(''),U.join('')));​
 
7:37 PM
I'm not saying it needs to be removed.
 
user895378
You actually don't even have to have it, you just can't use the auto-response encoding plugin if you don't
 
Can someone do a cv request in sandbox pls: chat.stackoverflow.com/rooms/1/sandbox
 
user895378
The relevant functions won't ever be called if you don't enable auto-response encoding
 
user895378
I'm pretty sure it only breaks the tests for you because php analyzes those lines for code coverage.
 
user895378
But if you were running an actual app off of the repo files you wouldn't have any issues
 
7:40 PM
@PeeHaa Tested
 
tnx
 
user895378
@LeviMorrison It's a good point though. When I setup the config parsing I'll make sure to throw a ConfigException if the requisite functions aren't available and the plugin is enabled.
 
user895378
AND NOW FINALLY, I'm going to play with the new Http Client
 
lol
The tests aren't complete, btw.
Use at your own peril.
Also, function __construct($uri, $httpVersion, $method, array $headers, $body = '') is there a reason headers aren't optional?
Default to array $headers = array()?
Well, found an error somewhere.
@rdlowrey Is this $pattern = ',^([^\s:]+):[ \t]*(.+)$,'; correct? My regex-fu is rusty.
 
user895378
@LeviMorrison I tested the crap out of it
 
7:47 PM
Okay. I'll have to pull out my debugger then.
 
user895378
@LeviMorrison check out the relevant test method and add some test cases and try to break it
 
user895378
@LeviMorrison I guess a request with no headers is perfectly valid. I hadn't considered a scenario where you wouldn't send headers but that makes sense.
 
Hmm.
I found the problem.
It gave a start-line. I need to learn more about the stream wrappers, I guess.
 
user895378
Will add a optional default empty header array
 
@rdlowrey So, here's the situation.
With an http stream wrapper, the headers we are given include the trace. So if you redirect a few times, it gives headers for each one, all in the SAME array structure.
That was a bad choice on their part, but we can't change it.
The question is: do we provide the user the trace?
It seems like we should, but then we have to figure out the best way to do it.
 
user895378
7:53 PM
So it's like several HTTP messages combined into one with each TRACE request included? I'm not terribly familiar with what happens using the TRACE verb.
 
Well, trace was a poor word choice.
I mean, I get the headers for each response.
 
user895378
oh okay
 
Do we send them back to the user, and if so, how?
 
If we don't, I still have to parse them and throw them away.
 
user895378
7:55 PM
@LeviMorrison What about providing an extra method -- one for the raw response and one that parses out any extraneous redirect stuff?
 
@rdlowrey Set a break-point in buildResponseFromStream after getting meta-data and send a GET to http://example.com/
 
user895378
Well, I don't know that something like that belongs in StdResponse
 
You can actually see what I'm talking about.
 
-9
Q: Why does php have so many time zones?

CitizenPhp 5.2 has a huge list of time zones available. To me, this seems excessive, but there must be a good reason for it. Why is that?

 
user895378
k
 
7:56 PM
 
user895378
@MikeB lol
 
user895378
That may be the single worst question of all time on SO.
 
At first I thought "Maybe he's from a country where time-zone's are called something else.. or taught in a different way.. or ignored all together?" But nope.. he's from US
 
@MikeB Well people from the US tend to think that's the entire world :)
 
@rdlowrey There surely has to have been a worse one...
There's no way that can be the absolute limit of retardedness.
 
user895378
7:59 PM
@GordonM yeah, I may have overreacted but the raw stupidity of the question punched me in the face ...
 
@rdlowrey It was so bad I think it gave me cancer </calculon>
 
How does someone with 750+ rep ask such a dumb question
 
> As further clarification, php has two time zones in Kentucky. Why locations instead of just a few like EST, PST, CST for US instead of tens of time zones?
:(
 
user895378
Somebody please deport that person.
 
8:01 PM
@MikeB . . . Then what about Arizona?
 
There's a ton of intricacies with timezones that deserve good question.. I think he just phrased his question extremely poorly
1719
A: Why is subtracting these two times (in 1927) giving a strange result?

Jon SkeetIt's a time zone change on December 31st in Shanghai. See this page for details of 1927 in Shanghai. Basically at midnight at the end of 1927, the clocks went back 5 minutes and 52 seconds. So "1927-12-31 23:54:08" actually happened twice, and it looks like Java is parsing it as the later possib...

 
You know, I think most PHP newbies who discover Stack Overflow probably react like this:
 
Or, hey, stupid questions are allowed, let me ask one!
 
(too lazy to look it up in the faq/meta). What happens if that question gets deleted. Does the reputation get added back to OP and subtracted from the answer(s)?
or just the answers
 
@rdlowrey So, have any thoughts on the header situation?
 
user895378
8:08 PM
@LeviMorrison just a sec, about to pull it up
 
my recommendation today: garlic, salvia, plaice and rice.
 
user895378
@LeviMorrison I'm setting up some test endpoints on localhost for controlled data
 
Hi @MikeB, you better understand passing by reference now?
 
@hakre Yeah, your answer, @ircmaxell's answer, and @tereško's video youtube.com/watch?v=bxxIXPc9IR8 helped a lot - Thanks
 
8:12 PM
@MikeB Yeah, watched the whole video plus some other ones from that conference. The video quality is quite OK and most of these talks have PDFs you can view next to the video.
 
Ah, pdf's would have helped - understanding the zval stuff is pretty important
However, I was definitely one of those people who always said "PHP passes objects by reference since 5.x"
 
@NikiC Please re-open. I mean the question is not that bad.
If it attracts too much stupid answers, I'll place some bounty on it.
 
@hakre No, sorry, but I think it can't be saved anymore
If you want to have an answer post a new, proper question
In it's current form it doesn't make sense
 
@MikeB Which is not true ;) Yeah, I mean Johannes Schlueters has a nice blog post on that topic, too: schlueters.de/blog/archives/125-Do-not-use-PHP-references.html
This is an earlier collection of mine: hakre.wordpress.com/2010/02/18/references-to-the-max - but please don't get blown away :)
@NikiC Ah it's not all black and white. I sometimes wish with some questions things would be more relaxed, however, by the sheer amount what comes in nowadays, I can understand that things get voted quickly.
 
@hakre I certainly agree that the question by itself is interesting, but the current form wouldn't yield any interesting answer
Also it has -15 votes...
 
user895378
8:19 PM
@LeviMorrison So I'm thinking the thing to do is probably to add a context option like strip_redirects, have it default to true and strip out everything up to the start of the final status line
 
user895378
Any thoughts on that?
 
@rdlowrey What if you want to see the responses?
 
user895378
And store the stripped redirects in a class property and add an accessor method.
 
Hm, my vim-fu is so bad
 
user895378
@LeviMorrison Then maybe take a StdResponseFactory in the constructor after all and create a list of responses that you can access.
 
8:21 PM
@NikiC Really? I thought yours would be top-notch.
 
user895378
Or not with the factory since the response is already newable in the first place
 
@rdlowrey I was wondering if returning a ResponseChain might be appropriate?
 
@LeviMorrison I use vim a lot, but I think I'm using nearly none of it's power
 
@NikiC Chaining commands sometimes gets me in trouble.
Luckily, the undo function is good.
 
user895378
@LeviMorrison Would that hamper the abstraction possibilities?
 
8:22 PM
@NikiC yah right, the question is not really well made. even I have no clue what the PHP 5.2 list of timezones actually is. Does it differ from PHP 5.3 or 5.4 even?
 
I'm not sure.
 
Isn't that olson db based?
 
@hakre It differs by having an old olson db :D
 
user895378
@LeviMorrison Well, you could always revert to a strict response type and inject a factory and create a ResponseChain<Response>
 
Also, there is no way I know of to get the bodies of those requests.
302 may include content, right?
 
user895378
8:26 PM
scanning the spec right now ...
 
Seems to not even mention it.
 
@NikiC lol. But yeah technically this is not PHP core even.
 
user895378
@LeviMorrison yeah that's what I thought too, but I see this in section 7 which makes me think it might be mentioned specifically somewhere:
 
@LeviMorrison It not only may but it's advised that to do.
 
user895378
> Request and Response messages MAY transfer an entity if not otherwise restricted by the request method or response status code
 
user895378
8:28 PM
(emphasis added)
 
@rdlowrey But do 300 level codes restrict it?
 
user895378
so there must be somewhere that specifies status codes that should not carry entity bodies
 
@hakre So can we get that question delvd? I don't like leaving +15 fun answers behind
 
@NikiC Okay, let's play police at late night.
Gone.
 
iiieie :)=
 
user895378
8:30 PM
@LeviMorrison I don't see how 300 codes could carry entity bodies because they all deal with redirection, but I could be wrong
 
@rdlowrey That is because often there is some human reading response bodies.
 
user895378
> This class of status code indicates that further action needs to be taken by the user agent in order to fulfil the request
 
It's per RFC that HTTP client must not do automatic redirects.
Today, those automatic redirects are that populuar that NGINX has a bug since years nobody seems to notice (or NGINX developers are just to lazy to fix) with their default response body on 3xx codes.
 
@rdlowrey I wonder if a class ClientResponse that holds a Response and ResponseHeaders (for the others) would be appropriate.
 
user895378
So can we point to a specific place in the spec where it says that 300 response codes are not explicitly prohibited from carrying entity bodies?
 
8:32 PM
Yes I can, you need that?
(it's in HTTP 1.0 and HTTP 1.1)
 
user895378
@hakre I'm not questioning you, I just like to find things in the spec when possible :)
 
Sure, I'm with you, just asking, let me fetch the link
 
user895378
@LeviMorrison Why bother with an extra response headers object when a Response already contains headers?
 
@rdlowrey If somebody specifies a Content-length we can't provide them WITH that content.
It's not possible.
 
RFC 2616 10.3 Redirection 3xx: "The action required MAY be carried out by the user agent without interaction with the user if and only if the method used in the second request is GET or HEAD." (automatic redirection)
 
8:34 PM
We could give a Response object and tell them that currently there will never be a body for the previous headers.
Or, alternatively, we could do the redirects ourselves.
 
And further on, more specific with 302: "The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s)."
 
user895378
@hakre I still don't see anything about the entity-body in those quotes ...
 
user895378
@LeviMorrison So is the problem that the stream wrapper won't give us the content of the entity body for any response prior to the final redirect?
 
@rdlowrey 'Hypertext note' means there must be a body . . .
@rdlowrey Correct.
 
user895378
oh well there you go.
 
8:36 PM
@rdlowrey "a short hypertext note" - that is a response body.
 
user895378
Thanks guys :)
 
np
 
Doing the redirects ourselves may not that bad.
 
user895378
@LeviMorrison Have you tested against a resource that returns a "short hypertext note" with the 3xx response? Because I can set one up real quick to try if example.com doesnt.
 
fun fact: Symfony2 was one of the first PHP frameworks (even applications) that reflects that properly.
 
8:38 PM
@rdlowrey Good point. Go ahead and set up a test, but I think I know somewhere that does give a body.
I think our local cs department does.
 
fun fact 2: For your wordpress blog, I suggest my better http redirects plugin: hakre.wordpress.com/plugins/better-http-redirects
 
user895378
lol @hakre you're just full of fun and helpful information today
 
user895378
@LeviMorrison btw, the setRawHeader was a really good idea. Just used it :)
 
@hakre reflects or redirects?
 
@hakre By the way, when I'm finished I think my http stream skills will be superior to yours.
This pales in comparison.
 
user895378
8:46 PM
@LeviMorrison Okay, so here are my results when I test locally using the client:
 
@rdlowrey I think I can get the data through the notification parameter.
It's not well documented.
 
user895378
well, when I return this:
 
user895378
        $this->response->setStatusCode(302);
        $this->response->setStatusDescription('Found');
        $this->response->setRawHeader('Content-Length: '.strlen($body));
        $this->response->setRawHeader('Date: Thu, 19 Jul 2012 20:15:59 GMT');
        $this->response->setRawHeader('Location: localhost:8096');
        $this->response->setBody($body);
        $this->response->send();
 
user895378
^ localhost:8096/test
 
user895378
My meta output using the client is:
 
user895378
8:47 PM
array(10) {
  'wrapper_data' =>
  array(5) {
    [0] =>
    string(15) "HTTP/1.1 200 OK"
    [1] =>
    string(20) "Host: localhost:8096"
    [2] =>
    string(17) "Connection: close"
    [3] =>
    string(23) "X-Powered-By: PHP/5.4.4"
    [4] =>
    string(23) "Content-type: text/html"
  }
  'wrapper_type' =>
  string(4) "http"
  'stream_type' =>
  string(14) "tcp_socket/ssl"
  'mode' =>
  string(2) "rb"
  'unread_bytes' =>
  int(0)
  'seekable' =>
  bool(false)
  'uri' =>
  string(22) "http://localhost:8096/"
 
user895378
It doesn't even mention that the redirect happened.
 
You HTTP people are crazy
 
@rdlowrey Very odd.
 
user895378
It may be the nature of the built-in 5.4 web server though ...
 
@LeviMorrison Well, spread the word. It's a feature that is often not well visible with PHP users, a very powerful one, not only for HTTP.
 
8:52 PM
sigh
 
@rdlowrey Does this work: $this->response->setRawHeader('302 Found');?
 
user895378
@hakre no. But $this->response->setStartLine('HTTP/1.1 302 Found') does
 
@hakre No.
 
I'd say a good HTTP server should have the standard HTTP status reason phrase at hand w/o the need to add it. Probably with the handy function to replace it.
 
@ircmaxell :)
 
8:55 PM
I just spent 2 hours building a finite-state javascript lexer, parser and executor...
to "run" a string...
 
and then?
 
user895378
@hakre status defaults to 200 unless Response::setStatusCode changes it
 
user895378
or setStartLine
 
@ircmaxell uhm?
 
@rdlowrey Implement a strict mode that should first of all return an internal server error because no status has been defined (or something like gone :))
 
8:56 PM
@hakre The reason phrase is not required to be the one defined by the RFC>
 
you mean, you build a js vm in two hours?
 
You can set it to be whatever you want.
 
@LeviMorrison It is not, but it's just friendly to take that one from the RFC in case the programmer is too lazy to provide one.
I mean the library consuming programmer, not the programmer who writes the library.
 
@hakre I guess that could be helpful..
 
user895378
@hakre Yeah, I think it's not a good idea to offer the defaults if none are set
 
user895378
8:58 PM
accidental "not" :)
 
@ircmaxell Sounds like implementing regular expressions.
 
@rdlowrey Set max redirects to 0 and fire it at a page that will redirect.
 
user895378
@LeviMorrison k
 

« first day (642 days earlier)      last day (4303 days later) »