« first day (263 days earlier)      last day (4675 days later) » 
00:00 - 16:0016:00 - 23:00

12:11 AM
@Gordon What a worthless talk
@stdio No, it will always be set (for a web request). You can do if (!empty($_POST)) or if ($_SERVER['REQUEST_METHOD'] == 'POST')
 
@ircmaxell thanks :)
 
np
 
12:31 AM
do you know how to send a jquery post request to a php script in the same page? Becouse I've problems
 
1:00 AM
Hi
 
hi
 
Cant you just use the ajax post method of jquery
 
?
 
Just the normal ajax method of jqeury
But then a post
 
I do something like ...$.post("",{data:data,data2:data2})....<?php...if(!empty($_POST)) do something...?>...but it doesn't work
 
1:09 AM
You can also try the $.ajax() method. And use 'post' as method. also try to check on a value. for example if($_post[submit])
 
the problem is it doesn't work
seems the request isn't sent
 
What part does not work
Ok
Do you encode/decode the json string properly in php
 
nothing regards json
just post request seems not be sent in the same page
 
And with the ajax functoon of jquery you can also have callback pptions like succes. they are only fired wjen the request was suvvessfulf
 
if I use 2 different files to jQuery code and php script, all work
 
1:19 AM
Sorry for the bad typing im on my mobile
 
np
it's simple saif...no success functions, ecc...
i've jquery code and php script code in the same page
a jquery post request with some data is sent to php script
it gets these data and does something...the problem is that post request seems not have succes
so, I don't know if it'is possible to have jquery and php code in the same page and they can communicate
becouse if I separate the codes (in 2 different files), it's ok
 
 
5 hours later…
6:35 AM
morning
 
Morning @teresko
I'm writing a function which returns an array of parent classes given a class (get_class_parents()), eg: get_class_parents('kfTextBox') => [stdclass,kfControl] (left is topmost).
Do you know what the best approach to do this is?
I suppose reflection vs regular PHP function.
Also, another question, I was thinking about caching results, since the class hierarchy can't be modified at runtime, do you see any flaws about this?
 
i just don't see the point in such information
 
6:50 AM
@teresko I didn't quite understand that. Are you questioning the usefulness of the function?
 
not usefulness per se , but the context in which you would want to use something like this
 
@teresko ok, sure.
 
i have this nagging feeling that it is a hack for a patch , which was made for a bugfix of some strange solution
 
Nope, once second and I'll explain.
 
sure
 
6:55 AM
You know the form builder, right? One of the "type editors" is a selectbox of existing controls in the designer.
The thing is I can specify "kfText" as a type.
The type editor shows a listbox of control instance of that type and subtypes, only.
Wait a sec.
facepalm
Hmm
ok, yeah. The editor iterates over each control instance and sees if it is of type kfText or has kfText in its class hierarchy when generating the selectbox.
(geez I managed to confuse myself)
Keep in mind, this is a selectbox of existing instances, not class names.
 
then you can use if ( $comeControll instanceof kfText ){}
it will look at whole hierarchy , not just the direct class name
 
@teresko It's in JS :(
And I'm not building a proper object hierarchy in JS.
 
this is PHP channel
 
No no, I meant, the instanceof part is done in JS.
But get_class_parent() is to fix the JS part from the PHP side.
@teresko My point is, I can't use instanceof in JS for technical reasons. So I'm providing the associated information (ie, the class hierarchy) to the JS from PHP via get_class_parents().
 
7:10 AM
can i ask about magento here??
 
@Jitendra - Sure. But can't guarantee an answer. :)
 
@Jitendra , you can , but you will get better result in freenode's channel for Magneto
 
Good morning @Gordon. I concur ^
 
@ChristianSciberras it really looks like you are taking the wrong approach here
 
@teresko What do you suggest?
 
7:23 AM
posted on July 06, 2011 by Stefan Koopmanschap

