« first day (1345 days earlier)      last day (3829 days later) » 
00:00 - 19:0019:00 - 00:00

00:00
And even if you needed it you can test just that part before sticking it inside another query
@Ocramius Do you know if it's possible in PHPUnit to configure a mock object so that a method is called, as well as spied on to check how many times it's called without having to setup a test for what the function returns?
I'm making something that needs a test for a caching decorator around a class, so I want to check that the method in the original class is only called once......and I'm having to hard-code what it returns into the test, because that seems the only way to setup the inspection, and have PHPunit call the original method.
00:13
nah - they all have will($this->returnValue('value'); and it seems only if you do that is it called.
ThW
ThW
it is called without will(), but it should return null
@ThW Which is unfortunate because the class that is actually calling it doesn't expect null to be returned...
ThW
ThW
well it is a stub first, a mock second, you not assert and call the original
@Danack yes, I do
@DaveRandom One on "performance" and php engines
@ThW I don't understand what you meant - this is what I'm trying to do.
        $mock = $this->getMock('ClassToBeCached');

        $mock
            ->expects($this->exactly(1))
            ->method('executeQuery')
            ->will($this->returnValue(5));

        $cache = InMemoryCache();
        $decoratedObject = new CachingClass($mock, $cache);

        //This should go through to ClassToBeCached
        $decoratedObject->executeQuery(['foo' => 1]);
        //This should be cached
        $decoratedObject->executeQuery(['foo' => 1]);
That works - but the returnValue is hardcoded to the value returned from ClassToBeCached::executeQuery.
If I delete the returnValue the ClassToBeCached:: executeQuery isn't actually called.
ThW
ThW
00:28
What message do you get from phpunit? Is it possible that $decoratedObject calls it again if it got NULL the first time?
@ThW I don't get a message from PHPUnit, but it just doesn't call ClassToBeCached::executeQuery without the returnValue, e.g. $mock->executeQuery(...) returns NULL even though the function is:
function executeQuery($params) {
    return 5;
}
@Danack it's never actually called
ThW
ThW
$this->getMock() generates a stub first, the class does not even need to exists
> When the second (optional) parameter is provided, only the methods whose names are in the array are replaced with a configurable test double. The behavior of the other methods is not changed. Providing NULL as the parameter means that no methods will be replaced.
ThW
ThW
it overrides all calls to the original logic
00:31
@ircmaxell It's called if you set returnValue - I'd prefer to not have to hard-code the result of the method.
Just to trigger the call to the original object.
ThW
ThW
it is not called it returns the value
@Danack the mocked method is not called unless you tell PHPUnit to let it call (via ->mock() parameter
returnValue simply returns a value when the mock's method is called
and that's on purpose (if you're testing logic tha tdepends on return values)
also @Danack as far as your question on internals, look at how Python implements integers (they are transparently bigints as well)
Will do - seems quite icky so far.
ThW
ThW
night
user924016
00:37
nn
00:52
Thats messed up... I got a downvote because I was editing
0
Q: Font-size gets overwritten even with !important

JuicyI'm using the follow PHP to output some tags on my blog: foreach ($tagvalues as $tag => $count) { $size = 12 + $count * 2; echo '<div class="tag" style=" font-size:' . $size . ' !important; "> ' . $tag . ' </div>'; } Which results in this HTML on my blog: ... <div class="tag" style=" ...

People downvote way too fast
 
1 hour later…
02:21
Looks like I'll be switching to Mockery then : $mock->shouldReceive('foo')->once()->passthru();`
 
3 hours later…
05:20
@rdlowrey Wondering if you had decided on ripping the Injector interface out of Auryn or not?
05:44
Hi guys!! :)
Hi hassan
@user3739658 don't take downvotes personally. Most of the times it means you gave a wrong/inaccurate answer
@Magikaas I just watched a few episodes. Quite funny, sometimes some unnecessary ecchi scenes. I guess that's called "fan service"
06:02
Hi, guys, I have almost figured out Amazon Advertising API, but I'm having a difficult time incorporating the signed URL/XML data...this seems to be throwing me an error when the URL displays the XML fine in the browser:
// generate signed URL
$request = aws_signed_request('com', array(
'Operation' => 'ItemSearch',
'SearchIndex' => 'Blended',
'Keywords' => $rowA1["topicTitle"].' '.$rowA1["location"].' '.$rowA1["category"],
'ResponseGroup' => 'Small, Images'), $public_key, $private_key, $associate_tag);
Warning: Invalid argument supplied for foreach()
I feel like simplexml_load_file might be incorrect?
@radleybobins Could you provide a sample of that XML in a (private) pastebin?
how do I do that?
@radleybobins pastebin.com (duh)
oh heh, yeah hang on
hmm sorry it didn't preserve the indents, i can paste something shorter and more to the point if you need
@hamza I think you have me looking in the right place, i'm thinking its a path error
06:20
@radleybobins I'm getting errors. So the XML isn't correctly formed...
hm, its just a response from amazon
maybe the pasting process messed things up, it looks pretty good on the browser
@radleybobins Ah, then when you get the XML in the browser, check the source code and copy paste it in a pastebin
i realized my path was wrong, Items->Item->ItemAttributes->Title
ok if it fixed your problem then it doesn't matter :P
thats what I did, I'll get a small chunk together and formatted, 1 min
no it didn't though
same error
okay here
will be easier to read
06:32
@radleybobins Ah I fixed the other XML
it's because "&" should be "&amp;"
anyways, give me a second
wait, but that xml is dynamic
so the $request returns a url
and that url contains the particular xml pertaining to the search, so I don't really have access to the xml
// do request
$xml = simplexml_load_file($request);
foreach($xml->Items->Item as $item){
	$title = (string) $item->ItemAttributes->Title;
	echo $title . '<br>';
}
@radleybobins I think there was a problem when copy pasting. Anyways, the code above should work
oh wow thats perfect
so am I just not allowed to go that deep on the foreach loop?
the paths look the same to me
So basically you're looping through each element with $xml->Items->Item and then you select ItemAttributes->Title from each item
@ircmaxell github.com/ircmaxell/password_compat/blob/master/lib/… --- curious if it's a windows machine and there is a /dev/urandom file exists with a static contents
06:36
You used Items->Item->ItemAttributes->Title which is incorrect, since there are several Item.
oh of course
@radleybobins Try echo (string) $xml->Items->Item[0]->ItemAttributes->Title; and it should work :)
wow i feel like an idiot
thanks so much
i've been at it for so long
Basically there are a lot of "Item"s
But since you want this dynamically, you don't specify the index. You just loop through it with a foreach loop.
Welcome
yeah, that makes sense
06:43
Anyways, see you guys later. /workout
cya thanks again!
07:36
good mornings :)
you are :)
08:30
* * * * * php /www/importa-quicky/daemon.php > ~/importa_daemon_log.log
Will this do what I think it should? (run daemon.php using php every minute and logging the output to importa_daemon_log.log)?
@SecondRikudo It think you mean >> to append to that log.
Yup, you're right
and you might also want to catch stderr.
user924016
09:08
morning
09:23
morning
09:34
morning
Where would you say it's the correct place to validate details such as minimum password strength, username matching constraints (3-15 chars for example), etc?
In the service, or in the domain object itself?
DO is my guess.
@Fabien In that case, who is responsible for hashing the password on registeration?
DO again.
There's this
> If you find that the validation rules are very complex, you can create a validation service that will be used by the aggregate root for this function. Source
morning
@Fabien Hmm, that means Domain Object knows about validators and that seem to be out of its responsibilities.
Imho, domain object should provide metadata, how it should be validated but should not be responsible for validation itself.
09:57
So a validation service then
user924016
agh =]
off to studies. Later
user924016
Enjoy the studies
10:24
mornign
@Leri Actually, I think the job of the Domain Object is to do Domain Logic, that includes validation in some cases.
good morning
It's not just a struct, it's a full fledged object.
Room, I can't remember name of the service, which allows to restore audio name by it's soundtrack (digital, for example, mp3). Can someone remind me?
10:28
@SecondRikudo well, I have only mp3 part of the track (55 seconds) and I want to restore it. I don't want to sing something (: It's not a song. It's a track (no words)
No idea then XD
@SecondRikudo may be you know name of good software, which will allow me to rip track ? (I have video part, but it's with other audio tracks there - words, e t.c.) - so I'll need somehow to split channels and leave only the soundtrack part
@AlmaDo You mean extracting the audio from Video?
@SecondRikudo not only. I know how to extract audio part from video. But it's a movie - so I'll also need to split background soundtrack from audio-channel for words, special effects, e t.c. Not sure if it's possible, of course
@AlmaDo It depends on how the video was saved. In some format there's a separation, in some there isn't.
I'm not sure how it's done though :(
10:36
@SecondRikudo sounds fair. Ok, I guess, it's impossible in current format :\
10:49
@SecondRikudo Hmm, Well, I usually, treat domain objects as dumb objects that only knows what kind of data it's supposed to carry with it and throws exceptions when invalid data is passed (if that counts as validation) then I am with you. Otherwise, dunno..
Does PHP have a HTML parsing library like Beautiful Soup for Python?
DomDocument?
909
Q: How do you parse and process HTML/XML in PHP?

RobertPittHow can one parse HTML/XML and extract information from it? This is a General Reference question for the php tag

11:06
@zerkms no, safe mode...
@Fabien :-)
@Ufoguy FluentDom github.com/FluentDOM/FluentDOM is more pleasant to use (imo) than the simple libraries in PHP.
@ircmaxell can I have your opinion on a testing matter?
@Danack I think that trying to beautify the DOM backfires horribly in the long run.
Why?
11:12
Beautifying the DOM is what brought us the absurd global web dependency for jQuery, and now that DOM is relatively nicer in the browser world, that dependency is very hard to get rid of, even when it's completely and absurdly redundant.
PHP doesn't even have the problems of inconsistency the client-side has, I see absolutely no reason to try and beautify a well known, well solved, well thought out solution like DOM.
On the contrary, learning DOM will allow you to use it everywhere, in PHP, in JavaScript, Python, Java, whatever.
>I see absolutely no reason to try and beautify a well known, well solved, well thought out solution like DOM.

Because productivity gains for programmer time today, are better than productivity gains in the future.
@Danack NO!
If you gain 30 minutes now, but lose two days in the future, that's not a productivity gain at all!
There are standards for a reason. When you break standards, and break design patterns, there are consequences.
@SecondRikudo But 30 mins gained now may be more valuable than 2 days in the future.
Also, the savings are much greater than that imo.
@Danack Hardly
Whatever you try to do with Fluent, I can do with DOM at about the same time.
XPath is stronger than CSS selectors IMO, and it all comes down to the personal experience of the author.
@SecondRikudo FluentDom does xpath...so not sure what you meant.
11:18
@Danack From a glance, FluentDom uses jQuery style API
Does it not?
The api style may be jQuery like, but it does xpath queries:
...
(obivously trivial example)
$descriptionBlock = $subDOM->find("child::ref:listitem/ref:para");
foreach ($descriptionBlock as $description) {
    /** @var DOMElement $term */
    $paramDescription .= trim($description->textContent);
}
Better example
Or at least more xpathy.
Being able to find stuff with xpath and then do a callable on the each is lovely.
$description = function (DOMElement $element) use ($manualEntry) {
        $manualEntry->setDescription($element->textContent);
    };

    $dom->find('//ref:refsect1[@role="description"]/ref:para')->each($description);
Mmmm-hmmm.
@Danack while I like callbacks, my experience with them is that a lot of people find them hard to grok. A foreach might not be as fancy, but everyone can easily understand it.
I am with @SecondRikudo when it comes to 3rd party DOM libraries. I don't see much benefit in using them over ext/dom. Although the latter can be quirky and verbose.
@Gordon I agree, writing code that is more likely to be understood is generally better and callback stuff is harder to debug as well. But there's cases where you want to chain stuff together, doing different functions based on what's in the elements, and in those cases, callbacks turn out to be nicer (to me at least).
11:38
I really miss generics in php
I really want to do: interface DataMapper<DomainObject> { // crud here }...
What do you guys usually do for that? ^
@Leri Cry a little.
I don't want to violate DRY and also I want type-hints.
@Danack I am not that type of a guy. :P
@Leri I use plugins.jetbrains.com/plugin/… which allows the type-hinting to be done via the doc block comments. Obviously it's not run time checking, but it allows static analysis to work.
At least for simple generics e.g. checks for an array of some class with SomeClass[]
@Danack Thanks, nice plugin. However, php makes me sad when I work with it.
11:55
@Gordon sure
what's up?
@SecondRikudo Hmm? DataMapper is supposed to provide CRUD and you can't write to http request.
@ircmaxell do you consider this to be a useful test: gist.github.com/gooh/47891cbab93315396214
@Leri First of all, take note that you're talking about an answer written nearly a year ago.
Second, what do you mean? Where have I said that you need to write to http requests?
I think it is, not as a unit test, but as a smoke/integration test.
@ircmaxell yup, that's what it is
11:58
but I do want to know why it extends DatabaseTestCase, that feels weird
@ircmaxell because legacy. the dbtestcase loads the fixtures like the user data and access tokens which I need to make the authentication work
@SecondRikudo OP wants to create object and assign posted data to it. In the answer, you suggest creating DataMapper, DataMapper, as far as I know, should be providing two way mapping.
@Gordon I partially want to say WAT, but I get it...
@Leri Yes, you are right.
12:10
@ircmaxell would you say I can remove that test and simply trust the routes to be protected? its handled internally through a custom listener in sf2 and configured in the sf2 firewall settings. but then there is no assertion individual routes are indeed protected.
@SecondRikudo Well, how do you do that now? I used to use some modification of Data Provider that had hidden dependencies and was an anti-pattern altogether.
@Leri I use a Form object that represents the data that was received from forms.
And have some Mapper between domain object and form presentation model object?
@Leri Yes
Sounds sane.
thanks
12:17
The Form object has a double purpose, it can do validation and pass on only data that passed validation, and it can also be bound to a view/template to prefill form data in case of validation errors.
 
1 hour later…
13:32
console.aws.amazon.com/iam/home?#security_credential if i use this .. then using my access key can other users upload media or they need seperate keys??
Sunday afternoon music has inspired my to whip out the ol' crappy bass guitar. My fingers hurt already.
morning
13:49
evening
can someone help me with how to use amazon's root access key..
@Fabien Sunday is always inspiring. btw, how's your hand?
Turns out it was fine. Just bruised pretty bad but everything normal.
put it in lukewarm water maybe
Tis fine. I have no plans for physical activity besides the gym room for a while anyway.
guitar gym programming ... do you dance as well?
13:57
@Fabien Gym activity is more than enough. It can really feel you with energy
I used to breakdance when i was younger but I gave it up for University basketball.
Good morning from 34,000 Feet up :-)
Where you jet-setting now @ircmaxell? :)
@ircmaxell Where are you flying? :)
your cv must be one of those super cool ones, i bet
14:01
@shortCircuit @ircmaxell?
Negative. Besides. I'm a mediocre web dev, not a programmer... yet. :)
> I wrote the Zend Certified Engineer Exam
If we're looking for people to clone to further the human race we have to vote @rdlowrey
@Fabien off to San Francisco, for Google I/O
@ircmaxell Nice. I've been to SF when I was pretty young. Can't remember much though.
14:03
I'm out there once a month, or so it seems :-)
@SecondRikudo can you tell me about one thing ... if i have 5 users using my website , and they want to upload their content to amazon cloud , should i use a single Access ID (the one where only two can be active at a time console.aws.amazon.com/iam/home?#security_credential ) or one of those IAM access ( docs.aws.amazon.com/IAM/latest/UserGuide/… )
@shortCircuit I've actually never worked with AWS, so I don't know.
:(
hot
@ircmaxell do you happen to know something!! you are the security man
how to write good resume
for PHP developer
any suggestions?
in the list of languages known write php(experienced)
add some projects or websites you have worked, that might help
14:13
okay
mostly indian recruiters are overwhelmed if you have made something you can show .
is it good tp fit all my work in one page only, or using 3-4 pages is also cool?
i guess when people don't answer in php room, the issue has been already addressed by google .. i need to look harder. 3-4 pages of CV. how many years of experience do you have.. ? i have 0 btw. my cv is 1.6 pages
i got 3+ years of experience
3-4 pages mean there are of lot of project works..
14:18
@SandipPingle keep it as short as possible but as long as necessary. I had a 2 page portfolio on my last application (for the job I have now)
okay, thanks @Patrick. I am actually confused about describing my project, should I write summary of each project or should explain it orally on demand?
@Gordon is it slow? If not, it can't hurt to leave in as a sanity check...
in our classes we were taught to write it like : i have worked in xyz company for n years as a ceo .
then they might ask you what work .. and you can describe..
@SandipPingle I had a partial screenshot, a quick description which included what I used to code it and a url. (for the portfolio, I also had a CV with past jobs etc)
umm.. don't they generally skim your cv ... and so keeping it short and proper highlighting by efficient use of fonts more useful than using descriptive sentences!!
14:27
:) i think AnonymousPro might be good font for my resume, thanks for the tip.
anybody having any sample profile for reference?
15:14
1
Comedy

Proposed Q&A site for comedians, people who wanna lol, and people coming back frustrated from work requiring fun.

Currently in definition.

15:39
PHP historians questions (mostly targeted at @Gordon and @ircmaxell), why did they decide that echo true will output 1, and echo false output nothing?
2
@ircmaxell A
@ircmaxell A and B
I like both
one for morning, one for evening (-:
15:49
both were shot 5 minutes apart :-)
@ircmaxell Your vids are cool
I checked them out yesterday, good insight.
thanks
Also what are those black things in A/b?
In the sea?
They look like remnants of a pier
yup
pilings
the hurricane (Sandy) destroyed that area
15:54
@ircmaxell Any idea about my question?
16:05
@ircmaxell I have a question about responsive design if you could help me?
Nvm solved it.
16:21
Hi everyone
user924016
Hi
Is it possible to send the http response manually (as string) instead of having to go through the header etc functions?
I guess not because the server adds stuff to it too?
16:38
Does anyone have a good idea/reason why some projects are ignoring the composer.lock file by their .gitignore file?
@hakre There seemed to have been a trend in thinking it was a good idea; that it should be regenerated via install on every clone
But in reality, that shouldn't be the case, because you want to persist the versioning.
@DanLugg that's what I normally take as well, especially for applications.
and if the lockfile should be regenerated on every clone, then why isn't there a flag in composer.json to no generate a lock-file?
I'm wondering especially because monolog which is driven by Seldaek ignores it and he is maintainer from composer as well.
Well, I don't think you want to regenerate the lock file. You keep it, and only regen when the deps change
makes sense.
Because if you have "whatever": "*" and do an install 6 months later on a quickly reversioned "whatever" package, the API could've changed.
Hopefully it wouldn't, but in reality...
Anywho, full disclosure: I'm not a composer guru by any means, that's just what I've taken away from various discussions of track/ignore regarding composer.lock.
@hakre Wait, monolog ignores the lock file?
user924016
puh.. been writting python all weekend
Does anybody of you know if there's any email parser that doesn't use mimeparser nor imap?
I need something that can be used on various server setups by users with no php skills to install 3rd party libraries
@NikolaR. "users with no php skills" and "installing libraries". Doesn't really make sense...
sorry, I wanted to say that app will be used mostly by users without php and other programming skills, and solution must not include installation of 3rd party libraries in order to work
17:06
@NikolaR. IMAP is a protocol. Without it how will you download the mail? It's like saying I want to browse the internet without TCP/IP
I am piping emails using php://stdin
so if this works, it means server has IMAP enabled?
Wait wait wait
So you're telling me you expect people who have no PHP skills, to open terminal, SSH into the server, run your PHP from the command-line, and type in the email via stdin?
How would I prevent the form from submitting if it doesn't meet requirements? I have it as action="r.php", but if it isn't valid how can I prevent it from going to r.php and showing the errors?
@user302975 define valid? Also you might use HTML5/JS
@user302975 You can't.
I don't even need your form to submit a POST request to your r.php
17:10
Well like if the username is taken, I don't want the form to be processed.
For example, you could use required attribute. You might also use the pattern attribute. But anyone can hack around it. You should add some checks to r.php
Can't I just stay on index.php?
@SecondRikudo no, I am making WordPress plugin with email piping feature. Plugin will be used by those users
/me sighs
The only thing you can do is try to make it more convenient for the user, by using JavaScript to halt the form submission.
17:10
@ircmaxell E_WP :P
user924016
@NikolaR. I made a wordpress plugin you can use =] wordpress.org/plugins/uninstall
10
user924016
=P
@RonniSkansing ahahahaha
@RonniSkansing 5/5! Must have!
So JS is the way most people do it? Just for the user, I know I'll also have to do server side validation @SecondRikudo
user924016
17:11
Thanks guys
funny... I can't stop laughing...
@HamZa E_A_LOT_OF_THINGS
@user302975 For the simpler cases, you can use HTML5's validation attributes.
For example <input required> will not allow the form to submit if empty.
Again, these are only for the UX, not for security. They can be very easily disabled.
@user302975 "If the user is taken" -> you might do some ajax-fu to prevent the "reloading" of the whole page
Alright. Thanks @HamZa @SecondRikudo
17:17
73
Q: Team members spending too much time on Stack Overflow

