« first day (1467 days earlier)      last day (3464 days later) » 

12:00 AM
assuming that the name is encrypted, getName could decypher it. If name is a property, I can't implement an encrypted version of User anymore
which indeed makes the interface unusable/inflexible
 
$ php -r 'interface Bing { public function boo(); } class A { public function boo() {} } class B extends A implements Bing {}'
 
and non-composable
 
@Ocramius You can use __get.
 
And be beaten up by my colleagues? Thanks!
 
@AndreaFaulds not if the interface defines a property? How would __get's behavior be enforced by the interface?
 
12:01 AM
Define a property and don't use it (ew)
Yeah, we need getters and setters :/
 
now my property is going to be read unless I unset() it at runtime
:P
 
>is utilized for reading data from inaccessible properties.
Oh, damnit.
 
Pro-tip: if a bar has "deep fried bacon" on the menu, just order it. Holy crap. #nycdrinkupathon
 
Hmm
@Ocramius Perhaps we could have virtual
virtual public $x;
marks a property as to be implemented by __get/__set
 
I'd rather re-propose property accessors instead
 
12:09 AM
Then again, why not actual getters/setters? :p
Yeah
 
afaik, the last round got rejected due to implementation details
 
@Ocramius I didn't like that RFC. I'd want something ultra-simple.
 
well, I'd start from there then :D
 
Like this: public $x { get { return ...; } set ($value) { $this->... = $value; } };
No visibility modifiers. No auto-shadow property. No short syntax. No magic. Just the basics.
 
hmm
well, it is a shadow property :)
 
12:14 AM
What is? I mean, no magical private $_x created
 
ah, nono
not that stuff plox
 
12:30 AM
 
@Danack Haha, and every movie ever after used the "horn" sound.
 
Is not horn. Is BWAHM!
 
Haha
 
12:47 AM
I handled inheritance now!
 
12:57 AM
SUP BROTHA'S
SORRY FOR CAPS WORKING WITH SQL SHIZZLE, TOO LAZY TO HIT CAPS ALL THE TIME :p
 
BWWWAAAAS @Danack
 
LOLZ
 
I <3 the Zend Engine
It's crap, but, well
That crapiness makes new stuff easy to implement
 
1:14 AM
Got a question: Can I ask questions?
^^ joke

anyways:
a php timestamp should it be saved as varchar or as int?
 
it should be saved as timestamp, but int is fine too...
it should be datetime anyways
 
hmm
datetime?
that's since 5.0
I want to keep my database datatypes as local as possible in the sentence 4.0 versions can also run it :)
wait I already screwed that up with my bigint :P
I basicly always use unsigned bigints :)
I am working on a forum software *educational purposes yet*
if I work with unsigned bigints this software can hold up with these ratio's:
My forum can store:
18446744073709551615 Members
18446744073709551615 Threads
18446744073709551615 Groups
18446744073709551615 Posts
18446744073709551615 Bans
18446744073709551615 Everything that has an ID xD
 
100 years later....
 
1:30 AM
@MikeM. never gonna happen
 
1000 years later....
xD
how long would the page be with 18446744073709551615 categories + forum sections :P
 
it won't be a page anymore
 
xD
How about the loading time xD
10 years later....
 
lol
 
clicking a forum section
 
1:33 AM
you're doing it wrong(tm)
 
18446744073709551615 threads

50 years later....
@CSᵠ Yeah I am seriously not joking -.-
althrough I still use bigint tho'
 
1:46 AM
A thousand years later...
 
xD
 
@boyee well, browsing that many threads (just browsing) at a very fast and let's say constant rate of 3 threads per second
does it seem reasonable so far?
would take...
approximately...
4.5 billion years
so... yeah, you're safe
 
lol hahha
 
ok, what's up with SO -- and why is it telling me that 0 questions exist...? :P
 
@MikeM. storing that many categories/sections, assuming each would be only one English word, allowing duplicates, would take up aprox. 95 million TerraBytes of 'disk'space
you'd maybe wanna think about restricting that one
 
1:58 AM
@CSᵠ I don't really mind if it becomes that big to be honest.
 
:)
 
I deliver a product the end user makes their decission.
but I make sure to make a warning for it :)
 
@cHao everything works... what's your query?
 