Yesterday there was a bit of discussion after uncon superstar Keith Casey mentioned he had been accepted to speak at an event, but the event required him to pay for his ticket. The discussion focussed on this specific event, but the topic is wider of course. And there are valid reasons for doing this, but you can also make mistakes with it.

 
right now i would suggest for you to create some example where members of this channel could look at the usecase
because, IMHO, your explanation was really really confusing
 
@teresko No can do, sorry. The example would be too complicated :(
 
7:39 AM
then it is one more sign for you to see that you are digging in wrong direction
 
As much as I'd love to peer review this thing, we're out of time.
I've been asking about different aspects throughout the whole project, and I'm extremely grateful to you guys giving expert advice.
 
morning
 
Hello @KamilTomšík :)
 
7:58 AM
@ChristianSciberras What version of PHP do you need to code to?
 
@Aether Don't know why you're asking, but I'm targeting 5.3+.
I'll figure out compatibility after its finished :D
 
Because for 5.3, you can use late static bindings to get your class parents.
 
@Aether I'm using get_class_parent() recursively, which is a slightly fixed alias of PHP's get_parent_class()
It seems to work so far.
 
Right, that's what I was thinking.
 
I was kind of curious as to @teresko's thoughts about it. So far, it doesn't seem to promise anything good ;)
 
8:02 AM
get_parent_class() only gives you the parent of the class it's used in.
I was thinking along the lines of this, which is probably similar to your code.

class A {
	static function getParentClasses() {
		$currentClass = get_called_class();
		$parentClass = get_parent_class($currentClass);

		if( $parentClass ) {
			$array = $parentClass::getParentClasses();
		} else {
			$array = array('stdClass');
		}

		$array[] = $currentClass;

		return $array;
	}
}
Then you don't need to define getParentClasses() in your subclasses.
 
Oh, mine is like a helper function, not a class method.
 
Of course, with a little extra knowledge of SPL, I could have just used class_parents.
 
why dont you use class_parents()?
@Aether ah.. you already mentioned it
 
Only just. :P
 
@Gordon - Oh. Meh.
Why doesn't it include stdclass?
 
8:09 AM
class Foo extends stdClass {}

print_r(class_parents('Foo'));

Array
(
    [stdClass] => stdClass
)
 
I thought every class "extended" stdClass by default?
 
hopefully, not...
 
ok, it doesn't. But it doesn't sound reasonable to me. Being able to create root classes, that is.
 
there is no Java Object in PHP
 
@ChristianSciberras root classes == lazy programmer...
 
8:12 AM
@Gordon Darn two years of java. :)
@KamilTomšík - The only non-Lazy programmers I know of are those that still do things in assembler. :P
 
using higher-level language is not about laziness, using base classes instead of composition is...
 
Since I seem to have lost @Raynos' debate on linux vs windows, thought I should mention I'm well comfortable with a linux VM (and a Win98/XP one as well ;).
@Gordon Instead of dual booting...
 
huh?
@Gordon btw: how's it going?
 
@KamilTomšík slight headache and trying to get a parser right
 
@Gordon Haven't had some coffee yet? It works miracles for me.
 
8:18 AM
and waiting for the firewall change to jump from released to closed
 
Together with anything that's sweet :)
 
@ChristianSciberras only one
 
@Gordon what about that rpc? have you finished?
 
@KamilTomšík no, and its not rpc
actually, the parser im working on right now is part of the solution to that other project though
 
@Gordon What does the parser parse/do (if I may ask)?
 
8:24 AM
hi all
 
@Gordon yeah, I know - but it sound like you wanted rpc :-P what's wrong with the parser?
 
@ChristianSciberras uri template parser
 
@Gordon is it for configuring mapping from xml?
 
@KamilTomšík nothing wrong with it.. just trying to come up with a nice OO way to do it
 
uri template parser?
 
8:30 AM
and yes, i know there is pear package and some other libs for that
feels like a good exercise though
 
