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

    From techfan55555@techfan55555@hotmail.com to comp.lang.php on Fri Mar 17 07:07:45 2023
    From Newsgroup: comp.lang.php

    Let's get to know each other. Me: http://kohtumispaik.000webhostapp.com/Infovahetusteks/dpic/1679061026.gif
    Have a nice day......
    On Friday, June 3, 2022 at 8:10:54rC>AM UTC+2, J.O. Aho wrote:
    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 <mmont...@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
    --- Synchronet 3.21d-Linux NewsLink 1.2