Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #18973
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: a question on a PayPal's ReflectionUtil (Was: Re: a question on) |
| Date | 2022-06-03 08:10 +0200 |
| Message-ID | <jftmv5FplujU1@mid.individual.net> (permalink) |
| References | <864k12ertd.fsf@levado.to> <86r146dcxj.fsf@levado.to> |
On 02/06/2022 22.32, Meredith Montgomery wrote:
> Sorry about the incomplete subject. I'm fixing that. I think I also
> understood a bit more about the code I'm asking, so I'm going to add an
> addendum. Sorry about this small mess.
>
> Meredith Montgomery <mmontgomery@levado.to> writes:
>
>> The file
>>
>> PayPal/Common/ReflectionUtil.php
>>
>> --- whose content I show entirely below --- seems to be a class with
>> only static methods and static properties. Now, check the procedure
>>
>> public static function propertyAnnotations($class, $propertyName)
>>
>> It contains the chunk
>>
>> if (!($refl =& self::$propertiesRefl[$class][$propertyName])) {
>> $getter = self::getter($class, $propertyName);
>> $refl = new \ReflectionMethod($class, $getter);
>> self::$propertiesRefl[$class][$propertyName] = $refl;
>> }
>>
>> So $refl is instantiated and it is stored in
>>
>> self::$propertiesRefl[$class][$propertyName]
>>
>> which is a private static array. This means it cannot be acessed from
>> the ``outside''. Also, no other chunk in this class uses
>> $propertiesRefl.
>>
>> Question. Why are they storing $refl if nobody uses it all, not even
>> the very class that defines it?
>
> Actually, it clearly does use $refl. It's used right at the first line
> in the chunk above. It is set merely so the if-inner-code is only
> executed once in its lifetime. Why? Can you just clarify to me what's
> going on this class? I'm not understanding it too clearly. Thank you!
Yes, the inner code in this section will be called once for each
combination of "class" and "propertyName".
The function will return a array of annotations (read a bit about it
here: https://www.educba.com/php-annotations )
It's most likely used to setup correct check for input values client
side and maybe even for post value validation.
--
//Aho
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
a question on Meredith Montgomery <mmontgomery@levado.to> - 2022-06-02 17:25 -0300
a question on a PayPal's ReflectionUtil (Was: Re: a question on) Meredith Montgomery <mmontgomery@levado.to> - 2022-06-02 17:32 -0300
Re: a question on a PayPal's ReflectionUtil (Was: Re: a question on) "J.O. Aho" <user@example.net> - 2022-06-03 08:10 +0200
Re: a question on a PayPal's ReflectionUtil (Was: Re: a question on) V <techfan55555@hotmail.com> - 2023-03-17 07:07 -0700
csiph-web