@Gordon what about #name# syntax? {} could theoretically appear in uri, # simply can't
 
@Gordon Correct me if I'm wrong, but didn't F3 employ something similar?
 
@KamilTomšík # is for fragments, so yes it can appear.
 
@Gordon yes, but fragments are not propagated to server
 
@ChristianSciberras havent used F3
 
8:33 AM
@Gordon okay, no offense :)
 
@KamilTomšík True, but at this point i dont care about template syntax. im taking that spec as the basis
 
F3::route('GET /brew/@count',
	function() {
		echo F3::resolve('{{@PARAMS.count}} bottles of beer on the wall.');
	}
);
 
@ChristianSciberras F3 is fatfreeframework? I thought you refered to Flow3
 
@Gordon Yeah. Should be F^3, but anyway :P
 
@Gordon The hardest part probably is to read that whole spec... ^^
 
8:35 AM
me too
 
@ChristianSciberras thats different syntax. the specs dont allow for expressions without curly braces
 
@Gordon I see. I'm not very much familiar with both. Thought there might be a connection.
 
the uri template specs suggest to use example.com/{foo}/{?a,b}
so its OPEN_TOKEN, OPTIONAL_OPERATOR, VAR_LIST, CLOSING_TOKEN
or
	'(
		\{                           # match opening curly brace
		(?P<operator> [+./;?|!@]? )  # followed by an optional operator
		(?P<variableList> [^\}]* )   # and all that is not a closing curly brace
		\}?                          # until a closing curly brace is found
	)x',
 
Did anyone else ever think that the Dunning-Kruger effect might be the reason why they like and defend PHP so much?
 
depending on operator the varlist is parsed according to different rules
 
@Gordon Why \}? ? Is the closing } optional?
 
hmm, haven't seen uri templates used much before... nice to see them again :)
 
@nikic because the specs want the parser to still use the entire expression but complain about the missing brace
anyway, im now wondering how to best model the expression as an object graph
so i can simply tell it to evaluate itself
e.g. without a gazillion if/else/switch/case statements
 
@Gordon I thought you don't want operators, just simple replacing, do you have any scenario already? example for uri template + desired behavior
 
@KamilTomšík $uriTemplateProcessor->process($uriTemplate, $replacementData)
e.g. called with example.com/{foo}, array('foo' => 'bar') will give example.com/bar
for the simplest case
i have a UriTemplate class done already, which can be passed the processor
but technically its yagni. the only thing one needs is the processor
i saw a ruby implmentation where you would do new UriTemplate('blah').replace(blah) which I felt was nice too, but I didnt want to couple all the processing logic to the UriTemplate instance
the processing as such is explained in the spec. find all expressions in curly braces. look at the operator and process varList according to rules of operator
varlist can be of additional types though
for instance {?name:1}with value Foo for name will be expanded to`?name=F`
 
9:05 AM
@ChristianSciberras not sure whether that's a yes or a no because when I read that it doesn't make me think "yeah, it sucks"
 
@Gordon well, I don't know - do you really want to propagate all parameters through GET?
 
Sup?
 
@AdamLynch It answer well why PHP Sucks yet people defend it.
@AdamLynch Ask just about any PHP developer whether PHP sucks or not, the answer is guaranteed.
 
yesterday, by salathe
PHP sucks.
^^
 
8 ^ stars. From yesterday.
 
9:07 AM
@Gordon you could just parse that template to multiple Expression instances and let them to both bind and evaluate themselves... however I'm not sure about usefulness of such powerful templating...
 
@AdamLynch - For the record, it's a "no".
Now go ask C++, Ruby, Python developers whether theirs' suck.
 
@Gordon do you already have services dependent on GET?
 
@KamilTomšík yeah, the specs dont have any clues for POST though. im still pondering about it
 
@ChristianSciberras ok but I was looking for a discussion (incl. about the Dunning-Kruger effect) not a link though :)
Yeah I seen that.
 
