« first day (432 days earlier)      last day (4516 days later) » 

12:00 AM
hi there ;)
@LeviMorrison: Was very tired the other day, first of thanks for all the feedback about data structures. I think there's a lot which SPL can benefit from, I see a point in making the SPL interfaces more granular. Would be cool to have that with SPL right away ;).
 
Tek
@ircmaxell sorry I had to attend a call. Still around?
 
@LeviMorrison I'm pretty sure there's no-one to particular blame for for that. But Marcus actually did a great job (today it looks like he could foresee the future), but I think his work was pretty isolated. At least that's a feeling I had earlier.
 
@hakre He did well in certain areas, certainly.
 
Absolutely. Even I'm personally not confident with the data structures, I'm very confident with the general design. I think it's important to be respectful in the right sense here.
Which includes that if we give feedback, that the type of feedback is appropriate and well-thought.
This includes the interfaces as well as the (C) implementation. But first the interfaces ;)
Anyway, I learned from you the differences between queue and dequeue.
I think it's a good idea to have those both structures.
Better say types of lists.
About the iterators, I think I raised a valid point.
I would say we commonly use list as stacks when we iterate.
I know that the current SPL has problems to deal with that.
I don't know the reason.
But because of something, the type of list processing (FIFO, LIFO) can not be precisely set-up with SplStack / Queue.
This was an actual problem I ran over.
I could work-around it, but I think the default structures should support it right away.
Otherwise, well, it's implementation details. But for basic (list) structures, it would be nice to have them useable for standard cases.
 
12:18 AM
@hakre Agreed.
 
12:31 AM
@Tek Back now
@NikiC Actually, I think it may be the easiest part. Since some things that we're trying to do is actually easy in C, but not in PHP (like pointer operations)
 
Tek
@ircmaxell Awesome! All right won't take up a lot of your time so quick question. I had an unexpected last minute interview from a friend that recommended me to a certain company.

Anyway, I've never worked for a company and I've always done PHP for small jobs and for fun. Turns out a lot of their work is pretty much what I do for my projects. (Data scraping, database sorting and presentation of data.) They asked me what I would like to earn... and I have no idea. The interview went great, I just don't have any idea what I should be earning for that type of work.
 
that's up to you
and your area.
it's too location dependent
 
Tek
I understand that, I guess what I'm saying is what's too little?
 
that's hard to answer
I am not good at that side
 
Tek
Ah, unfortunate. But I understand.
I was hoping I could receive some guidance. I don't want to be underpaid since it's not exactly a bagging job... lol
 
12:39 AM
yeah. But the first job is key for more than money. It opens tons of doors. So don't worry too much about pay...
 
@Tek ask for what would allow you to live a little bit above comfortable.
then you have room to wiggle down to comfortable
 
I ask for 25% more than I want
and use that to negotiate down
 
Tek
@ircmaxell Understandable. That helps.
@KevinPeno That's incredibly vague, but I get you lol.
 
@Tek basically what @ircmaxell said, but without numbers
 
:-D
 
Tek
12:45 AM
Well, thank you guys. That gives me confidence to ask for what I want
 
@ircmaxell if searching an array for a value, and I cannot find it, what SPL exception would you expect?
 
I wouldn't expect an exception, because it's not an exceptional condition
 
Tek
@KevinPeno You should read @ircmaxell's blog. He explains the differences between application errors and exceptions very well :D
 
why not? and what would you expect?
 
find() or search() implies that Not found is an acceptable state. In which case, I'd expect a return value indicating that. Exceptions are used when either you can't continue because you encountered something out of the ordinary (such as an error, or invalid state of some sort), or something is wrong in general. Neither of those two are applicable in that case...
@Tek: I wouldn't consider it an error either. It's a valid state of the method...
 
12:51 AM
@Tek I don't see it as an error.
meh
Ok, let me restate, because it isn't really a search/find (cause I would agree with you)
 
Tek
@ircmaxell I was just mentioning the different states you talked about.
 
:-D
 
