Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #18973

Re: a question on a PayPal's ReflectionUtil (Was: Re: a question on)

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
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 Fri, 3 Jun 2022 08:10:44 +0200
Lines 51
Message-ID <jftmv5FplujU1@mid.individual.net> (permalink)
References <864k12ertd.fsf@levado.to> <86r146dcxj.fsf@levado.to>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net vAEjE8QCxpZtDWjgpBD5FA1XZWbMB42K78kYSjURAeDrabGrg9
Cancel-Lock sha1:5UWmVLPp49KfR11o4elvk0EBN38=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1
Content-Language en-US-large
In-Reply-To <86r146dcxj.fsf@levado.to>
Xref csiph.com comp.lang.php:18973

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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