@AdamLynch Since PHP people are conscious of this fact, Dunning-Kruger effect just can't take place here.
 
9:10 AM
@ChristianSciberras I wouldn't say it sucks. I'd defend it to the end. Maybe the Dunning-Kruger effect only applies to me then haha
 
@Gordon you could also do something like

...->mapRequest(function($builder){
  ... name, uri
  ->method(GET/POST)
  ->param(function($paramBuilder){
    //configure param - name, type, transformations, etc.
  })
})

that way, you could just switch GET/POST in requestBuilder... paramBuilders would then just result in different behavior
API would be more complicated, so it's probably hard decision...
 
i'd still need the uriTemplate parser then though
for those get requests
 
@Gordon no, you wouldn't - if your templating is just about GET parameters... if "path" is consistent regardless of passed params...
 
path is never consistent. imagine a rest client that wants to interface with example.com/order/{order_id}
 
@Gordon yeah, that's why I was asking...
@Gordon however rest is entirely different ecosystem - you can let your service to describe itself - by OPTIONS
I don't know, whole configuration just doesn't feel right to me... if I was writing REST/webservice client, I'd probably favor configuration through some standard format - either by OPTIONS (however I don't know too much about it, never been too much into rest) or by WSDL. Even when service does not expose its wsdl (and some of them do this by introspection - usually J2EE ones), you can write your own... yes, it's painful, but there are some GUI tools for this already...
and I guess somebody already written WSDL complaint webservice client for php...
 
9:28 AM
REST aint RPC, so WSDL are not that well suited
what you really want to do is use hypermedia controls to describe possible state transitions
REST services are described with a Domain Application Protocol and WSDLs are not good at that
OPTIONS is basically just a fallback to query for the resource's contract when the resource doesnt deliver that already through hypermedia controls, for instance with atom
 
yeah, it's not... well, thx for making it clear, like I said I'm not REST obsessed... my point was - you want to describe webservice (or REST :)) - and you can certainly do it in php, however you won't be able to re-use it in future (python, ruby, js, java, whatever else) some standard xml is probably better idea - even if it will require some extra energy
 
REST in Practice is a pretty good book about the topic btw
 
yeah, I heard that.
 
9:56 AM
Thought this was better in chat than a question on main site: I don't want to submit my user entered information into my database until i have confirmation of payment receieved from PayPal. Is it possible to pass the $_POST data into the 'listener' script PayPal's IPN needs, and only INSERT if the IPN is true?
 
@Dan Ready PayPal's docs, I was pretty sure it had something to that effect. If not, use sessions.
 
Thanks Christian, i have been having a look through but i'm a rookie so sometimes (most of the time) i need things explained in clearer manner.
I did read somewhere that i couldn't post session data into the listener script, but that seems the most obvious way to me
So was just hoping someone could point me in the right direction
 
I meant PHP sessions. You can use PHP sessions.
 
Yeas thats what i meant as well, apparantly Paypals IPN will respond with "VERIFIED" if true, so i would have thought, if i passed the users $_POST data in a session to the listener script, i could then have an IF ELSE clause to insert the $_POST data if "VERIFIED". Does this sound ok to you?
But (theres always a but) i have to send the user to Paypals payment page so i can't pass the session data to the listener script
 
 
2 hours later…
11:42 AM
Hello All
How can we connect the Php script with Wordpress website.... ?
 
@salathe is it me or is having to do $someNode->parentNode->insertBefore($newNode, $someNode); completely non-intuitive
 
@Gordon when approached from a "how do I put this node before this other node?" perspective, yep it's not very intuitive... and a common question :)
 
@Gordon Well, in a way it is intuitive. Doesn't one need to do the same in JS's DOM API?
 
hey, this is my first chat message :P
 
@MichaelSchinis hi
 
11:48 AM
@salathe is there another possible perspective? :)
 
The chat is great.. Im starting to love this place..
 