@NikiC: What you'd like to earn is normally the sum of your rent or fraction to pay for the living plus the food plus the leisure multiplied by a factor you like.
 
@KevinPeno Well, then that may change somethings
:-D
 
Say I'm looking for the index of the specified value. Do you still consider that a search?
different than "contains"
 
12:54 AM
so you mean like $obj->getIndex($id)?
 
yeah
closest PHP function i can find is array_search. Find the indexOf the value, but I'm unsure about the falsy return on fail
 
part of me says yes, it's valid, just return null. Other parts of me say that it's really an invalid offset and should be an OutOfBoundsException...
but I'm not sure...
 
That's what I was fighting
 
@KevinPeno well, it would be ArrayObject::offsetGet
 
@ircmaxell Are you saying it's similar with the opposite argument (value vs. index)?
 
12:57 AM
Gordon really did something with putting the exact type of exception on the agenda. Or was it NikiC?
 
Oh, you want getByValue($value)?
oddd
@hakre Nikic IIRC
 
@ircmaxell basically getIndexByValue
 
::indexOf($value)
 
right
but should it exception if there is no value in the collection
 
@KevinPeno Ahhhhhhhhh
hrm. I think I would not throw an exception in that case
 
1:01 AM
Exception or Special Case.
Decide for yourself
 
I wouldn't. JS's implementation returns an invalid index (-1) if not found...
 
E.g. you can return NULL if there is no such index - or throw an Exception.
 
@hakre Assuming exception, what exception would you throw (per SPL)
 
NULL normally needs an if and Exception a try in PHP.
 
@KevinPeno UnexpectedValueException is what you want.
 
1:02 AM
I would first of all throw an Exception in PHP.
 
That's what SplObjectStorage uses when you 'get' something that doesn't exist.
I don't fully understand the exception, but that is the use-case.
 
According to the SPL, the next thing I'll throw is a RuntimeException (you can not do much wrong with that one in PHP).
 
I wouldn't throw an exception in that case personally... But whatever
 
The next thing I would do (contrary) is to throw an InvalidArgumentException.
 
@hakre Please no. The argument was valid, it just didn't exist in the set. So perhaps DomainException if not UnexpectedValue...
 
1:04 AM
@LeviMorrison I don't see a method on SPLObjectStorage that gets via value of the index
 
@KevinPeno Honestly, I'm with ircmaxell. I'd return -1. If they index it, it will throw OutOfBoundsException or error or something..
 
@ircmaxell That one I won't throw, because the method is delegating something of the callee, not the other way round.
 
I think the right way would be to return NULL, because there is no index.
 
@ircmaxell Yes, but the offset is the key, not by value
 
1:05 AM
@hakre just pasting to the docs of what you said originally
eih
ok dinner
 
if (NULL === $result = $obj->indexOf($value))
{
    # no such value exists
}
 
@hakre I don't like mixing types, myself. If it returns an int, NULL isn't valid.
 
@LeviMorrison I agree.
 
sure that would be subject to discussion, but with PHP it is not easy to formulate a domain language so the syntax should tell it in your code.
@LeviMorrison C-style, NULL is 0, never use (int) 0 for any ID and you're fine.
 
@KevinPeno To keep inline with normal PHP behavior, you should return false. Then if you ever check true/false, be sure to use ===. However, I'd return -1.
 
1:07 AM
@LeviMorrison I thought of that, but it is no different from using null as above imo
in PHP anyway
 
need to underline levi here, standard (non OOP) behavior of PHP functions and extension functions is to return FALSE on error.
if you take NULL === FALSE === 0 ideally and you never choose 0 as a perfect valid return value (e.g. as an index), you're mostly save.
I prefer that route to not define anything with (int) 0.
That's working pretty flexible in PHP.
 
@KevinPeno I'd say false is better than null. Barely.
 
So let indexes start with 1 not 0.
 
@LeviMorrison Sure. I'd agree. And I think false is better than -1.
 
@KevinPeno I think -1 is better than false in this instance.
 