no query. i just hit the "questions" button. doesn't always happen either
sometimes i get questions, sometimes i don't. and nothing changes on my end between attempts
 
Oi
 
2:00 AM
@MikeM. Warning: this product is able to exceed diskspace existing in the entire world to date
oi
@cHao addons?
 
@CSᵠ That's what I do it for :) (rofl)
 
yup, you're safe
 
just WOT. and i've had it installed for months now
 
WOT?
 
web of trust. basically ranks the trustworthiness of a link's destination (as reported by other users)
 
2:11 AM
I never trust these "Downloads of all time" thingies...
I am going to sleep for about 1,5 hours
then I am going to make myself ready for a day bullshitting in theme park "de efteling" :)
cya'll
 
@AndreaFaulds But half of the common use-case is auto-properties with different visibility. public $foo { get; private set; } -- you don't need auto-properties for that, but now you have to write the backing field yourself.
And the auto-properties just generate name-mangled private fields, like $\0foo, and the associated $this->{"\0foo"} = $value etc.
Nothing particularly "magic" happening.
 
2:42 AM
sealed class Government {
    public Party InPower { get; internal set; }
}
 
user895378
@Danack Hmm, okay, will look into it.
 
user895378
@Danack Can you give me a bit more information about the scenario where you see the problem? Like does it happen after lots of requests or what?
 
user895378
Any sort of context would be helpful.
 
user895378
3:13 AM
@Danack I've found that there is a memory leak somewhere :)
 
user895378
It manifests for each socket connection that has to be opened. When the socket is closed there are resources somewhere that aren't being cleared so they will pile up indefinitely until your script blows up.
 
user895378
That may or may not be the cause of your problem but it's one thing I can definitely fix.
 
user895378
/cc @Fabien ^
 
user895378
After three years of event loop programming I'm officially a memory-leak ninja assassin.
 
user895378
The leak is something on the order of 3k per socket that is opened and closed, though. So I'm not sure that's the cause of this specific problem.
 
user895378
3:33 AM
@Fabien and/or @Danack ... are either of you guys using either pecl/libevent or the php-uv extension in your current environments?
 
user895378
3:46 AM
Nevermind, that's not the culprit.
 
user895378
I've narrowed down the problem to Promise instances never being destroyed.
 
user895378
Announcement: Sorry to everyone else for usurping the history with my rubber ducking :)
 
usurp; now there's a word you don't hear every day.
 
user895378
Yes, it's embarrassing but words like that creep into your vocabulary when you spend too much time cruising Game of Thrones fan sites.
 
4:20 AM
i want to study software design patterns, but i don't know which book should be better.
i am seeing..
http://www.flipkart.com/patterns-enterprise-application-architecture-english/p/itmdwxxtkyfybvxs?pid=9788131794029&icmpid=reco_pp_same_book_book_2&ppid=9788131700075

and

http://www.flipkart.com/design-patterns-elements-reusable-object-oriented-software-english-1st/p/itmdytsswfy3qeqn?pid=9788131700075&icmpid=reco_pp_same_book_book_22&ppid=9788131794029

is there anything better for a begineer
 
 
1 hour later…
5:39 AM
good morning :)
 
@AndreaFaulds there is a member_modifier rule so then you can remove the check from compile routine for method decl ...
moin all
 
6:09 AM
@ircmaxell ping
 
6:33 AM
posted on October 22, 2014 by kbironneau

/* by mato */

 
6:52 AM
@mato :)
 
good morning
 
7:17 AM
good meurning :)
 
7:32 AM
murnings
 
7:50 AM
'nin
 
Morning
 
moonings
 
Anyone elses Google hangout not working?
 
I don't have any friends in real life to hangout with =o(
 
Morning
 
8:03 AM
@Fabien me, and blogger ... and g+
@crypticツ overrated ...
 
@crypticツ Coworkers?
good to see you back.
@DanLugg ping
 
@JoeWatkins Nikita Popov… not Nikita Poppov (your last blog post…)
 
cant change it ... will do later...
thanks
actually blogger just started working ... /cc @Fabien
 
Cool. Hopefully the rest will be back soon
 
morning guys so a week ago i asked a question but it didnt get a lot of view and i really need this to work out and so i was wondering if you guys could give me a hand. stackoverflow.com/questions/26392762/… thanks guys
 