@Gordon once you've learned that it's the parent's job, sure but not before then
@MichaelSchinis first chat message, to loving the place, in 1 minute :)
 
Should be named insertBeforeChild then
 
@salathe when i say loving the place, i mean the whole stackoexchange thing :)
 
which of course cannot be because its the name given in the w3 specs. i know i know.
 
11:51 AM
@Gordon or insertChildBeforeOtherChild()
 
Hello
How can we connect the Php script with Wordpress website.... ?
 
Press 1
 
install the 42 plugin
 
1
 
$newNode->insertInto($someNode->parentNode)->insertBefore($someNode);
 
 
1 hour later…
air
1:05 PM
hello i am looking for help in swift mailer
hello
 
1:27 PM
yo @ChristianSciberras
 
How do you get the default value of a non-static property without initializing the class?
Hey @UniqueKey.
 
@ChristianSciberras Reflection
 
@nikic Couldn't get it to work.
$ReflectedProperty->getValue($instance)
Well, the weird part is that docs say $instance is optional.
The signature: public mixed ReflectionProperty::getValue ([ string $object ] )
 
hm, you'Re right, doesn't seem to be a getDefault there
@ChristianSciberras Where did you find that docs?
 
I don't see [ ... ] there
 
true enough
 
@nikic Actually, I checked my own first.
My personal one on my pc (the chm)
The signature in the CHM is that I mentioned above.
If you download the CHM, it's probably faulty as well, mine shouldn't be too old.
 
then the CHM is wrong. report that to the documentation team to get it fixed
 
1:35 PM
sigh
Well, there is isDefault()
 
the change happend on 2011-02-10 ;)
yeah, but no getDefault ^^
 
:D
public array ReflectionClass::getDefaultProperties ( void )
 
saw that already but afaik it does something different ;)
nope
does exactly what you want
$class->getDefaultProperties()['name'] on PHP 5.4 :D happy about array dereferencing support
 
must resist ranting on lack of documentation
 
it is documented
 
1:43 PM
@ChristianSciberras If you want it to be documented, document it :D
 
I said I won't rant :D
 
ReflectionClass::getDefaultProperties — Gets default properties. Return Values: An array of default properties.
 
hey, want to laugh?
 
@UniqueKey Interesting, go ahead.
 
well, the PM was on vacation for two weeks. finally a breather from pointless, inconclusive specifications, and a ton of time to develop undisturbed -- had the specs and all already. so i completed a planned two weeks project in half the time (there's a pattern here: when he's directly mangling the project, i'm late and it's wrong, and when it's in my hands i'm early and it's right).
 
1:46 PM
Sounds familiar. Very familiar.
 
so i did everything up to spec, and he came back today. i'm not sure if to my flattering or annoyance, but he was pleasantly surprised that everything went spotlessly as i did the project alone, as expected
 
    Method [ <internal:Reflection> public method getValue ] {

      - Parameters [1] {
        Parameter #0 [ <optional> $object ]
      }
    }
that's apparently a bug
because it sure isnt optional
@salathe ping
its not listed in the manual as optional either
 
but then he had to chime in: he wanted me to integrate into wordpress a live chat, with group management, logging and attachment support, and it all had to be integrated into a windows domain.
 
@salathe foghorn
 
Is that the reflection of the ReflectionClass class?
 
1:48 PM
and it was meant to be a TEMPORARY solution.
 
@Gordon Why is there a bug? It is correct in the current doc builds ^^
 
@Aether this is php --rc ReflectionProperty
 
so when i insisted that it was close to impossible to find such a tool written in PHP, much less to integrate into a blogging platform, he accused me of jumping to conclusions and deciding that it was impossible all on my own.
 
@Gordon Nice, I didn't know about that.
 
i was pretty close to flipping him off, and it wasn't until i explained, in gory detail, why in god's name no sane developer would make something so complicated for a blogging soft that he desisted.
 
1:50 PM
@nikic can you check why it says optional but doesnt allow omitting it?
It will give a Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 0 given when omitting an instance
 
the kicker? there's already a perfectly nice chat software, but as a standalone application, that does that already, and even then it's going to be replaced too.
 
@Gordon Ah, now you are talking not about docs but about PHP's internal method info?
 
@nikic yes. see output above
 
The last argument there should probably be 1
 
as if I'd knew what that means ;P
 
1:55 PM
@Gordon lxr.php.net/xref/PHP_TRUNK/Zend/… -> required_num_args
 
fix it
 
^^
I'm not a C guy. I don't want to fiddle with PHP internals
Additionally it's actually not the code being wrong but the doc change
Because the argument is indeed optional if the property is static ;)
 
