« first day (2084 days earlier)      last day (2879 days later) » 

10:00 PM
> I don't think that most consumers of ReflectionType are interested in obtaining a ReflectionClass for the type hint anyway
@NikiC ^ What are they interested in then?
 
@LeviMorrison the name
 
And what are they going to do with it?
 
use it in codegen, look up something based on it in a DI container, generate docs, whatever
 
And how is the suggest behavior at odds with any of those things?
 
@LeviMorrison it is not at odds with them (apart from the potential of incorrect checks), because they don't need the additional suggested behavior
 
10:05 PM
I can accept that, except that some people will want to get a ReflectionClass from it.
It helps those people and doesn't harm the ones you mentioned.
 
@LeviMorrison But does it really help them? I don't see a lot of differences between these two:
if ($type instanceof ReflectionClassType) {
    $r = $type->getClass();
}
// and
if (class_exists($type->getName())) {
    $r = new ReflectionClass($type->getName());
}
 
Ah, you already have a potential mistake. Thank you for the example.
 
I'm sure the mistake is subject to either context or interpretation
 
Autoloader was not triggered.
 
Of course it was
!!docs class_exists
 
10:08 PM
[ class_exists() ] Checks if the class has been defined
 
See.
 
I could have sworn it defaulted to false, not true.
My bad on that detail then.
But it will fail for interfaces.
ReflectionClass can be built for those but class_exists() will be false.
 
@LeviMorrison True :) And then you can start arguing whether ReflectionClassType is still an accurate name etc
 
Well it's not a correct name; no arguments there ^_^
But it matches ReflectionClass. Do you have a better name?
 
(I remember a huge discussion on the original ReflectionType PR where we did everything to avoid bringing the name "class" into anything)
@LeviMorrison ha, no
 
10:12 PM
Since class_exists returns false for interfaces I imagine it would return false for enums as well.
I'm not sure enums will actually be classes, but they could be.
But if they are then it further complicates the future compat, while there is no such issue with the proposed RFC.
Do you agree on that point?
 
@LeviMorrison ugh … And I for my part could have sworn that class_exists() does a simple lookup in class table without distinguishing type of class… (i.e. that it returns true for interfaces etc. too)
 
@bwoebi Me too :D It's stupid behavior imho
 
not_builtin_type_exists? :D
 
@NikiC yeah… the only useful one would be a function determining whether a class can be instantiated
 
@bwoebi I'm sure this is why it works that way.
 
10:16 PM
@LeviMorrison Some pedant likely complained at some point
 
@LeviMorrison try instantiating an object of class Closure…
 
!!docs closure
 
[ Closure ] Class used to represent anonymous functions.
 
(is documented as private ctor)
 
As I thought: Closure was only introduced in 5.3 whereas the behavior with class_exists existed in 5.0.
Still private constructors, but those were only added in 5.0 as well.
 
10:19 PM
@LeviMorrison your point…?
 
It was potentially valid assumption at the time.
Remember, when 5.0 was new nobody had private constructors :D
Anyway, my overall point is that it does indeed facilitate the correct creation of ReflectionClass instances and does not harm the other use cases.
@NikiC Should I rename getClass() -> getReflectionClass()?
 
This vote is somehow weird to me … open for 6 hours … three votes … two from me and Levi, one from Nikita …
 
Anonymous
Night guys o/
 
Yeah, seems odd.
I can see how a lot of people just don't care.
I sometimes choose to not vote.
Maybe that's what they're all doing in this case.
Given that there is a BC impact I expect some people to show up to vote no :D
 
I label increasingly nonsensical images with ‘UI’ and ‘UX’ and hope they get used in serious presentations https://t.co/tDJgRp6CO5
 
@LeviMorrison Sounds reasonable, though maybe inconsistent with other reflection APIs?
 
I picked getClass() for consistency, yes.
Hmm.
   try {
     $r = new ReflectionClass($type->getName());
   } catch (ReflectionException $e) {
     // handle case where ReflectionClass cannot be used
   }
That is the most forward-compat solution with current proposal without ReflectionClassType.
You are right that I'd like to avoid the "class" misnomer but when the best option is to rely on exceptions when it's not really exceptional I think there needs to be a better solution.
 
@LeviMorrison To turn this around, in what situation do you imagine it to be useful?
I mean, getting the ReflectionClass
I'm sure there are cases, I just have a hard time coming up with examples
 
Why do you get ReflectionClass for a parameter?
 
@LeviMorrison Due to a bad design descision
It's pretty universally hated, I think
 
10:52 PM
:D
 
People parse the output of ReflectionParameter::export() to get the actual class name, I think
 
As in the name as it was written when the type was defined?
 
Oh I mean to avoid loading. Depends on context. If it's not a problem getting it from the ReflectionClass is fine
Btw, an interesting issue in this discussion that has not yet come up is parent/self
Though it's not actually clear on which side those weigh in
 
Ah, that's a good point.
 
On the one hand, ReflectionClassType would allow the implementation to automatically resolve them
 
10:54 PM
I forget about those sometimes because I don't really use them.
 
On the other hand, self/parent are context dependent, you can't actually statically resolve them in some cases or the resolution may not be universally valid
 
@NikiC Agreed. What's on the other hand?
 
E.g. you can't resolve a self type on a trait
 
And similarly, self on closures is binding dependent
 
10:56 PM
Can you make a ReflectionClass for a trait? Checking...
 
So would you get a ReflectionClassType only if it can be statically resolved? Or never get one for self/parent?
 
Answer: Yes.
 
@LeviMorrison The problem is that self in traits does not refer to the trait
But the class it is used in
 
I didn't mean it would be useful, rather I was curious :D
 
ah
 
10:58 PM
Is closure rebinding workign with self checks for return types currently?
Let me reword that: are self checks working with closure rebinding at the moment?
 
They should
 
I was thinking they get statically resolved.
 
I remember doing a bunch of fixed in 7 to ensure that self really is always runtime resolve in closures ... and not just sometimes, depending on moon phase
 
Bah, who had that genius idea of in place rehashes … makes everything harder…
 
Uhm... what am I doing wrong here? 3v4l.org/Y1n1v
 
11:06 PM
@LeviMorrison you're context binding, not statically binding
 
Ah, right.
 
@LeviMorrison I.e. try ->call($bar);: 3v4l.org/VEnpO
 
I did, but I was looking in the docs to see what the correct bindTo argument would be.
 
@LeviMorrison well, "Bar" as third param
 
var_dump(Foo::MakeConstructor()->bindTo($bar, get_class($bar))());
Seems odd that the static context doesn't follow the object when present.
Hopefully there was a reason for it when that was introduced.
Honestly I wish we only allowed rebinding for classes of the same type. Screw all the other use cases.
Or alternatively that self and static never existed.
@NikiC I'll double check the behavior of this tonight but I believe it will simply create a ReflectionNamedType because the autoload will be guaranteed to fail.
You can't check it because the patch is local only :D
 
11:15 PM
@LeviMorrison We do… but you're manipulating a custom Closure (the "real" returned Closure) here, not the methods Closure (also called fake Closure)
 
11:31 PM
@LeviMorrison Thanks
Still leaves the question of how it should behave :D
 
neo
I know you shouldnt as questions from w3schools but in this page is the example shown for the code below working on same?
http://www.w3schools.com/php/php_ajax_database.asp#
I think the code given is in GET but i think the example show is using POST right ?
 

« first day (2084 days earlier)      last day (2879 days later) »