8:13 AM
@AndreaFaulds by the way, I strongly feel that to_{type}() functions should return null. For one main reason: to be able to pass its return value to a nullable scalar typehint. Imagining code like: function accpetsInt (int $i = null) { if ($i === NULL) $i = 2 /* default value */; /* do something with $i */ } acceptInt(to_int($_GET["userinput"])); If we return false, it'll get as ugly as acceptInt(($tmp = to_int($_GET["userinput"])) === false ? null : $tmp); I really prefer the former variant
Also, IMO exceptions are also a bad idea as the casts probably will be used on external input and exceptions are not a way to handle malformed user input. Really not.
 
@rdlowrey Not as far as I am aware.
 
good mornings
 
@AndreaFaulds well… I think I'll put my thoughts onto the ml…
 
@rdlowrey Seems to be fine fetching final uri thanks :)
 
8:33 AM
posted on October 22, 2014 by kbironneau

/* by garyry */

 
hahaha
 
Hmm. I don't reply often to mails on internals, but when I do, I usually have a strong opinion… \cc @AndreaFaulds
 
I like this trick for($k=2;$k--;)echo $k;
 
@HamZa What trick is there?
 
@bwoebi no trick for you... Most of the times people tend to do: for($k = 1;$k >= 0; $k--)
 
8:46 AM
@HamZa foreach ([1, 0] as $k) is nice too ;-)
 
hehe true
Reminds me of python
 
Wasn't there something like for in [1..0] or somehow that?
 
Ruby I guess
 
well… no idea… I don't know neither… ruby or python…
 
9:00 AM
returnsArray()[0] neat feature too
 
ThW
@iroegbu really? to me it seams you're loading to much data in a method :-) ... it is different with returnArrayAccess()[0]
 
3v4l.org/0JJOn I like that I don't need to assign to a variable to use the returned array
 
ThW
@iroegbu I would prefer something like 3v4l.org/VPhdX, avoiding the notice for an invalid index.
Don't take me wrong, the dereferencing is useful, but I consider it something to be careful with.
 
9:16 AM
I understand your concern, who'll just reference stuff like I did there? see 3v4l.org/FmEQr
 
Google Hangouts is working again but I think you need to restart it. If not I re-downloaded the app and it's updated and working.
 
can we ?
 
ThW
@iroegbu I use classes implementing ArrayAccess/IteratorAggregate for that kind of lists. That provides me with the encapsulation and the syntax sugar.
 
0 12-59/6 9 * * *
0 /6 10-16 * * *
0 0-37/6 17 * * *
Run every 6 minutes, starting from 9:12 AM until 5:37 PM.
 
9:37 AM
Any of you guys know how to set a proxy with Artax?
 
@Jimbo o/
 
@Fabien Does this help?
 
Potentially @Jimbo I'll check it out thanks.
@Jimbo You're familiar with Auryn actually. I could use your advice.
 
I recommend using Guzzle, it's so much better and has much better async, non-blocking capabilities /cc @rdlowrey
 
9:43 AM
@Jimbo Trying to summon the wrath? :P
 
Nah, I haven't mentioned MVC anywhere ;-)
 
Lets say you have a bunch of puzzles that can be solved in various ways but you always want to just call the method ->puzzleAnswer(); to return your answer.

You have a class PuzzleDecoder(). In that class you can call this puzzleAnswer() method that exists on all the individual puzzle classes. You need to instantiate the correct puzzleClass from the PuzzleDecoder() class.
With Auryn what do I do?
I can get the correct puzzleClass name from a string passed to the PuzzleDecoder();
 
That was the worst possible example available
:D
 
You're the worst example available!
 
Ohh touche
 
9:46 AM
Let me psuedo-code. brb
@Jimbo Still crude
 
@Fabien That's because that's an empty page :P
 
Ugh didnt work
 
@Fabien you are linking to the homepage...
 
Fixed. Stupid author required.
 
mornings
 
9:56 AM
Hey Dave
 
hey
 
@Fabien So, you're trying to instantiate the correct Puzzle object via the string $puzzleType?
 
Yeah
Eventually so I can have Auryn handle dependencies instead.
 
@Fabien nope. Make a Puzzle interface. Then add a dependency to that to your Decoder class instead of the string
 
