« first day (1662 days earlier)      last day (3286 days later) » 

3:00 PM
I find this behavior to be disturbing.
 
@Jimbo @Andrea says that can happen IIRC on her site
 
@LeviMorrison Wait, what? So if you bound one parameter there (instead of the two indicated in the query) and tried to run it, you'd get an error. You don't get an error with NO parameters bound?
 
Assuming the note is correct then yes.
Haven't tested yet.
 
what happened to the nullsafe method calls RFC?
 
It fizzled, I suppose.
And honestly I'm really glad.
 
3:04 PM
heh, hack has it now
 
It was proposed by a member of the HHVM/Hack team :)
 
oh really? I liked it
#weCantHaveTheNiceThings™
 
$why?->are()?->you()?->chaining()?->so()?->much()
 
do you know the reason it failed?
 
Additionally, who says that just returning null is even desirable behavior?
The whole thing seems like it's designed to make bad code easier.
And not just any bad code, but some specific kind of bad code.
 
3:08 PM
sometimes it is, but you are thinking about very specific bad code on purpose
 
You know what I wouldn't mind?
class FooBuilder {
    public function __castTo($type) {
        return new Foo();
    }
}

function bar(Foo $foo) {  }

bar(new FooBuilder()); // valid
Errybody commence fun-making
 
new Global()
 
You mean you want C++'s automatic constructor and cast operator overloading?
 
Essentially? Probably.
 
3:10 PM
O_0
 
why does castTo recv a type and ignore it ?
 
It's sometimes useful, yes.
 
@JoeWatkins I just ignored it in my example.
public function __castTo($type) {
    if ($type === 'Foo') return new Foo();
    if ($type === 'Bar') return new Bar();
}
public function __castTo($type) {
    if ($type === 'int') return $this->someIntegerProperty;
}
 
^ use instanceof, $type should at least be a FQname when it's a class
 
No, the callee shouldn't care (IMO) Wait, what?
Fair enough, Foo was in the global NS ;-)
 
(\Foo\Bar) $bazInstance :D
 
if it existed, we would complain that the code is wrong, that the programmer should be hinting for and implementing an interface ...
 
I'm voting to close this question as off-topic because Power Rangers are so 1994 — Dan Lugg 30 secs ago
 
@JoeWatkins Or intersection types for those familiar with algebraic type systems.
 
@LeviMorrison I'm assuming intersection types are familiar to union types?
 
3:18 PM
// If it implements Countable and Iterator it's good to go
function foo(Countable&Iterator $iterator);
 
@DanLugg function test(BazInterface -> BazImplementation $foo){}
 
Really, the builder-to-built trick is a side-effect of just wanting __castTo for dumping to scalars.
 
on the PHP game when you don't like something you use the feature-encourages-bad-code card
 
@Worf And what would the effect of that be?
 
@marcio You are not wrong.
 
3:20 PM
there are arguments against casting to scalar that stand on their own, such as if the data was representable as a scalar in the first place, it would not be abstracted by a class
 
@LeviMorrison the most abused card evah ;-)
 
@JoeWatkins Except where you wish to provide operations on that scalar.
(float) new Money()
 
@DanLugg something like this:
interface X{ function hey(); }

class XImpl implements X{
    function __construct(string $a){$this->a = $a;}
	function hey(){}
    static function __box($a){ return new XImpl($a); }
}

function someTest(X @ XImpl $x){ $x->hey(); }
someTest("foo"); // works
 
I don't understand why the wonky syntax is necessary there.
Oh, wait okay
 
because X is an interface
with @ XImpl you pick the preferred implementation
 
3:25 PM
I don't know how I feel about that, which probably means I don't like it but haven't realized it yet.
 
but i don't like that anymore. would be a mess with mixed type hintings function(int|float $x){}
 
@Worf don try to re-purpose @
 
Well, TBH, I think that inline union types should burn in a hole somewhere.
 
@marcio :P that is and forever will be the stfu operator
 
    function f(int|float $x); // NOOOPE

    type numeric { int, float };
    function f(numeric $x); // awesome saucem
 
3:28 PM
typedef numeric = int | float;
 
it sux, verbose
interface A{ function foo(string $x); }
interface B{ function foo(int $x); }
class C implements A, B{
function foo(string|int $x){} // epic win
}
 
Anonymous
whats this php?
 
