« first day (1465 days earlier)      last day (3488 days later) » 

7:01 PM
@LeviMorrison Not throwing an exception also has the benefit of not having to add more exceptions to the core of the language.
 
the machine crashed 51 minutes ago ...
 
@TumblrGuy indeed... could you add that as a comment?
 
I bet in hell, there's a room where all you do is wait for RDoc installations to complete.
 
lol
 
And I'm starting to become concerned that I'm there.
 
7:22 PM
Wow, Ruby (Sass) just BSOD'd my machine.
 
heh. BSOD.
old times.
 
@DanLugg BSODs are due to kernel-level stupidty, like bad drivers or failing hardware. The likelyhood of it being ruby alone is tiny.
 
Well, it was presumably initiated by Ruby.
That is, whatever indeed caused the fail.
 
Bad memory maybe.
 
Hope not, new-ish box.
 
7:26 PM
better pop memtest on it overnight...
 
Okay, let's say I have this method declaration:
function foo(Bar $b){}
I have the parameter $b as a ReflectionParameter.
From what I can tell, the way to know that $b has an object type declaration is basically !isArray() && !isCallable().
Or alternatively getClass() !== NULL
Is that correct?
/cc @rdlowrey @DanLugg @Danack
 
So you want to know that $b has to be an instance of Bar?
 
Not even an instance of Bar. Just that it's an object type.
 
is_object?
 
I have no idea...Auryn appears to be doing the getClass().
 
7:40 PM
@LeviMorrison Sounds correct to me; $r->getClass() !== null is what I do.
 
I prefer $r->getKind() === $r::IS_OBJECT
 
^^ Literally was about to say, much better.
 
I could maybe be persuaded to have an isKind($kind) method.
So you can do $rt->isKind(ReflectionType::IS_OBJECT)
Would also allow $rt->isKind(ReflectionType::IS_OBJECT | ReflectionType::IS_ARRAY)
Dunno how I feel about that. It's definitely better than $rt->getClass !== null
 
Whether bitflags or not, it'll be better
switch($r->getKind()) {
    case $r::IS_ARRAY:
    case $r::IS_OBJECT:
    case $r::IS_CALLABLE:
    default:
}
 
Also... let's say we don't know if it has a type declaration.
I have reviewed the API, please correct me if I'm wrong, but to know that it doesn't have a type you have to do:
!$rt->isArray() && !$rt->isCallable() && $rt->getClass === null
 
7:50 PM
!$r->getClass() && !$r->isCallable() & !$r->isArray() ^^ Yea.
 
That's just horrible.
 
I'd say.
I think "that's" can be extended to reflection in general ;-)
 
Yeah, I'm really glad I didn't just commit simple reflection support and call it good.
This is just bad.
 
@DanLugg omg NOT AGAIN
@LeviMorrison eventually isType($r::IS_ARRAY | $r::IS_CALLABLE)
or stuff like that
 
@Ocramius WHY ARE YOU YELLING?
 
7:53 PM
@DanLugg BECAUSE IT'S SO SILENT IN HERE!
 
OH OKAY! TO WHAT WAS THE "OMG NOT AGAIN" IN REFERENCE
 
TO THE STRIKED MESSAGE!
 
Okay, so I rewrote the section on Reflection; thoughts?
I just restructured that section, so you gotta refresh if you already had it loaded.
 
@LeviMorrison There's no issue between an 'IS_OBJECT' that is invokable also being 'IS_CALLABLE'? Also that may suck a little in PHP(7+x) where arrays are objects.
 
@LeviMorrison With exceptions the programmer can catch and handle it however they want. And exceptions will make debugging a lot easier since it will be clear why the value isn't castable, rather than just whether it is castable.
 
8:00 PM
@TheodoreBrown Except you now must deal with exceptions.
That's forcing the programmer to use a particular paradigm.
@Danack I should clarify this in the docs, but IS_ARRAY means you gave the type array, IS_CALLABLE means you gave the type callable, IS_OBJECT means anything else (at the moment)
IS_CALLABLE doesn't mean the value is callable; it means the type declaration is callable, as in function(callable $f)
 
k - this is just instinct and not completely backed up by reasons, but IS_CLASS sounds slightly clearer, and avoiding future compatibility problems with things that might be objects, but not classes.
 