Well, I'm off for today. Cheers guys!
 
@Gordon it's conditionally optional
gist: 1067290, 2011-07-06 14:01:54Z
<?php

class Example {
	public static $member = "Hi Gordon!";
	public $another = "Aww :(";
}

// Works fine
$ref = new ReflectionProperty("Example", "member");
var_dump( $ref->getValue() );

// Warning:  ReflectionProperty::getValue() expects exactly 1 parameter, 0 given 
$ref = new ReflectionProperty("Example", "another");
var_dump( $ref->getValue() );
 
2:18 PM
sup
0
A: Determining what is a useful unit test

edorianHow many tests per method? Well the theoretical and highly impractical maximum is the N-Path complexity (assume the tests all cover different ways through the code ;)). The minimum is ONE!. You quote: *And the thought of testing each of your methods with its own test method (in a 1-1 relati...

comments ?
and that the question got +15 in 45minutes is pretty darn much in SO terms
 
I should start to write more unit tests
 
@salathe I see. Thanks.
@edorian upvoted despite the eye bleeding headlines
01010000 01001000 01010000
 
2:38 PM
01010000 01001000 01010000 ?
 
yeah
 
sorry, i don't speak binary, could you translate?
Ui "PHP sucks." got 10 stars by now ... ^^
 
Oi, why removed that?
 
because its spam :)
 
2:40 PM
Don't we like spam?
^^
@Gordon It's on topic at least ;)
 
on topic spam :)
 
hum the online doc editor eats up my ram. firefox is at 1.2 G by now
 
@nikic typical for extjs apps
 
last time i used it i let it idle for about 2 hours while watching a movie. when i came back ff was frozen and i lost all my edits
 
2:47 PM
@Gordon :/ yeah, but without all the visual crap it's just a wall of text ands that even worse imho
 
@edorian you could not use h1 though. that would help ;)
 
@Gordon but what else, there are not h2 afaik (are there? does ## work?) and just bold for everything sucks too
 
yes ## or ###
its structually wrong but nicer to the eye
 
What do you mean by "structurally wrong"?
 
those i gladly use
@Gordon doesn't really get smaller :(
@Aether <h2> without an <h1> is not really great structure of html
 
3:03 PM
PHP sucks earned 11 votes. Shouldn't PHP be closed now? :P
 
@Gordon it does, my bad
 
@edorian But in the larger context of the page overall, it's not a <h2> without a <h1>.
 
@Aether If you don't use "top level heading" in a SO answer it's strange to use "2nd level heading" because the grouping is off. Only stuff on level 2 doesn't make that much sense
but since the <h1>/top level stuff is REALLY big it can be nicer to use only the smaller headings
 
@Aether what @edorian said
 
3:45 PM
switch($match['operator']) sound funny when you say it loud
swɪtʃmætʃˈɒpəreɪtə
 
@salathe "An error, and abort silently. :)" :)
 
@nikic :)
 
thinks it would be fun to write a convertor for PHP2IPA and back
 
@Gordon What's IPA?
 
international phonetic alphabet. the one i used up there
 
00:00 - 16:0016:00 - 23:00

« first day (263 days earlier)      last day (4675 days later) »