works well with future features like generics
 
ttj
how do i set up php to work with livereload?
 
@marcio What's with the desire to use the pipe?
 
3:29 PM
@LeviMorrison wouldn't the type something = int | float be a huge wtf because constants?
 
@marcio I don't understand what you mean.
 
@DanLugg inclusive or - bitwise
 
Yea, but still. Why not follow some semblance of uniformity?
{ comma, delimited }
 
@DanLugg Because it is literally a union of those types. In other words, it is an int or float.
 
@LeviMorrison oh right, we can't have constants named as int | float etc
 
3:31 PM
Meh. Syntax schmyntax.
 
@DanLugg because you might end up having function x((Foo | Bar) & Baz $x){}
 
^^
 
but how would type OtherSomething = Something | SomethingElse; behave if there is a constant named "SOMETHING"?
 
@DanLugg i wasn't joking :P afaik that is an actual thing in several languages
 
interface Foo { }
class Foo1 implements Foo { }
class Foo2 implements Foo { }
class Foo3 implements Foo { }
function f ((Foo & ~Foo3) $foo) { /* Foo3 is a poopy implementation */ }
 
3:34 PM
@Jimbo that happens and there's nothing I can do about it
my best advice is "use Firefox"
 
@marcio It wouldn't matter. Why would it matter?
You can't use "constants" in type expressions – only types.
 
@DanLugg can you give a piratical example of how this is going to be used
 
@DanLugg imagine this:
interface Comparable<T is string | int | float | bool | object>{ function compareTo(T $other); }
class X implements Comparable<Foo>, Comparable<Bar>{
    function compareTo(Bar|Foo $other){}
}
 
Heey =]
 
sup @RonniSkansing
 
3:39 PM
Just home from work, feeling abit tired
you?
 
nevermind. Will we be able to:

use A\B\C\D\Foo;
use A\B\C\D\Bar;

typedef X = Foo | Bar;
// or
typedef X = Foo::class | Bar::class;
 
@marcio The latter doesn't work because they aren't stringly typed.
The former does.
 
@RonniSkansing i work from home, but same :D (working from home is not as good as i thought it was :P)
 
@LeviMorrison ok, the former is definitely the preferable
 
when I close my web browser and open it again, facebook keeps logged-in, however php sessions are actives until the web browser closes. how is it possible ? cookies ?
 
3:43 PM
yes, cookies
 
user image
4
 
that means if i get the cookie of someone, i can easily use his/her account right ?
 
in theory, yes
 
or is there a mechanism that ensures another layer of security ?
 
@발렌텐 there isn't. Well, there's https
 
3:46 PM
well i don't have money
 
interesting @FlorianMargaine
 
and maybe soon letsencrypt.org
 
but again, ssl is not really going to protect user from cookie-hack. If I get my friend's facebook cookies and copy them on my computer, i'll still be able to see his account
 
@발렌텐 And how do you think you get the cookies in the first place?
 
3:50 PM
usb keys rocks!
 
@발렌텐 you are looking for the term "session hijacking", you can do many tricks but only real protection is HTTPS and prevent XSS
 
(removed)
 
fake ↑
 
@발렌텐 @발렌텐 no I do not think so
session can easily be checked if it has the same ip, browser or etc
 
anyways thanks for your supports everyone :-]
@RonniSkansing yes I guess cookie is not just the only layer of facebook's security hihi.. gotta be an algo right there
 
4:05 PM
posted on May 05, 2015 by kbironneau

/* by adfleshner */

 
This answer is still getting upvotes: stackoverflow.com/a/907821/538216
Upvotes means more upvotes! Yay!
Let's just ignore the giant warning box and complete lack of explanation.
+1
 
Anonymous
@LeviMorrison why can't you just edit and correct the mistakes?
 
@samaYo Sometimes people will say "make a new answer and if it's better it will rise to the top"
Soon it will have been one year and my answer still won't be on top. That's even with a lot of campaigning in this room.
This is an example of that idea failing. It doesn't rise to the top. Upvotes beget more upvotes.
 
Anonymous
Yeah, since most people tend to upvote the first answer they see. It does not need to have a warning, if it is inacurate. I would just remove / improve it.
 
4:17 PM
It's not inaccurate: it's insecure.
Additionally it doesn't explain anything. "Just do this"
I found this in the bad question/answer queue lol
 
