logs archiveIRC Archive / Freenode / #php / 2015 / September / 4 / 1
kkspy
Can't wait for PHP 7
choki
can't wait for security issues in php 7
zap0
kkspy, what are you going to do?
kkspy
choki: I don't believe there will be any. Code analysis is too good these days.
choki
:D
kkspy
zap0: anonymous classes, $a ?? false
jkoudys
can return types be set to return static, so it'll make sure that whatever the method returns is the same class as this?
kkspy
jkoudys: I can't understand your question.
zap0
kkspy, i meant, what are you planning to do in the meantime?
         

kkspy
zap0: open RFC in my browser and fap fap fap fap
zap0
are you running 7RC1 ?
kkspy
zap0: not yet
jkoudys
kkspy, `function foo(): static` is how I'd try to write it
zap0
but you said you couldn't wait..
kkspy
But I need a stable release to use it in production.
It's a figure of speech, of course I can.
zap0
but you are waiting... i don't think you understand the concept of can't.
kkspy
It means that I am eager to switch to PHP 7.
Alphos
jkoudys what are you trying to achieve exactly ?
zap0
what makes you think someone else calling it non-RC makes it 'production' ready for you?
jkoudys
Alphos, I'm trying to set a return type to the same type as the calling class
Alphos
jkoudys can't be done. you can return $this though
jkoudys
Alphos, thx
LawnGnome
I didn't know this myself (slightly embarrassingly, since I wrote that bit of the manual), but it appears you can use "self" as a return type in PHP 7.
django_
anyone using netbeans?
trying to refresh the ide but this doesnt work: http://stackoverflow.com/questions/4441000/how-do-i-refresh-netbeans-workspace
LawnGnome
jkoudys
LawnGnome, now that's interesting! Thanks dude
kkspy
LawnGnome: but how does it work? 'instanceof $this' ?
LawnGnome
kkspy: It's just shorthand for "whatever the name of the class you're defining the method in is".
Alphos
ooooh, new syntax !
         

jkoudys
LawnGnome, that's mostly what I want.. any child class will be an instance of the parent by definition, though it'll miss cases like static functions that return `self`, when I really wanted them to return `static`
kkspy
LawnGnome: get_called_class() or __CLASS__ ?
LawnGnome
kkspy: __CLASS__
hassoon
__NOPE__
jkoudys
I think that's a really readable syntax if you're building a class with methods intended for function chaining
kkspy
LawnGnome: that's a pity, get_called_class() behaviour (static) would look much more reasonable there.
jkoudys
since it's immediately obvious that anything : self is chainable
LawnGnome
jkoudys: Yeah, that would be an obvious addition down the track. Bear in mind that some of the possibilities for return types haven't been implemented in 7.0  at some point I assume some concept of covariance will be added, so I would suspect it'll get revisited then.
jkoudys
LawnGnome, covariance would be nice. I like anything that replaces excessive PHPDoc patterns that everyone was doing the same way
kkspy
jkoudys
LawnGnome, though for me, nullable return types should be the main thing to push for
ecart
how do I make such a number : 12312312312
stay like this:
123123123-12
123.123.123-12
this
jkoudys
we can sorta nullable our type hints, but a lack of it on return types really limits a lot of very useful patterns. e.g. a `isUserActive(): boolean` method is nice since that's a clear true/false, but `getActiveUser(): ?User` would also be wonderful, since then it would return a user if they're active, or a null if they're not
works marvellously in hack
kkspy
LawnGnome: get_called_class(), not __CLASS__ actually :)
ecart
how do I make such a number : 12312312312 stay like this: 123.123.123-12?
kkspy
Essentially 'self' checks it like: if ($return instanceof $this)
jkoudys
kkspy, did you check the actual opcodes to figure that out?
kkspy
jkoudys: nope, why?
jkoudys
kkspy, well you could compare and see if the return-type hint is actually executing get_called_class() underneath
I've been pretty surprised about what I've seen around instanceof behaviour
AcidReign
ecart: preg_replace( '~(\d{3})(\d{3})(\d{3})(\d{2})~','\1.\2.\3-\4', '12312312312')
ecart
chunk_split no make this?
;/
i like chunk_split please
^^
AcidReign
ecart: then use it
ecart
i dont now know
Sammitch
`php -r 'var_dump(-2**2);'` produces: int(-4) :I
AcidReign
www.php.net/chunk_split
ecart: it's not going to do two delimiters, like you have
ecart
I 've read says to do.
bwoebi
Sammitch: I see no reason why - should have a higher precedence than ** ...
caffinated
ecart: http://codepad.hashphp.org/FpN7xM if you *really* don't like it...
but honestly, regex.
Sammitch
bwoebi: subtraction shouldn't, but negation should :I
ecart
ok
thank you
^^
bwoebi
Sammitch: why? to confuse people?
caffinated
in other news, variadrics rock for sprintf()
Sammitch
bwoebi: imho the current state is the confusing one
I certainly don't mentally expand -2 to -1 * 2
AcidReign
caffinated: so they can drop vsprintf
Vooloo
how do I solve conflicts if two traits have the same method?
mmazing
Sammitch, what should (-2**2) produce ?
Sammitch
mm imo 4, but as-implemented -4
AcidReign
caffinated: but my custom "asprintf" is probably still relevant...
caffinated
AcidReign: they could, i always forget that it's even there
bwoebi
Sammitch: btw. that's always that way& also when written on paper, you apply negation last.
caffinated
I just think variadrics change the game for those types of functions
AcidReign
at least until they come up with a sprintf like string format tool that takes assoc arrays
caffinated
AcidReign: easy enough to write
mmazing
Sammitch
bwoebi: I suppose people internalize that differently.
bwoebi
mmazing: where exactly in that article is that written?
caffinated
i'm not sure why that article would be relevant to php
mmazing
bwoebi, under "Programming Languages", unary operations come before multiplication, etc
caffinated
php's order of operations is all that matters to php.
ecart
AcidReign
Parse error: syntax error, unexpected '.' in php on line 8
mmazing
caffinated, bwoebi said it was common practice, i'm saying that it's not
caffinated
fair enough
bwoebi
mmazing: yes... binary - < * < unary - < ** is order
mmazing: there's just no ** in that table
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 next »