« first day (1591 days earlier)      last day (3583 days later) » 

16:00
7 mins ago, by NikiC
you need to generate code to validate the string and raise an error or perform a cast
@FlorianMargaine Well in your example we could tell you at compile time that your code sucks and you should feel bad and based on that not even bother to compile it ;) See, strict types can completely optimize your code away :P
Anyone use twig and know how I can use a variable, by it's name in a string?
but the point still stands
Btw, that was totally serious.
16:02
I'm pretty sure it will be widely used though
That code is essentially equivalent to "throw exception" with strict types.
function getId(): int {
    return idFromDatabase();
}

function idFromDatabase(): string {}
it works in coercive mode
Bleh
string conversions are my least favorite part of PHP's type juggling
@Jimbo twig.sensiolabs.org/doc/templates.html#string-interpolation maybe? - But I don't recommend doing that.....concatting stuff to a temp var is probably going to be less rage inducing later....
@FlorianMargaine you're asking for a one-sentance explanation of a lot of tradeoffs and complex machinery
16:05
@Danack effectively an eval?
a couple sentences is fine... you got the idea
also, I loled after seeing the image again: cdn2.www.basereality.com/image/917/original/110.jpg
@Jimbo All of twig is effectively an eval right? Which is why I prefer not to use it.
@FlorianMargaine a quote from relativity for dummies, no doubt ... oh ... wait ...
Hey, stop increasing my S3 Cloudfront bill!1!
@FlorianMargaine there are complex tradeoffs at play. I don't want to simplify it further than necessary because that hand-waves over those tradeoffs
just like Zeev is handwaving over them, while I am trying to make them explicit
16:09
I think you should give up ... he is not listening ... I am giving up ... bravely ...
@FlorianMargaine I'd say that, essentially the difference is in how often the AOT/JIT compiler will have available reliable type information and what kind of code it needs to generate if it doesn't.
when is this all gonna be voted on ?
@FlorianMargaine E.g. by using type backpropagation from the callsite of a function with known strict types, you will know what type a variable must have in order to not trigger an exception. You will be able to insert a guard for this at one place and assume the type everywhere else. With weak types you will have to generate code that can handle all possible types for the variable everywhere it is used.
sigh, mwops post re-iterates a lot of falacies about the existing proposals
@FlorianMargaine complexity of the implementation, and of the code it needs to generate (complex means slower and more fragile)
apparently it's only us that thinks more complex means more fragile ...
16:16
Fair enough, thanks @NikiC @ircmaxell
Morning again room
And I agree, more complex = more fragile. No one can deny that...
Zeev is having a good ruddy go at it ...
he's probably convinced some people it's true ...
he convinced Matt
and it fucking kills me, because 80% of what Matt said misrepresents both RFCs
16:24
hm wondering if i should write a mail thread about the game theory of the two RFC votes on the same topic
first mover looses imho
it will be 50/50 split now, so no RFC gets more than ~50% votes, however since everyone wants some kind of type hints, the last proposals will get the "i dont care give me type hints" camp again, pushing it over 66% ;)
unless I keep voting open until the end of the second RFC...
in this case votes will split 50/50 on both rfcs, making none of both pass
user924016
Moorning
@Ronni Morning :)
16:31
Zeev's scares the crap out of me, because nobody realizes that it's giving us another INI setting (or breaking BC significantly)
i'd prefer the BC break to the ini setting, but only because then w edont have an ini setting
we do have a python2/3 situation though
time for php 5.7 again?
So we need to cheat: a) do we want STH (2/3) and b) which STH RFC do we want: Anthonys, Ze'ev's or something else (option with most votes wins)
Then we probably get some winner…
but not sure if it's a good idea………
I just found some code where a guy calls a global array, counts() the array and uses that to "for(;;)" through it. facepalm
@beberlei Yes. I will definitely vote against Zeev's proposal if it changes internal function type checks as well. This is madness
16:34
@Fabor typical of php newcomers
Not a newcomer though
@NikiC yet nobody seems to realize that
I'm very much in favor of tweaking the zpp behavior in a few places (like wrt numeric strings with trailing chars), but just completely changing things, wtf.
@Jimbo ie reflection?
@Fabor At the point where he was using globals, did the rest of it surprise you?
16:35
Now, if the new rules only apply to userland functions - then I would think twice about it.
heh good point
@NikiC IMHO having a forked scalar type system would be a mistake as well
@CarrieKendall Not really. I pass three variables (var1, var2, var3) to my twig template that I want to access depending on a variable. Imagine I have {% set p = "var1" %} // I'd like to actually use var1 depending on p
hey @tereško . Why do you consider my post harmful ?
> So really, it's screw BC, screw consistent behavior between internal and userland behavior or install another fundamental behavior ini setting.
16:37
@Dracony because it argues for use of integration tests
and you consider those bad because ?
@Jimbo i don't really understand the goal. give an example of what you actually are trying to do ;)
because those tests are fragile and grow at geometric rate
@CarrieKendall return $twig->render('index.html.twig', ['var1' => 'HERRO', 'var2' => 'OMG ]);
^ In the controller
16:38
In the template, I have the string "var1"
I'd like to be able to get 'HERRO' because I have the string 'var1' (so variable variable)
@Jimbo actually, it SHOULD be in the view =P
@ircmaxell Also, I don't get people's attitude towards E_DEPRECATED
@NikiC what do you mean?
@tereško Those are still needed though. Hence the title that unit tests are not enough. It's not me arguing unit tests should be dropped out
anyway
To me, if code throws any kind of notice (which is not explicitly suppressed), it's broken code.
16:39
Can anyone tell me why can't an abstract class be overriden in a child class?
@NikiC Except code designed to throw notices ;-)
@Dracony because you are messing with visibility
@NikiC agree, especially since errors aren't free
abstract class A {
abstract public function a ();
}

abstract class B extends A {
abstract public function a ($t = false);
}
this seems like legit code
but doesn't work
you cannot change the method's footprint
16:41
@NikiC have fun with legacy code emulating register_globals :-)
@bwoebi We already know you don't care about code quality :P
why so? It's compatible
if I make that same method not abstract it works perfectly
@Dracony It only works perfectly if you fucked up your error_reporting settings
class A {
public function a ();
}