Anonymous
Yeah, compared to your answer it has no real value.
 
Anonymous
but that's SO :)
 
It's basically the same as a bunch of bad answers all mucking around at the bottom.
 
Anonymous
Apart from that, you should be awarded a badge for the total number of (16) edits to your answer. :)
 
I upgrade it every time someone gives me feedback.
^^
 
4:21 PM
@LeviMorrison feedback: Put the pdo answer first and not in the same code block
 
Anonymous
Not sure but I read once, that too much edit can convert an answer jnto some kind of community-wiki type answer thing.
 
So people don't think this is complicated or something
 
Anonymous
+1
 
Also, as a side note: I feel like the API for prepared statements should be different:
$db->prepare($query, ...$params);
Seems like you should provide the number of arguments at the same time to ensure correctness (kinda like printf)
I understand there is a difference though, since you can reuse the prepared query and execute it multiple times with different parameters.
 
@LeviMorrison That
Conceptually at least it makes sense, though I agree that most of the time you'll want to run it right away and only once
 
Anonymous
4:36 PM
I guess it means using ->prepare() like this github.com/samayo/Leaper which is already too common among with pdo wrappers these days.
 
hello i am trying to echo name in php value example - <?php header('Location:verify.php?user=<?php echo $name; ?>'); ?> but i am unable to do that anyone can tell me how can i echo name there?
 
Anonymous
Some may argue it is not a good idea, to further minify the-already-small pdo api :/
 
@samaYo Except instead of an array of values it uses the parameters.
(I mean if I were to do it)
 
Anonymous
@LeviMorrison Hm, I think it would be cool.
 
Anonymous
And probably very simple to implement too. If only I had the know-how, I would write an rfc for it.
 
Anonymous
4:45 PM
@SukhchainSingh why? the Location: attribute is used for redirecting, just use $name if you want to send the header i.e. redirect to page $name
 
Anonymous
Also, use an absolute path for the url
 
hello my problem is solved now i used - '.$name.'
 
@JoeWatkins Some people just don't see PHP as anything other than the children's glue that holds together guestbooks and visitor counters.
Sometimes I wish I were one of those people ... lol
 
@JoeWatkins now I totally lost any need to discuss with him. Had some decent discussions in the past, but that's totally ridiculous :-(
 
4:57 PM
HTML parsing is farking hard
@JoeWatkins what's going on man? Haven't talked in a while, how are you doing?
 
yeah I've read some not totally ridiculous comments from him before too @Ocramius
@ircmaxell I'm good, thanks for asking ...
 
@JoeWatkins how's the family?
 
@ircmaxell all good too :)
 
always good to hear
 
we look pretty happy :)
 
5:16 PM
:-D
workingworking on anything fun?
 
I'm using lampp in ubuntu. How do I set the password to the mysql database using phpmyadmin? Where is the password stored.I checked conig.inc.php ? Any help
 
@ircmaxell well, I'm just starting to research something new, its not super exciting, a different kind of sapi ...
 
@psychoCoder Don't put any passwords in your phpmyadmin config. Configure it to prompt you every time and enter it every time. Serve it only over https and add an HTTP auth in front of it.
 
So it is making things a little difficult. Although I've store the connection in a new php file and importing it every time. But I was thinking is there any way i can set a password to the mysql database (in phpmyadmin).
@Charles Actually I don't have any password set for phpmyadmin. The problem is I'm doing some project with a team. Everyone has 'root' password set for their phpmyadmin. So everytime I want a connection to the database , I have to change the connection settings (password) .The connection is made to mysql database from php web pages.
 
@psychoCoder So, you want to use phpmyadmin to create a new username and password your application can use to connect to mysql?
 
5:27 PM
Don't use root for phpmyadmin :p
 
@JoeWatkins oh yeah? what type?
 
@Charles @ChrisBaker This is the config file hastebin.com/osebulomuc.php . The password is root here.
what if I want to remove the password
I want to change the settings so that I don't have to put the password in the connection.
 
@psychoCoder Create a new user and then use grants to give them access to the database... and then never use root again.
 
@ircmaxell I'm not exactly sure what it will look like yet, the basic aim is to skip rinit/rshutdown for every request, and hand over control of that stuff to the programmer (to the extent the zend api will allow), so that a request is no longer rinit, code, rshutdown, but just code ...
I'm aware, a lot of code won't work this way, I'm aware no legacy code will, but I don't care, we're looking to the future ...
 