@LeviMorrison There are many internal PHP methods/functions that throw exceptions. Using them implies that you will deal with them in some way. Is this bad?
 
@TheodoreBrown That's untrue. There are very, very few which throw exceptions when compared to the total number of functions and methods.
 
E_APPEAL_TO_POPULARITY
 
E_APPEAL_TO_LUNACY
 
8:04 PM
Also, I don't think there are any functions which throw exceptions in core, only methods.
That's particularly relevant because we are talking about functions here.
 
E_APPEAL_TO_LEGACY
 
@TheodoreBrown If you really want exceptions, it's trivial to wrap the test of 'is castable to int'. If you don't want exceptions then having to wrap and catch to ignore the exception sounds like poor language design.
 
@Danack I disagree. It's not trivial at all to wrap a bool value and throw an exception which says exactly why the value isn't castable. On the other hand, it would be very easy to create a function which wraps the exception in a try/catch block and returns a bool.
 
"says exactly why the value isn't castable" - that sounds a lot like trying to figure out why an email address isn't valid. No one cares. It's either valid or not.
 
@Danack It's very helpful for debugging. Was it an overflow? Was the syntax wrong? Did it have an invalid type? Etc.
 
@ircmaxell Can you give this a read and let me know what you think? wiki.php.net/rfc/returntypehinting#reflection
 
SY.
Hi. I've got a problem with installing a composer package. The package is lstrojny/functional-php. I've set "minimum-stability" : "dev" in my composer.json and my require looks like this: "lstrojny/functional-php": "1.0.*@dev". Composer update always fails though: The requested package lstrojny/functional-php could not be found in any version, there may be a typo in the package name.. Could someone assist me in sorting this out?
 
@LeviMorrison one problem I see is that you have a BC issue
 
@TheodoreBrown "It's very helpful for debugging. " Not really....I can just look at avalue and see instantly that 13.5 isn't an int...and for user input I'm not going to be debugging it anyway. I'm just going to display - a message "Sorry but '$enteredValue' is not a valid whole number. Please try again.". I'm not going to be showing them exception message from the php core.
 
example, let's say we add a scalar hint down the road
so now you have a new constant ReflectionType::IS_SCALAR
 
8:13 PM
@SY. Sure - can you upload your complete composer.json to pastebin?
 
but you can't use it, otherwise you will fatal error on older code
since the older constant won't be defined
 
instead, I'd suggest returning a string, which is predictable "array", "callable", "object"
 
Yeah no.
I'm not sure why you think that's any better.
You have to do the same checks, except now it's string comparisons instead of integers.
 
@LeviMorrison I get that
 
8:17 PM
@SY. Erm - so you have this in your composer:
"repositories":
        [
            {
                "type": "composer",
                "url": "http:\/\/www.phpclasses.org\/"
            },
            {
                "packagist": false
            }
        ]
 
however, using constants is going to be problematic if types are added in the future
$ReflectionType->getClass === null <-- missing ()
 
Which basically disables the packagist repository and adds a website - which isn't a repository - as a repository.
 
@ircmaxell A constant would need to be added, yes. But in the calling code you have the same forward-compat issue.
 
@LeviMorrison imagine this:
switch ($type->getKind()) {
    case ReflectionType::IS_ARRAY:
    case ReflectionType::IS_CALLABLE:
    case ReflectionType::IS_OBJECT:
        // works on 7+
    case ReflectionType::IS_SCALAR:
        // breaks below version that introduces type
}
vs
switch ($type->getKind()) {
    case "array":
    case "callable":
    case "object":
       // works on 7+
    case "scalar":
        // wont get called until scalar is introduced, but won't fatal error either
}
 
SY.
@Danack oh wow, I've actually copied it from the phpclasses site and installed a package off of there just an hour ago; didn't think it'd ruin the packagist repository
 
8:20 PM
@ircmaxell Very good point
 
@ircmaxell I don't care. I really don't.
No, it's not a good point.
 
I don't like the string solution either
but it won't fatal error, which is my point.
 
You can do the strings case already
 
I'm open to other possibilities
 
You just have to wrap.
If you really care about that then you can do it.
 
8:21 PM
wrap what?
 
user895378
lol
 
how? I would need to reflect over ReflectionType to find the constants it defines, so that I can use ReflectionType to access the type?
 