class B extends A {
public function a ($t = false) {};
}

this works perfectly
when inheritance is properly implemented, you should be able to use the superclass in place of derived class
16:43
@Dracony why would you redeclare the method abstract again if you basically already have it
I have my error reporting on E_STRICT
it should be on E_ALL
E_ALL && E_STRICT
@Jimbo maybe rethink the problem a little. what if you passed an array where the keys are the var names, then you can use it like arr['var1']
16:44
&
|
@CarrieKendall Nice! Good thinking, thanks :-)
also:
abstract public function a ($t = false);
the boolean parameter indicates that you should have instead TWO separate methods
a few personal mentions from the fabpot this morning eh?
@NikiC Funny. It's not my code…
@tereško well why it works for non abstract methods though ?
All i want is consistency
16:46
@tereško Interesting.
@Dracony You're right sorry. But in that case it even works if the parent method is abstract. What's the problem again here?
public function listMembers($reverse = false)
{
    ...
}
You'd make two functions?
@MattPrelude boolean flag usually means that the method has two different execution paths
I was thinking more like two returns.
@MattPrelude listNumbers() and reverseListNumbers()
16:47
return (true === $reverse) ? $members : rsort($members);
they can share functionality
so you'd remove the flag, then just implement a second function like...
@MattPrelude hi yoda
public function listReverseMembers()
{
    return rsort($this->listMembers());
}
ups
3v4l.org/4dJ44 the error for this is funny
oh nevermind, first function was supposed to be called b()
16:50
@NikiC Well it throws an exception, try running this:

abstract class A {
abstract public function a () {}
}