user2711965Almost 8 months ago, I introduced encouraged my team members to follow Stack Overflow so that they can read questions, help others, and build their skills. But now this has gotten out of hand. I have a team of 5 developers, and three of them make at least 150 points on average,each. (This is most...

^ hehehe
18:09
echo explode(' ',$row['tag']); is giving me Notice: Array to string conversion.
Any ideas why?
@RahulKhosla you are echoing an array. instead of echo, use var_dump() or printf
Wait I was trying to replace the spaces with ,'s
but I just found I can use str_replace.
    <?php echo str_replace(" ", ", ", $row['tag']); ?>
@NikolaR. Is there any way I can wrap <span>mytag</span>'s?
@RahulKhosla echo '<span>'.str_replace(" ", ", ", $row['tag'])."</span>"; ?
I ment
around each tag
my tag is in the following format "a b c"
is $row['tag'] an array?
18:15
No, just in that format above ^.
I see, it's string
then use $tags = explode(" ",$row['tag']);
Ahhh I see
and then echo '<span>'.implode("</span><span>",$tags)."</span>";
Thanks so much
or better use foreach($tags as $tag) echo "<span>$tag</span>";
18:19
@NikolaR. Thanks so much, saved me hours!!
Nope.
@RahulKhosla u're welcome
I understand the code now, lemme just confirm.
explode, explodes the $row['tag'] into an array by using " "'s as a separator.
as delimiter, yes
foreach, loops the $tags as $tag, then just echos it within span's?
18:22
correct
Foreach has to always have two params? Can't it just be foreach($tag) {}
?
it must be array as item
or array as key=>value
OHhhh
So in this case, the exploded row is $tags.
I get it now :D thanks!
evenings
18:35
Hey Dave
@RahulKhosla (I'm guessing it was you) fyi stars --> are shared, they don't act like personal bookmarks. Please don't star things that are only of interest to you as it clutters up the board on the right. You can save links to messages you want to find again by right-clicking the down arrow that appears between the message test and the avatar on the left-hand side of the message and doing "copy link address". Thanks :-)
@DanLugg It doesn't just protect against new versions satisfying the requirements, it also protects against being tags being moved or other fuckery.
@SecondRikudo because PHP :-P There actually is a good rationale behind it but I can't remember what it is. It bugs me more that '0' == false tbh, I can live with echo (int)$boolVar;
Still less worse then Java's System.out.println("" + null); outputting "null".
@PeeHaa didn't you ping me last night? I don't find the ping anymore
18:42
He covered his ping tracks. It was a one night ping.
@Danack errr... wat?
@DaveRandom like this:
String s = null;
s = s + "hello";
System.out.println(s); // prints "nullhello"
Because who doesn't want visible null strings.
@ircmaxell Will super-secret project be less super-secret by then? :-D
@Danack No I get what you mean, that "wat" was at the behaviour :-P
Presumably that means that String has an emergency fallback toString() that gets called instead of throwing an npe :-S
I wonder if you could overload it
wtf
@DaveRandom I think it's at the byte code/vm level. You can do null + "SomeString" and it will output nullSomeString.
As there's no class to lookup the + operator of, the behaviour has to be defined outside of a class.
Well yeh I guess so, would be an awesome way to screw with people though :-P
oh shit yeh I remember what I wanted to say
@rdlowrey ping when alive
I know you fixed the segfault with openssl >1.0.1 + TLS1.1/1.2 in PHP <5.6, and presumably because no-one ever reported it no-one ever really encountered it, but I wonder if after heartbleed we might see some people running into it eventually. It's very likely that someone somewhere running <5.6 and OpenSSL 1+ updated OpenSSL to 1.0.1f or whatever it is, and didn't update PHP. Thoughts?
00:00 - 19:0019:00 - 00:00

« first day (1345 days earlier)      last day (3829 days later) »