user895378
I love that stage of development where you're like, "Cool. If you want that you'll have to do it yourself because I'm finished."
 
With global constants (e.g. T_*) we can at least easily define BC constants, but we can't do the same with class constants
 
@rdlowrey to be fair, I don't think that is what's happening here
 
user895378
8:23 PM
@ircmaxell You're right, it just put me in that mindset temporarily :)
 
:-)
 
SY.
@Danack is removing the "packagist": false line enough to keep both these software sources intact?
 
@SY. please stay away from that horrible site...
there second best "class" is "PHP MD5 Decrypter"
 
// almost not psuedo-code
function AnthonysStringAdapter(ReflectionType $t) {
    switch ($t->getKind()) {
        case IS_ARRAY:
        case IS_CALLABLE:
            return $t->getName();

        case IS_OBJECT:
            return "object";

        default:
             if (/* PHP_VERSION check */) {
                 return "scalar";
             }
        // fallthrough
        case IS_UNDECLARED:
            return "";
    }
}
 
@SY. Should be - but I wasn't aware that phpclasses is a satis repository....and yeah. I'd consider installing software directly from there a bit of a dodgy idea.
 
8:26 PM
@ircmaxell nice!
 
@LeviMorrison well, how would that work reliably? Meaning what would that PHP_VERSION CHECK look like, as it'd need to check more than just the version (considering it could be int, or whatever arbitrary value)...
 
SY.
well tbh I was considering rewriting what I got from there myself because the code was very poor quality
 
get your packages from here: https://packagist.org/
they might not always be great, but chances are that a package with a decent order of installations is many orders of magnitudes better than that phpclasses crap
 
$scalar = "IS_SCALAR";
// do this in the version check
if ( == ReflectionType::$scalar) {
    return "scalar";
}
 
SY.
sure, I've always done that in the past so I guess I'll stick to it
thanks a lot, Danack!
 
8:29 PM
np.
 
SY.
and ty for the tip Patrick
 
@LeviMorrison that won't work... it'll try ti load the static property $scalar
 
Then it's 'else' case after checkign all the other types.
 
you'd have to do constant("ReflectionType::$scalar")
 
I understand your concern. I don't care about that particular issue, and I don't think anyone should either.
Basically it's modifying an enum.
That always sucks, but that enum is way better than what we currently have.
 
8:31 PM
modifying an enum in a way that will fatal when trying to build a BC layer, without jumping through hoops...
 
No, you can do it just fine.
I absolutely promise.
 
and I don't think it's that far out of reality that "anyone should care either"
 
You can always use the 'else' case after everything else has been checked.
 
@NikiC what do you think?
 
@ircmaxell Thanks. Fixed.
Also, I really, really think everyone who wants scalar types should reconsider.
The more arguments I hear for this way vs that way the more I think we shouldn't do them.
And I really think we want strict scalars if we do them at all.
 
8:35 PM
I'm not arguing that point, but I am saying that thinking the current set of type declarations isn't all we'll ever need, even without scalar types
 
Definitely. Doesn't cover void either.
Or nullable.
 
I want primitive autoboxing. Is that so hard to ask for?!
:P
 
And so forth.
 
wait, I meant
I want Java. Is that so hard to ask for?!
 
so if there's a case where you need to expand them, I think thinking about how to handle the expansion is a good thing to discuss
 
8:36 PM
Yep. Discussed. Moving on.
 
@FlorianMargaine you're lucky I'm in a good mood, or I'd have kicked you for that comment :-P
 
Look, we're talking about Reflection.
This is basically runtime magic
I really, really think this is not as big of an issue as you make it out to be.
 
@FlorianMargaine Primitive autoboxing! Yay!
PRIMITIVE AUTOBOTS, TRANSFORM!
 
Dinobots!
 
8:38 PM
OH NO, ITS THE EXCEPTICONS!
3
 
that said... primitive autoboxing would solve the scalar type hinting issue.
 
And also, your concern isn't "BC" as we typically use the term. This is writing code that works on multiple versions, which isn't the same thing.
 
@LeviMorrison I can haz macros?
 
You can't use return types in 5.x. That's not a BC issue. It would be a BC issue if we broke 5.x code.
 
@DanLugg LOL
 
8:39 PM
Again, this is all in the nomenclature used by Internals; it's actually incorrect usage ^^
 