abstract class B extends A {
abstract public function a ($t = false) {}
}
arghhh
@MattPrelude I think your example is way too dumbed down for have any point. You acre currently arguing about getMembers() method
without the braces obviously
@tereško Any method which can return in asc/desc order, or keys/values?
I would typically use a bool param to those, to determine which way to go.
if you were writing a listing code, then you would producing the list in the correct order to begin with
16:51
the main question is why you can change the signature?
mm you did commen out the second overload in this example
I'm not arguing whether this is the "right" way. Rather I don;t see why it works for concrete methods and not abstract ones
@tereško There are places where you would want both orders. i.e. sort high->low or low->high
The reson I want to be able to override abstract methods like that is for btter documentation
that's because i wanted to show that there's no meaning to repeat the abstract function since it doesn't enforce anything, so class B already has the abstract method and overriding it or not makes absolutely no difference
@MattPrelude what the fuck are you talking about ?
your code is NOT PRODUCING the list
it is just re-sorting it
16:53
I omitted the database call...
one specific wordpress site too slow on localhost...works fine on server... other sites work fine on localhost... what gives?
But if there are 3 classes extending from B I would have to write docblocks for each of them
Thats what the ... was signifying, producing the list
instead of just documenting it in B
public function listMembers($reverse = false)
{
    ...

    return (true === $reverse) ? $members : rsort($members);
}
16:54
@MattPrelude if you want results from DB in reversed order, you change the query
your argument is invalid
well, that's another problem
I've been learning more vim commands over the last few weeks.
@tereško That doesn't affect the question in hand, whether I change the return or for example do
I realized I hadn't been learning any new ones in a while.
If you use vim and are currently not using vim windows I highly recommend it.
@MattPrelude ya know what, do what ever you want. I just run out of fucks to give.
16:55
$query .= (true === reverse) ? "ORDER BY lastName ASC" : "ORDER BY lastName DESC";
user924016
@MattPrelude ?
@RonniSkansing Boolean parameters to methods.
would wordpress even work when the coercive scalar type hints directly break everything in PHP7?
i doubt it
@RonniSkansing Debating the usefulness thereof.
16:57
guys... what would cause slow speed on localhost when other sites work fine and the site itself works fine on live server
@RonniSkansing or... were.
user924016
@MattPrelude ah.. sure.. are they usefull? Cause I think your hiding away information in the method call
@beberlei Are you the person who sent the game theory message on Internals?
@user3692125 Incorrectly configured hosts file.
user924016
listMembers(true);
user924016
16:58
@MattPrelude yea.. I have not considered this boolean args before, I will take more care about using them myself in the future =]
@LeviMorrison i am why? something wrong?
I do have virtual hosts set up for some of them and not on some of them...
@RonniSkansing They'd be more useful if PHP had named parameters.
could that be a problem?
@beberlei No, just making sure I know you are the same person. I have a notably bad memory ^^
17:00
@RonniSkansing Yeah, I see that now. Will probably do that in future.
@Dracony drop the abstract on the second one. Why do you declare an abstract method twice?
@LeviMorrison my nickname is shorterend version of b(enjamin)eberlei
user924016
@MattPrelude =] Sorry, somehow edited my last msg instead of writting a new
abstract class A {
abstract public function a ();
}

abstract class B extends A {
public function a ($t = false);
}
<b>Fatal error</b>: Non-abstract method B::a() must contain body on line <b>6</b><br />
hm, i should ask for adding my php extension (hdrhistogram) to pecl, i get a vote then \o/
17:02
I don't want to implement it in B
@Dracony huh, so why do you want to redeclare an abstract method?
The error is not due to the sig change, it's because you're redeclaring an abstract method
to change the signature
so how do I change the signature then?
@Dracony Why are you changing the signature?
to have consistency
elaborate example:
abstract class DatabaseTest {
public function setUp() {
$this->prepareDatabase();
}

abstract protected function prepareDatabase();
}
@Dracony you cant change the signature except adding params with = null, see en.wikipedia.org/wiki/Liskov_substitution_principle - php enforces this very strictly
17:05
forgive me for not being more familiar with php voting, but, what happens when there are multiple rfcs (with differing implementations) for the the same feature?
How do you get a vote on PHP rfcs?
@CarrieKendall undefined behavior
abstract class MultipleDatabaseTest() extends DatabaseTest{
public function testWithMultiple(){
$this->prepareDatabase(true);
}
abstract protected function prepareDatabase($wthMultiple = false);
}
@MattPrelude you need to be part of the php project, either core cnotributior, pecl extensions, phpdocs and so on
posted on February 23, 2015 by kbironneau

/* by pikfrik */

17:07
@MattPrelude or a community representative (undefined concept)
abstract class A {
abstract public function a ();
}