1:10 AM
-1 = TRUE and never 0, so it's most often suggesting something valid has been returned.
-1 is also a sign that someone only visible to signed numbers was able to form a Special Case, which is a waste of negative numbers.
 
@KevinPeno What exactly is this all for, again?
 
Historically, 0 is actually a special case.
As in math, you can't divide by 0 for example.
 
@hakre In PHP, all numbers are signed.
 
@LeviMorrison Just striking coversation and dicking around
 
But you can with any other number.
@LeviMorrison Not really.
 
1:13 AM
@hakre Really. They are. Have you looked under the hood?
 
@LeviMorrison Check INF.
(sorry for bitching around, that's my nature when I'm drunk)
 
I was referring to float, not int.
floats are part of numbers, aren't they in PHP?
 
To my knowledge, floats are also signed.
 
Right, could be as you write it.
Is there -INF in PHP?
How to prove that?
I mean, is there some simple code to trigger it?
There was some short code to trigger INF in a phpunit issue.
Let me check
 
1:18 AM
I'm not sure what you mean. But floats are stored as C type double.
Anyway, I need to go home. I'm making dinner tonight and it's getting late. My wife is hungry, no doubt.
Later!
 
@hakre Except when doing 0 based counting, which is used in the vast majority of language implementations
 
When writing unit test with PHPUnit, is it possible to return a value from one unit test so you can use it as a parameter in another unit test? That would be really handy when chaining test together.
 
@JohnConde That's the sign that you're setting up your tests wrong.
good tests should be 100% independent....
 
I'm testing a payment system. You can do prior authorization on credit cards and then capture funds on those authorizations later. I can set up the tests so when testing the capture portion of the code i can get a fresh authorization but if I have a fresh authorization it would be easier to use it. but I can see why that would be bad in unit testing.
 
@JohnConde Don't do it that way. Because otherwise you can wind up in a situation that 2 tests fail because one piece of code breaks. Which is not good
I'd mock out the authorization code so that you're not actually hitting the network for those calls.
Then test the network component separately
watch that video
 
1:30 AM
@ircmaxell Actually in math it's, but well, in IT, is it really as well? Would like to see backed that up by a fact.
 
How would mock something like that? I'm trying to think how you could do that but can't come up with it.
 
@hakre look around. Find me a case of 1 indexed counting in a commonly used langauge
@JohnConde Watch the video, he explains that exact case in the video
 
@ircmaxell normally any index() routine expects one by definition in SDK's I've seen to far.
 
Then that's my new goal for the evening. Thanks again.
 
Also mostly any of the flags you have for masks and configuration are never 0.
 
1:32 AM
@hakre not that I've seen... But perhaps
 
So I would more tend to say it's common to not use 0 for something in IT.
 
@JohnConde Good luck!
@hakre Flags are different...
I'm talking anything where indexes are accessed directly. So not enums or bitflags
 
I can prove that but unless you can provide some facts (and FLAGS are actually indexes) it's hard to say what's common.
Unless proven wrong, I would suggest to not use the number 0 to signal that there is something.
Which is pretty much the same in math, you don't use 0 to actually count something.
 
look at all array implementations, and find one that's 1 indexed
 
C isn't that bad at that point honestly.
So what do you get if you access string t[0] of a zero length string in C?
It is very common in IT to make use of the value 0 to signal there is nothing (NULL).
Which is actually equivalent to FALSE (0) in many programming languages.
 
1:37 AM
Actually, that's undefined IIRC, since the array doesn't get any memory allocated to it, so the pointer itself is null
so trying to dereference it won't really work...
 
Whereas you talk about offsets, in which the offset of 0 makes actually sense of having no offset at all.
A string in C is always one byte.
(At least)
 
@hakre No it's not. There is no such thing in C. there is char (which is 1 byte), and char[n] which is 1 byte * n instances
so declaring char[0] foo; allocates no memory, but it does put the symbol into the table for reallocation if necessary
either way
 
I was talking about string, which is - you're right - at that point an implementation of an array of bytes and therefore a construct. See null-terminated string: en.wikipedia.org/wiki/Null-terminated_string
For your case char[0] is undefined, as C hardly can not map any non-existant offset to a non-existant base. It can be mem:://0 but I doubt C will map this.
Or does it?
 
