@@ -2190,6 +2190,122 @@ public function testPHP81ConstructorPropertyPromotionWithOnlyReadOnly()
21902190    }//end testPHP81ConstructorPropertyPromotionWithOnlyReadOnly() 
21912191
21922192
2193+     /** 
2194+      * Verify recognition of PHP8 constructor with property promotion using PHP 8.4 asymmetric visibility. 
2195+      * 
2196+      * @return void 
2197+      */ 
2198+     public  function  testPHP84ConstructorPropertyPromotionWithAsymVisibility ()
2199+     {
2200+         // Offsets are relative to the T_FUNCTION token. 
2201+         $ expected     = [];
2202+         $ expected [0 ] = [
2203+             'token '                 => 12 ,
2204+             'name '                  => '$book ' ,
2205+             'content '               => 'protected(set) string|Book $book ' ,
2206+             'has_attributes '        => false ,
2207+             'pass_by_reference '     => false ,
2208+             'reference_token '       => false ,
2209+             'variable_length '       => false ,
2210+             'variadic_token '        => false ,
2211+             'type_hint '             => 'string|Book ' ,
2212+             'type_hint_token '       => 8 ,
2213+             'type_hint_end_token '   => 10 ,
2214+             'nullable_type '         => false ,
2215+             'property_visibility '   => 'public ' ,
2216+             'visibility_token '      => false ,
2217+             'set_visibility '        => 'protected(set) ' ,
2218+             'set_visibility_token '  => 6 ,
2219+             'property_readonly '     => false ,
2220+             'comma_token '           => 13 ,
2221+         ];
2222+         $ expected [1 ] = [
2223+             'token '                 => 23 ,
2224+             'name '                  => '$publisher ' ,
2225+             'content '               => 'public private(set) ?Publisher $publisher ' ,
2226+             'has_attributes '        => false ,
2227+             'pass_by_reference '     => false ,
2228+             'reference_token '       => false ,
2229+             'variable_length '       => false ,
2230+             'variadic_token '        => false ,
2231+             'type_hint '             => '?Publisher ' ,
2232+             'type_hint_token '       => 21 ,
2233+             'type_hint_end_token '   => 21 ,
2234+             'nullable_type '         => true ,
2235+             'property_visibility '   => 'public ' ,
2236+             'visibility_token '      => 16 ,
2237+             'set_visibility '        => 'private(set) ' ,
2238+             'set_visibility_token '  => 18 ,
2239+             'property_readonly '     => false ,
2240+             'comma_token '           => 24 ,
2241+         ];
2242+         $ expected [2 ] = [
2243+             'token '                 => 33 ,
2244+             'name '                  => '$author ' ,
2245+             'content '               => 'Private(set) PROTECTED Author $author ' ,
2246+             'has_attributes '        => false ,
2247+             'pass_by_reference '     => false ,
2248+             'reference_token '       => false ,
2249+             'variable_length '       => false ,
2250+             'variadic_token '        => false ,
2251+             'type_hint '             => 'Author ' ,
2252+             'type_hint_token '       => 31 ,
2253+             'type_hint_end_token '   => 31 ,
2254+             'nullable_type '         => false ,
2255+             'property_visibility '   => 'PROTECTED ' ,
2256+             'visibility_token '      => 29 ,
2257+             'set_visibility '        => 'Private(set) ' ,
2258+             'set_visibility_token '  => 27 ,
2259+             'property_readonly '     => false ,
2260+             'comma_token '           => 34 ,
2261+         ];
2262+         $ expected [3 ] = [
2263+             'token '                 => 43 ,
2264+             'name '                  => '$pubYear ' ,
2265+             'content '               => 'readonly public(set) int $pubYear ' ,
2266+             'has_attributes '        => false ,
2267+             'pass_by_reference '     => false ,
2268+             'reference_token '       => false ,
2269+             'variable_length '       => false ,
2270+             'variadic_token '        => false ,
2271+             'type_hint '             => 'int ' ,
2272+             'type_hint_token '       => 41 ,
2273+             'type_hint_end_token '   => 41 ,
2274+             'nullable_type '         => false ,
2275+             'property_visibility '   => 'public ' ,
2276+             'visibility_token '      => false ,
2277+             'set_visibility '        => 'public(set) ' ,
2278+             'set_visibility_token '  => 39 ,
2279+             'property_readonly '     => true ,
2280+             'readonly_token '        => 37 ,
2281+             'comma_token '           => 44 ,
2282+         ];
2283+         $ expected [4 ] = [
2284+             'token '                 => 49 ,
2285+             'name '                  => '$illegalMissingType ' ,
2286+             'content '               => 'protected(set) $illegalMissingType ' ,
2287+             'has_attributes '        => false ,
2288+             'pass_by_reference '     => false ,
2289+             'reference_token '       => false ,
2290+             'variable_length '       => false ,
2291+             'variadic_token '        => false ,
2292+             'type_hint '             => '' ,
2293+             'type_hint_token '       => false ,
2294+             'type_hint_end_token '   => false ,
2295+             'nullable_type '         => false ,
2296+             'property_visibility '   => 'public ' ,
2297+             'visibility_token '      => false ,
2298+             'set_visibility '        => 'protected(set) ' ,
2299+             'set_visibility_token '  => 47 ,
2300+             'property_readonly '     => false ,
2301+             'comma_token '           => 50 ,
2302+         ];
2303+ 
2304+         $ this  ->getMethodParametersTestHelper ('/*  ' .__FUNCTION__ .' */ ' , $ expected );
2305+ 
2306+     }//end testPHP84ConstructorPropertyPromotionWithAsymVisibility() 
2307+ 
2308+ 
21932309    /** 
21942310     * Verify behaviour when a non-constructor function uses PHP 8 property promotion syntax. 
21952311     * 
@@ -3214,6 +3330,10 @@ private function getMethodParametersTestHelper($commentString, $expected, $targe
32143330                $ expected [$ key ]['visibility_token ' ] += $ target ;
32153331            }
32163332
3333+             if  (isset ($ param ['set_visibility_token ' ]) === true  && is_int ($ param ['set_visibility_token ' ]) === true ) {
3334+                 $ expected [$ key ]['set_visibility_token ' ] += $ target ;
3335+             }
3336+ 
32173337            if  (isset ($ param ['readonly_token ' ]) === true ) {
32183338                $ expected [$ key ]['readonly_token ' ] += $ target ;
32193339            }
0 commit comments