Don't do that within the constructor of the object, I would suggest figuring out the $puzzleType first, checking with class_exists() etc, then passing it into the Decoder
What @Patrick said
Interface the puzzle out so that all of your puzzle types can be referred to by your Decoder and type hinted for
 
10:00 AM
morning
 
May I ask for an example please? So I don't misinterpret that.
 
Well, that's the interface created for you
 
you mean return $this->puzzle->puzzleAnswer(); ?
 
@Fabien Then you would use Auryn to make a PuzzleDecoder with the specific Puzzle instance you require.
 
btw.. isn't $this->getPuzzle()->puzzleAnswer() preferred?
 
10:02 AM
@FlorianMargaine Yep
 
just wondering if it's for the sake of the example
 
@JIGNESH don't do that
 
PuzzleDecode(r) seems a bit unecessary though
 
@FlorianMargaine Nope, no need to do that if you're already within the class
 
ok
 
10:03 AM
tnx @DaveRandom
 
@Jimbo but then if you need a specific logic when getting the property you have to refactor
 
As hilarious as that is, DO IT AND I WILL END YOU
:-P
 
:D
 
@FlorianMargaine I tend to put that sort of logic in the setter
Thinking about it, I haven't actually put any logic in the getter yet I don't think
 
yeah... YAGNI I guess
 
10:04 AM
So I pass the interface?
 
just feels... wrong
I want getters/setters ._.
 
@Fabien paste.jesse-obrien.ca/EZn not sure what the point of the decoder class is
 
Cheers @Patrick and @Jimbo
 
@Fabien you pass an instantiated object, type hint with the interface only
 
@Patrick Seems like it's a service connecting the usage of a HTTPClient and the contents of a Puzzle
 
10:05 AM
I see
 
Means you can swap out your HTTPClient and still do what you need
 
@Fabien that way, any kind of puzzle will pass, and your PuzzleDecoder knows that it will have the 2 methods it needs. Because it's an interface.
so your PuzzleDecoder only needs the object to adhere to the contract of the interface. It doesn't care about anything else
 
What about an abstract class, with the HTTPClient and Puzzle interface for the constructor, with the two extra methods declared as abstract?
So your puzzles will then at least all get the same http client? :-)
 
@Jimbo seems like it would make more sense to create a PuzzleScraper and a PuzzleSolver
@Jimbo or just share it on the auryn side of things?
I don't like extending things :D
 
@Patrick Extending has legitimate usages, we all prefer composition but still abstract classes are useful
 
10:09 AM
@FlorianMargaine Cheers
 
Like forcing a set of objects to always have a validator object associated with them, for example. I've done that
 
@Fabien that's duck typing btw
> If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck.
notice that verbs are used "swims like", "quacks like", etc. Not nouns.
as usual, @ircmaxell's blog has some nice posts about this...
 
Sweet, you guys are awesome.
 
@FlorianMargaine great classic post
@FlorianMargaine I recall reading a similar one about first class citizens
 
@FlorianMargaine oh no, it was written in early 2000's and definitely not by ircmaxell
 
ah :)
that said... what's a first class citizen?
functions are in languages like js... but "first class citizen" by itself doesn't mean much
 
@FlorianMargaine it was written in the same style as the kingdom of nouns, a pretty interesting read, will try to find it later :) there was an explanation of differences between languages that in some functions are FCS and in some not, what it depends on, what it affects and such
 
Hi
Is there an easy way to do a redirect but when there is already output before you do it?
I mean some solution you don't have to worry about the headers already sent.
 
yes, the solution is to go through a single (simple) controller. This way, you see in 20 lines where the headers are sent and where the output is sent.
 
10:25 AM
@Duikboot I can only think of echo '<script>window.location = "http://www.somepage.com";</script>';
but that's bullshit
 
@Duikboot why would that happen in the first place?
 
@SergeyTelshevsky I won't do that. :P
It's a wordpress site and I have a site property wich may not be accessed by not logged in users. So I did a check on that...
 
@Duikboot why don't you buffer the output in that case?
 
That works but now I want to redirect the user to the homepage.
 
wordpress... well there's your problem :(
 
10:27 AM
oh, it's wordpress * retreats *
 
;p
 