Well, if you do char[] foo = "bar", 4 bytes will be allocated (1 for the null byte)
 
Leave the null byte aside, how can I access the first byte of the whole system?
In C.
 
1:46 AM
foo[0]
 
and foo is undefined?
 
Let's do this:
char foo[] = "bar";
printf(foo[0]); // "b" printed
 
so offset 0 to index 1, isn't it?
What if foo would be undefined, what would be the outcome?
naturally, the outcome would be undefined.
so you already have something before you add anything to it.
That's just the point I wanted to visualize.
Zero (or 0 or NULL or FALSE) always is a special case, a quite normal one in that point we deal with.
So returning -1 is a bad idea quite generally.
 
@hakre compiler error
@hakre eih, not generally. But I understand what you're saying. I wouldn't do it out of style, but it's not bad...
 
@ircmaxell There you have it, the compiler is even refusing to compile it.
The outcome is obviously undefined.
 
1:52 AM
If foo is undefined, it won't compile
 
If it does not compile it's undefined.
So the offset of 0 can't change the fact it's undefined.
 
I'm totally confused by what you're getting at
 
Just don't get me wrong, 0 is not bad (or useless), it's valuable as any other number.
Same is for NULL or FALSE.
Returning -1 on error to the opposite is a bad idea.
But wheter I throw an Excpetion or return NULL is actually pretty much the same in context of the compiler
Even PHP will throw me an exception if I return FALSE or NULL on failure
At least at the point I try to access something on FALSE or NULL.
 