@Charles So if i create a new user and provide him required previliges , I can use this to make changes in the database .
 
5:32 PM
@psychoCoder Yes. Do that instead of using root.
 
@JoeWatkins True FastCGI style, I assume?
 
@Charles This query CREATE USER . from where do i execute it? From phpmyadmin
 
@LeviMorrison I am not sure ...
 
because to execute this query from inside the webpages i need a connection to the database.
 
@psychoCoder Yes, from phpmyadmin. Look for the SQL tab. There are other ways, but learning the commands is easiest. Good luck.
 
5:34 PM
@Charles I'm not sure how to do that
 
@JoeWatkins Each worker does a bunch of setup and then does a loop calling FCGI::accept()
 
yes... I know how to run sql queries from phpmyadmin. Is there any way I can run these commands from the webpages
 
(Well, not necessarily a bunch – just whatever your app needs)
 
I don't know why I avoided composer for so long. Irrational rejection of new things, I guess. It is embedded in my personality to reject pop culture :p
 
oh I know how fcgi works, I'm just not sure what it will look like yet at all...
 
5:35 PM
@Charles
 
@ChrisBaker I'm okay with composer. I just hate that everyone seems to architect their setup/install to be entirely reliant on it.
 
@Charles because see the problem is every time I'm creating a new user and granting the permissions , doing this manually is not feasible
 
I shouldn't need composer to use your software.
 
Quick question for whoever wants to throw out an opinion: I need a *fast* way to generate request IDs that need to be "unique-enough" to track a log path, but a collision happening in the same week or so wouldn't really matter.

What would be the best tradeoff for unique-enough and fast for something like this?
(In other words I don't need these to be cryptographically securely random)
 
@LeviMorrison hrm, just had more fallout from your static closures change :/
 
5:38 PM
md5(uniqid(true)) [:troll]
 
@NikiC :/ Example?
 
@Rican7 Why not ^ ?
It's fast. It's uniquish. It does what you are asking
 
@Rican7 just go with a UUID?
 
Ha, yea, that's what I was thinking... I just wasn't sure if it'd be unique enough (I don't know much at all about uniqid() )
 
@LeviMorrison I was fixing self::class support in closures (so it supports rebinding), but it doesn't work properly as self::class will be interpreted as static::class, because the scope for static closures is now set to called_scope
 
5:40 PM
Depending on where the code is running, uniqid is not unique enough. On a windows box, there's only second precision, so you get collisions happening left and right.
 
Second?
 
@NikiC We don't allow rebinding of closures created in classes (not historically)
 
@ChrisBaker I stopped at "windows"
 
Rather than millisecond
 
Errr I haven't ever seen that :(
 
5:41 PM
@Ocramius Meh, you don't always get to choose your deployment or development environment
 
Honestly I would love to throw out our closures and redo them.
 
@LeviMorrison we don't? If it's created in a non-static method we allow it, right?
 
@NikiC Not that I am aware of.
 
@ChrisBaker you pretty much always get to chose the job :-P
 
Keep in mind it's getting to the point that my memory is very unreliable though ^^
 
5:41 PM
@LeviMorrison pretty sure we do. wouldn't make sense otherwise
 
I thought it was kinda somewhat based on microtime? @ChrisBaker
 
Given how pretty much all php code is in classes the rebinding feature would be useless otherwise
 
I was using it in a query generator for the placeholder names. Code worked great on the production server. I had to move to a WAMP box for a few weeks, and shit is bombing everywhere. It took me a bit to find why my queries seemed to be failing.
 
/me opens man pages
 
@NikiC Essentially, a closure in global scope is different than one creating in a class scope.
IIRC
This was true before my changes.
 
5:42 PM
@LeviMorrison I'll have to look at this more closely and see what we can do to make this somewhat consistent
If it's possible at all ^^
 
And keep in mind all sort of LSB stuff didn't work correctly before my changes.
 
Nothing in the manual about it. Who maintains this thing??
 
Honestly I think we need to rework closures, @NikiC.
 