10:39 AM
are facades always an anti-pattern or does it depend on the implementation? e.g. no static methods, serving as an interface to a bunch of interconnected classes?
 
Has anyone actually had a valid use-case for statics in their codebase?
 
10:55 AM
You guys ever know a solution like redis that instead of having a TTL has a TTD. So it'd remove an item for that time.
 
lol, that one got 1 undelv
 
@Jimbo I think only making stateless library classes is a case
 
Morning
 
Moved yet @AlmaDo?
 
@AlmaDo hi
 
10:59 AM
Well since 1-st of October
On lunch now, waiting for food ;)
 
@AlmaDo Nice. How is everything?
 
Everything is fine so far
 
had a kind of argument with collegue, what do you guys think, is it ok to return instance of paginator from doctrine repository method?
 
Some problems since I'm a foreign but it's ok
 
@SergeyTelshevsky Why not just make them non-static though?
 
11:06 AM
@Jimbo imo it's pointless to create instances just to call their methods
 
@SergeyTelshevsky to get rid of static coupling?
 
@SergeyTelshevsky Not pointless, means you don't couple any more....
 
@nikita2206 @Jimbo true, but this also depends on use case, I think it's completely OK to have coupling in view files, for example
 
Imo it's pointless to have globally available method calls (global state), hard to control and remember it exists.... might as well use dependency injection with hard objects
 
@SergeyTelshevsky it makes unit testing impossible
 
11:09 AM
@nikita2206 I don't think anyone ever tests view files
 
you are takling about view files?
 
as an example
 
Templates, I believe
 
we're talking about use cases of static classes
 
I know of one use case - Logger
 
11:10 AM
@nikita2206 disagree
 
because you don't ever need to test interaction of your object with Logger
so you don't need to mock it
 
@nikita2206 Nope but you may need to swap it
 
on the other hand you probably want to have different loggers for different objects, that leads me to LoggerFactory::getFor($this);
 
so imo static is ok if and only if coupling is not a concern
 
11:12 AM
This way you can make it work pretty easily
 
@nikita2206 I would unit test logging too
 
But for libraries, that are meant to be used by anyone you have to have it as a dependency for sure
@SergeyTelshevsky it's like testing that second <span> tag in your html has an attribute style
just pointless and prone to changes in the code
 
@nikita2206 @Jimbo how would you implement a string formatting class that is used only in view/template files?
what's more important, how would you use that?
 
What exactly is the question? just class Formatter { public function formatBlaBla($foo) { return 'bar'; } } ?
or you don't like injecting it in the view?
 
What I say is that using it in the view file will be unreadable
remember your js developers will have to read and understand your code
 
11:23 AM
So I got an elePHPant :D
 
while having global state static class will remove all that hassle
 
@Amelia \o/
 
I think I borked codepad -_-
its back. Phew
 
hi. can anyone explain me this date format - 2014-10-16T18:00:00Z. What is the T after 16th and Z in the last.
 
ISO 8601 Data elements and interchange formats – Information interchange – Representation of dates and times is an international standard covering the exchange of date and time-related data. It was issued by the International Organization for Standardization (ISO) and was first published in 1988. The purpose of this standard is to provide an unambiguous and well-defined method of representing dates and times, so as to avoid misinterpretation of numeric representations of dates and times, particularly when data are transferred between countries with different conventions for writing numeric dates...
 
11:26 AM
@SergeyTelshevsky honestly, if you care about designers that much, why not use for example Twig? You can create "functions" that are mapped to the real php methods of the objects, so you will not have coupling and you will have cute templates
 
@PeeHaa thanks for the info .. i will go through it. Can we generate data in this format ?
 
yes we can
and np
 
@Sajal there's a constant in php
DATE_ISO8601
 
@nikita2206 so using this constant will return current date in ISO format ?
 
@Sajal date(DATE_ISO8601);
 
11:29 AM
@nikita2206 if you have the time to make these proxy methods then yes, but some tend not to use any template engines and use raw php
 
need a few help with pdo...
i have a php function, which executes a PDO statement, and return it... Something like
    myFunction($db,$type){
        $query = $db->prepare("SELECT * FROM table WHERE type=:type");
        if($query->execute([':type'=>$type])){
            return $query;
        }else{
            return false;
        }
    }
 
@nikita2206 thanks :)
 