FALSE->theMethod()` will give me a FATAL, as well as on NULL->theMethod().
You can throw one earlier, but in case you're unsure which one, just return FALSE or NULL and the code is pretty safe.
It only get's into question when you mix the commons on return types / throwing exceptions.
But even then, returning FALSE or NULL on error is pretty safe.
 
1:59 AM
yup
 
@ircmaxell I think it's actually a bad idea to look in MW for something that shares another language. I prefer the ISO notation (and I guess there are others good ones) what a flaw is and what an error is. Compare en.wikipedia.org/wiki/Software_bug
Regarding specific Exceptions: The topic has been raised the last days, and I think it's very much worth to discuss this in context of the SPL to get more clarification for the terms used, especially in PHP
However, part of that discussion is to negotiate about terms (which is a productive process) but the other part is to actually identify why the original implementation is missing some points (if it really is, isn't it?).
 
yeah
 
I'm not sure what aggraves me more. That an answer uses mysql_ for PHP code examples or that they label their jQuery code as "JavaScript"
 
lol
it is javascript
 
@CharlesSprayberry: I guess the mysql_point, but I guess some day will come those functions will become aliased into mysqli_. Not sure, but that day might come.
;)
 
2:10 AM
@ircmaxell It might be JavaScript but a call to a jQuery object method should not be labeled "JavaScript" code. It should be labeled "jQuery" code. JavaScript code implies that you can use it outside of the confines of jQuery.
 
That mysql thingy is actually blocking that most PHP user can use PDO which is very comfortable.
 
@CharlesSprayberry If I show you code that uses Zend Framework parts, would you not call it PHP code?
 
@CharlesSprayberry: You might miss that jQuery is just javascript in a general sense. I mean, it actually is a javascript library, nothing more (and nothing less).
It's just that you use a library because you think it's helpful.
jQuery is actually that js library that is probably the most popular one.
Like mysql_ is probably the PHP extension that is the most popular one, too.
 
I understand your arguments. I just don't agree with it. If I showed you the inner workings of a Zend framework class that required other Zend components to work I think it would be misleading to label this code as generic PHP without also mentioning that you kinda need this other stuff to work.
 
the backbone makes a PUT request and how would i get this on the server $_PUT , $_GET, $_POST , $_REQUEST all are empty ? and the $_SERVER shows the request is been made using PUT ?
 
2:14 AM
Look inside the jQuery code and try to understand javascript and you will actually say the same as you did for Zend Framework for jQuery.
 
some one plz throw light how to receive it
 
@Mian_Khurram_Ijaz where's the data passed?
$_PUT is non existant
 
how can i be sure with having a print_r but all are empty
 
use either HTTP_RAW_POST_DATA or file_get_contents('php://input');
 
how to confirm if data is actually getting passed
 
backbone makes a PUT request on model.save()
 
Is there something like $_PUT? Never heard of that. Should not be a PHP superglobal at least.
 
no there is not i just mis put it
 
@hakre no, there's not
 
So what is your actual problem (putting $_PUT aside)? You have problems to obtain the requests data?
 
2:17 AM
yes
the request does show in Chrome: model:{"id":556,"name":"xxx"}
 
have you tried php:://input ?
 
It should be there
 
sorry how do you try php:://input i do not understand this syntax where to put it?
 
Just seeing chrome, you're concerned about client-side or server-side?
 
on server-side
 
2:18 AM
okay
php://input is just a stream descriptor. It provides the RAW input to a PHP script.
 
save_data.php is on my server and backbone.js is making PUT request with the right data to it i can see the REQUEST going and comming back but i do not know how to pull the data sent at the server side
 
I would guess that PUT put's the data into the HTTP request body.
 
@ircmaxell the $HTTP_RAW_POST_DATA is also empty
 
If that's empty, have you checked for php://stdin?
With file_get_contents('php://stdin') ?
 
file_get_contents('php://stdin'); is empty too
 
2:28 AM
Are you actually sure that the client is sending a PUT request?
 
yeah the backbone.js is making a succefull request to the save_data.php on my server i can see the request been made with the right data,
the problem is backbone.js by default makes REST requests so if the data is new it makes PUT otherwise make a POST request
 
"the right data"???? How do you know?
 
right data to be sent to the server
under the Form Data tag in Chrome
i.e model:{"id":580,"name":"xxx"}
 
but not for the put requests?
 
w do u mean ?
 
2:31 AM
why doesn't that backbone.js always makes a put request?
(but that might not be your issue here)
 
when the data is for update it makes a POST reqeust otherwise PUT cuz it follows REST architecture
from the docs i am using Backbone.EmulateJson = true
 
REST would be to use PUT always.
But if I read you right, your problem is that with PUT you have problems to obtain the data on the server-side (inside PHP).
doesn't it?
 
yes exactly
found the solution
Backbone.emulateHTTP = true;
Backbone.emulateJSON = true;
 
@Mian_Khurram_Ijaz what about file_get_contents('php://input');?
 
and you will get the the json data in $_POST['model']
 
2:41 AM
HTTP_RAW_POST_DATA isn't always populated
 
Okay, that's an actual POST request then.
 
thanks guys i am done
happy Xmas
bye
 
You can access all POST entities pre-parsed in PHP within $_POST then.
Otherwise it's inside php://input (php://stdin).
But in your case you were more looking to find out which HTTP method was used.
Good you could find out finally by configuring the JS library.
$_POST in PHP is actually easy to use. Stick to that. Happy hanukkah.
 
@hakre stdin and input are very different
 
Just suggested that in case the OS configuration would made a different.
 
2:48 AM
I'm back :)
 
re
I need some help with an URL design.
 
@hakre Alright, go for it :)
 
Let's say you have a FILE you want to apply some XPATH expression to it.
How would you write it as an URL?
For example: FILE?xpath=XPATHEXPRESSION
or is that too much likely to a HTTP request?
 
example.com/file/FILE?xpath=urlencodedXPATHEXPRESSION could work, yes.
 
okay, let's say, you want something better. How would you write it?
(asking for feedback)
Let's say you're totally free with however URL looks like. But FILE needs to match Linux/Windows semantics.
 
2:54 AM
eih, too much to think about this late
 
@ircmaxell Just ping with @hakre later if you feel so.
 
:-D
 
@hakre What is this for, exactly? That could help
 

« first day (432 days earlier)      last day (4516 days later) »