abstract class B extends A {
abstract public function a ($t = null);
}
this throws the same error
so idk what your point is @beberlei
@Dracony well redefining an abstract method doesnt work at all
@Dracony You shouldn't be changing signatures, or redefining abstract methods.
why?
it works for normal methods
how are abstract special?
I don't think it works for normal methods
17:10
@Dracony You shouldn't be able to change signatures on normal subclasses either.
changing signature that is
The point of inheritance is that you could use the objects interchangeably. If you change the method signatures, that's no longer true.
it works for normal methods
not for abstract
in any case, what you are trying is a liskov substitution principle vilation
@CarrieKendall if only one passes, you have an answer. If multiple, then we have a fote-off
17:11
PHP doesnt like it, prevents it
@Patrick you here?
If every child class has different method signatures, why are you using inheritance?
because he didn't get the concept right ^^
@ircmaxell oh, okay. so, i would assume this has happened before? does it happen often
I know, rhetorical question
17:13
> I don't see how that would affect PHP 7 adoption at all actually. You can just disable E_DEPRECATED and your upgrade would be clean. Technically it would have to wait to PHP 8 before we change it to E_RECOVERABLE_ERROR, give users several years to migrate. Given we're talking about coercive rules and not strict rules, I actually don't expect that many failures (initial tests of Francois' patch results in 8% failures in our unit tests,
> and that's before tweaking the rules in any way (and apparently, at least some of them have to do with bugs in internal functions that can be easily fixed). It doesn't strike me as a worse migration than we did getting rid of magic_quotes or safe_mode. It can be done.
@CarrieKendall no, and no
@ircmaxell thereby refuting himself again that this is only 1-2 years out there
We migrated off of magic_quotes and safe_mode because we realized they were a mistake. Is he really saying we should make a mistake again because we can fix it?
oh, well you know what assuming does
@MattPrelude these are compatible overloads though. They work perefctly with concrete methods
Hey @ircmaxell, can you take a look at reddit.com/r/PHP/comments/2wvvbw/… ?
Does that look like something that needs changing to you?
@Dracony Doesn't it generate a notice when you pass too many arguments?
17:17
@RonniSkansing You don't have experience with wp_remote_get by any chance? :P
it works perfectly fine with concrete methods
@Dracony because an abstract method defines a contract
@Dracony no, it raises an E_STRICT. it works, but not "perfectly fine"
user924016
@PeeHaa sorry nope, no exp.. most of my exp says it is often wise to not use the wp "api" =]
@Dracony if($object instanceof A) { //assume has $object->a() }
doesn't a concrete method define a contract in the same way
I mean from an OOP standpoint I shouldn't care whether the method is abstract or not or where it was implemented in the tree
17:18
@RonniSkansing Yeah I think their http client is fubar. It keeps timing out on local calls :|
I just define a typr and roll with it
Asshole wordpress
user924016
lol yea, do you need another box to test it with?
@ircmaxell Thought it would raise something.
Also such overloading works perfectly fine for interfaces! which also define a contract
17:19
please stop calling it overloading
it's extension
@Dracony no it doesn't
yup it doesnt
just checked
@ircmaxell Does it raise a E_STRICT pre-5.6? Because wouldn't that mean all functions relying on func_get_args() generate E_STRICT?
@Dracony show code
@ircmaxell I mean I agree that it does generate that error
just checked that
but why do that for compatible overrides ?
i am turning into Derick
17:21
@Dracony It's not compatible. One signature has one argument, the other has no arguments.
@beberlei You are?
@NikiC i feel the urge to rage against evrery subtle BC break that is undectable/non-fataling
In java I could at least do:
!
interface A{
public void a();
}

interface B extends A {
public void a();
public void a(boolean a);
}
thats overloading
not overriding
well php doesnt have that
17:25
nope
so I kind of figured the ability to add default values for parameters could be used to emulate the feature
so fuck me right?
and that is actually a good thing imo
you can work around it though
just make multiple methods =D
=(
makes me a sad unicorn
@Dracony It should make you a happy unicorn because PHP just prevented you from introducing an ugly design ;)
@NikiC ^this
17:34
alrighty, I'll go and try coming up with some nice method names for these cases
Quote: Not enough people realise that "method overloading" in Java is just a way of having multiple methods with the same name
wish we could have some of the java way though(
impossible without strict typing :o
especially when you have like 4+ params all of which canbe default
then you need a ton of method names inn php
a function with 4 params is a sign of bad design
if this sounds silly to you, watch this: vimeo.com/12643301
well actually, watch it anyway, it greatly improved the maintainbility of my code lately :)
(there is legitimate reasons for using 4 or more parameters, escpecially in constructors but I don't think that applies to your use case)
17:38
my case for now is purely theoretical
I can definitely see cases with functions that have a lot of optional parameters
like in python urllib
where you have a function that does an http request and a buch of optional parameters like headers and stuff
but python has named arugments, making this less painful
in php you design apis differently from the beginning
@Dracony well you could simply give it the request, the request has a header bag, and so on, you don't need more than 2 or 3 arguments and it helps with testability and loose coupling
by the way, you know why PHP allows trailing characters in numeric strings?
because someone intentionally restored that in 5.2 or something
@Andrea WHY
@Charles ask whoever did it
17:48
what do you mean by "numeric strings" ?
"5.6" ?
"0xABC" ?
ah sry my english.. leading != trailing ^^
I think I got it now ;)
@Andrea I will not ask. Instead, I will beat it out of them.
@Andrea oh heow I hate that stupid "feature"
@Andrea orly
current status: "Please wait while your phone is being encrypted. Time remaining 19:30"
17:53
Phones. We don't need phones where we're going.
/me needs to work on his Doc impersonation skills.
@MarcelBurkhard the guy in that video has the most annoying voice ever
he sounds like a valley girl on a shopping spree

« first day (1591 days earlier)      last day (3583 days later) »