github.com/… <- > 1000 results
 
@ircmaxell I really don't know what you mean by that. I haven't touched ReflectionParameter.
 
no, meaning that a non-trivial amount of people use ReflectionParameter, therefor I think it's safe to say that a non-trivial amount of people will use this new API. So I don't think it's worth brushing off
 
And a substantial number of those are .phpt tests, which are either HHVM or php-src forks.
It's much smaller than 1,000
Most of the hits I've seen have been phpt files
 
hey guys.
 
8:41 PM
@ircmaxell I don't know. Having a forward compatible design is nice, but returning strings here feels wrong (the set of possible return values is less well-defined).
 
@NikiC yeah, I'm not sold on either solution
 
I have this string. "name lastname <email@domain.com>" - I found a way to get the email from within <> using preg_match, but how can I get the bit outside <> as well?
 
@ircmaxell Github code search is totally useless for analyzing amount of usage. Most of it is always duplicate code :/
 
I'll take the foibles of the proposed API over the string one. I'm all for feedback and improvement, but what you proposed is inferior when you actually use it for the 99% case.
Also, the current API is absolutely silly.
 
@LeviMorrison I love isDefaultValueAvailable.
 
8:43 PM
I proposed nothing
 
@cantsay preg_match can return the offset locations where strings have been found. You should be able to work back from that info to get the rest of the string.
 
Like, srsly? hasDefaultValue wasn't clear enough.
 
I showed an alternative. I'm not sold on the string concept
But I don't like a concept that requires a ton of work to make forward compatible either
24 mins ago, by ircmaxell
I don't like the string solution either
24 mins ago, by ircmaxell
but it won't fatal error, which is my point.
 
@Danack I was also thinking of using explode to split at < and then remove the > after
which should result in an array with both pieces of info. is that a better idea?
 
8:47 PM
@DanLugg ...you are talking about ReflectionParameter?
hasDefaultValue isn't listed on the docs page.
 
@LeviMorrison Dan was suggesting that hasDefaultValue() would have been a more concise method name
 
Oh, definitely.
Also, if I remember correctly that isn't reliable in PDO and maybe some other extensions.
Also, what does this even mean? isDefaultValueConstant
I'm not sure what "Constant" means there
 
@LeviMorrison Constant as in a constant. Not a constant value.
like $foo = M_PI
 
And why on earth would it matter if the default value was a constant in Reflection?
 
8:53 PM
Hey, Andrea.
 
/me is watching today/yesterday's PHP Round Table
Hey Levi
When'll return types be voted on?
 
@AndreaFaulds oh good lord :-P
 
@ircmaxell ...why that reaction?
 
@AndreaFaulds I need a bit more feedback on the Reflection stuff.
 
I never watch my own videos. or listen to myself speak. eiw
 
8:54 PM
@ircmaxell By the way, this BC issue is the same if we use a method call like they currently do.
 
@ircmaxell I think it's a good idea to learn to like your voice recorded
Because it's how other people hear you
 
isScalar() doesn't exist and you don't control the __call magic either.
 
Sure, your voice always sounds different to yourself, but nobody cares, they don't hear your inner voice
 
I guess you could do the assignment magic.
 
@LeviMorrison Go on...
 
8:55 PM
@LeviMorrison actually, slightly different, since the fatal is runtime
 
@AndreaFaulds Was nice. I especially liked Sara ^^
 
43 secs ago, by Levi Morrison
I guess you could do the assignment magic.
^ Yeah.
 
@NikiC Sara's awesome. I've met her in person :)
 
she is awesome
 
She was apparoximately as awesome as I thought she'd be :p
 
8:56 PM
We're taking about Sara Golemon, right?
 
yes
 
Of course :)
 
been off the internet for few days now .. is it makes me feel kinda slow and dull ?
is that how normal people feel all the time ?
 
I haven't met her, but we've collaborated a bit. Seems very nice except when Internals goes insane about a bug fix for multiple default statements.
 
I feel like I constantly annoy her though
which is probably true
 
8:59 PM
Guys, any apache gurus around? serverfault.com/q/638432/45086
 
I could delay ReflectionType until we have Enums /cc @AndreaFaulds
 
wait, there's a proposal for enums?
 
It's one of the many things I'd like to do
 

« first day (1465 days earlier)      last day (3488 days later) »