@nikita2206 but how does this template "function" differ from a static method
 
@Julo0sS php room?
 
@Sajal T is the time/data separator, Z is shorthand for +00:00 (timezone, UTC in this case)
 
11:31 AM
@mikedidthis can you move it pls?
 
DATE_ISO8601 will usually return 2014-10-16T18:00:00+00:00 which is also correct in the standard
 
@SergeyTelshevsky I would say TRY IT =) but anyway, for the case of php as a template engine, you probably need some preset globals for all the templates... This formatter could go there. Or, it be a static class, I think it would be the same on the level of "badness".

template "function" is a function in terms of this template engine
 
@Amelia so how to get strictly this format - 2014-10-16T18:00:00Z
 
11:33 AM
hi all!
 
@Sejal: you dont need to.
 
if anyone could, check my previous post (moved by MikeDidThis), i continue my explanation here :P
 
@nikita2206 yes, creates same coupling but in scope of a template engine :)
 
You need to give an ISO8601 timestamp, the Z is not mandatory
 
then i have to use its result to "complete" another query
 
11:34 AM
@SergeyTelshevsky well, I agree with you that you don't unit-test templates
so it's fine
 
so what i'd like to do is :
$get = myFunction($db,$type);
$newGet = $db->prepare("SELECT * FROM table2 WHERE id IN($get)");
tought it was possible since the "$get" var is a pdo statement
but seems like its not^^
 
@Amelia i don't get it clearly. If you can give detail it would be helpful and save my googling time. I need to pass this date format to some 3rd party api - 2014-10-16T18:00:00Z. What date format should i use.
 
@Sajal you do not need the Z at the end.
use DATE_ISO8601
and you're done
 
@Amelia okk great. Thanks a lot :)
 
No problem~
 
11:40 AM
@Julo0sS What are you trying to achieve exactly?
 
ThW
@Julo0sS You can not just put an object as a string into another string.
@SecondRikudo it looks like he tries to use a prepared and executed pdo statement as a subquery
 
@SergeyTelshevsky It'd be a JavaScript class then?
 
@Jimbo depends, I tend not to do any formatting on JS side, I don't think it's right to use JS for anything but making your pages interactive
 
@SergeyTelshevsky You'd send a string to the server side, just so you can format it, and return it?
 
@Jimbo of course not, but if I want to format a string I got from database I would use PHP function for that
 
11:48 AM
@SergeyTelshevsky So you'd make a class for server-side, and your JavaScript developers would never see it
 
okay, have a look at this :
...somewhere in my code...
$ids = getIds($db,$type);
$data = $db->prepare("SELECT * FROM table2 WHERE related IN (:ids)");
$data->execute([':ids'=>$ids]);
... ...

function getIds($db,$type){
$query = $db->prepare("SELECT id FROM table1 WHERE type = :type");
if($query->execute([':type'=>$type]){
return $query;
}else{
return false;
}
}


What i try to achieve is to get a list of database entries that have, as value of a column, the value returned from the first query...
 
@Jimbo yes, they would have a small documentation
 
@SergeyTelshevsky Lol.. okay that's fine. Still, no need for global state..
 
@Jimbo I don't say it's teh bset way, but rather try to think of what would be a better use case for static classes than this :)
 
@Julo0sS You cannot bind an array
243
Q: Can I bind an array to an IN() condition?

AndruI'm curious to know if it's possible to bind an array of values to a placeholder using PDO. The use case here is attempting to pass an array of values for use with an IN() condition. I'm not very good at explaining, so here's some psuedocode to demonstrate... I'd like to be able to do something ...

 
11:56 AM
@PeeHaa lol i was reading the same page... :P
 
with implode its possible
select * from table Where column_name IN (".implode(',',$arr).")
maybe
oh :( the link
 
@argentum47 That doesn't actually bind params
 
Just used my first Abstract Class -_-.
 
what i did, was to put the ids into a string... so
foreach($ids as $id){
if($idsList!=''){
$idsList.=',';
}
$idsList.=$id['colName'];
}

Then i did in my query...

$db->prepare("blablabla IN(:ids)");
...->execute([':ids'=>$idsList]);

BUT result is NOT the result expected...
 
You cannot do that
 

« first day (1467 days earlier)      last day (3464 days later) »