meh class Get implements \ArrayAccess { ctor( Array $t->get => $get ....
 
@LeviMorrison Any particular wishes?
 
5:43 PM
@PeeHaa Between that and the fact that money_format is completely just not defined on Windows.... grumble grumble. At least the situation with money_format is documented.
 
how far away from a php7 release are we?
 
@NikiC Practical or wishlist?
 
@RonniSkansing first alpha is tentatively scheduled for in ten days
 
@LeviMorrison preferably practical :)
 
5:44 PM
\o/ yay! much closer than expected
 
lxr.php.net/xref/PHP_TRUNK/Zend/zend_vm_def.h#7782 … why is this case UNEXPECTED()? I thought object type hints always were most used hints…
 
> Since it uses mt_rand(), it is still cryptographically secure.
 
@PeeHaa @ChrisBaker yea, I need this to be able to run for multiple auto-scaled machines without collision in the same second. :/
@Danack haha, facepalm
 
@ChrisBaker Am I missing the relevance?
 
@bwoebi This is not for type hints but for is_object()
 
5:46 PM
oh… thanks -.- ^^
 
@NikiC static and self are fully supported and rebindable. After my changes to make static work there were some side effects like declaring $this in a static closure meant that it would error at compile time.
 
@PeeHaa Yes, that wasn't the comment I thought it was :p
 
Either way that looks like something that should be fixed. This is stupid
@ChrisBaker hehe
 
Declaring a closure in any scope defaults to that scope (or no scope if it is global) and binds the closure if $this is used (not bound if no $this present) and there is something to bind to.
 
5:47 PM
That too
 
class Factory {

    static function make() {
        return function() {
            return $this->property;
        };
    }

}
@NikiC In my opinion this should work.
Ideally we remove static closures completely.
If you don't use $this then it's inherently static, or if you use self or static or parent it's static.
 
@LeviMorrison and what's $this referencing to when called? … or do you mean in combination with binding?
 
@bwoebi If you call Factory::make()() you'll get an error.
 
I am failing to see why it shouldn't work on windows :|
 
@LeviMorrison yeah, agree with doing something like that
 
5:51 PM
@PeeHaa uniqid?
 
@NikiC I think this works currently but there is some case where it doesn't.
(something similar)
 
If so, I found the comment I thought I was linking to... but it isn't a comment on php.net, even though the answer says it is. stackoverflow.com/a/4070285/610573
 
I'm trying to remember.
:/
 
@LeviMorrison fine for me
 
@ChrisBaker Yes. I don't understand why it isn't fixed
 
5:52 PM
Wait… that's not what I meant to write.
(I meant to comment out $m())
I'll keep trying. I know there's something that's broken that should work.
But all of these things I've posted should still work too
Related: bugs.php.net/bug.php?id=69568 /cc @bwoebi @NikiC
 
@PeeHaa I notice that a lot of discussion surrounding anything related to random anything is all about whether it is cryptographically secure or not. Since uniqid is not regarded as secure, it's almost as though there is a culture of neglecting it or writing it off as useless.
 
(Which I think is a duplicate of bugs.php.net/bug.php?id=68194)
 
@LeviMorrison looks like there's no scope binding for implicit static closures…
 
All I want out of the damn thing is a unique string, not for cryptography, but for HTML or query building, something like that. To that end, a function called uniqid just needs to give me a fricking unique string, doesn't seem like it would be hard.
 
I don't even want it to be actual unique (although that would be nice). I would settle for it just working on windows as stated on the box :P
 
5:56 PM
@LeviMorrison Do you mean this? 3v4l.org/FObAA
The "cannot bind" error
 
@LeviMorrison waiiit… I thought protected only works the way up, never the way down?
 
@NikiC Yes, I believe that's correct.
 
I am building a monster
 
@bwoebi I was looking at this more too. It is more nuanced than I originally thought.
 
That would be a good start
 
5:57 PM
The reason is Right is accessing Left; which it doesn't have access to.
This means I actually fixed another bug \o/
 
@PeeHaa @ChrisBaker exactly! I don't need anything cryptographically securely random, I just need a random "ID" for a request log trace...
 
(Take that, stupid haters)
 
@ircmaxell but a nice monster, yea?
 
@Rican7 For that usecase, even though it looks a little silly, something like this does do the job: pastebin.com/eDZbFGEu
 
ha, yea, except I'm doing it in a PHP-FPM context, so the function will only be called once (a static counter doesn't help here)
 

« first day (1662 days earlier)      last day (3286 days later) »