@@ -1961,6 +1961,57 @@ public function testPHP81ConstructorPropertyPromotionWithReadOnly()
19611961 $ this ->getMethodParametersTestHelper ('/* ' . __FUNCTION__ . ' */ ' , $ expected );
19621962 }
19631963
1964+ /**
1965+ * Verify recognition of PHP8 constructor with property promotion using PHP 8.1 readonly keyword
1966+ * without a property type.
1967+ *
1968+ * @return void
1969+ */
1970+ public function testPHP81ConstructorPropertyPromotionWithReadOnlyNoTypeDeclaration ()
1971+ {
1972+ $ expected = [];
1973+ $ expected [0 ] = [
1974+ 'token ' => 8 , // Offset from the T_FUNCTION token.
1975+ 'name ' => '$promotedProp ' ,
1976+ 'content ' => 'public readonly $promotedProp ' ,
1977+ 'has_attributes ' => false ,
1978+ 'pass_by_reference ' => false ,
1979+ 'reference_token ' => false ,
1980+ 'variable_length ' => false ,
1981+ 'variadic_token ' => false ,
1982+ 'type_hint ' => '' ,
1983+ 'type_hint_token ' => false ,
1984+ 'type_hint_end_token ' => false ,
1985+ 'nullable_type ' => false ,
1986+ 'property_visibility ' => 'public ' ,
1987+ 'visibility_token ' => 4 , // Offset from the T_FUNCTION token.
1988+ 'property_readonly ' => true ,
1989+ 'readonly_token ' => 6 , // Offset from the T_FUNCTION token.
1990+ 'comma_token ' => 9 ,
1991+ ];
1992+ $ expected [1 ] = [
1993+ 'token ' => 16 , // Offset from the T_FUNCTION token.
1994+ 'name ' => '$promotedToo ' ,
1995+ 'content ' => 'ReadOnly private &$promotedToo ' ,
1996+ 'has_attributes ' => false ,
1997+ 'pass_by_reference ' => true ,
1998+ 'reference_token ' => 15 , // Offset from the T_FUNCTION token.
1999+ 'variable_length ' => false ,
2000+ 'variadic_token ' => false ,
2001+ 'type_hint ' => '' ,
2002+ 'type_hint_token ' => false ,
2003+ 'type_hint_end_token ' => false ,
2004+ 'nullable_type ' => false ,
2005+ 'property_visibility ' => 'private ' ,
2006+ 'visibility_token ' => 13 , // Offset from the T_FUNCTION token.
2007+ 'property_readonly ' => true ,
2008+ 'readonly_token ' => 11 , // Offset from the T_FUNCTION token.
2009+ 'comma_token ' => false ,
2010+ ];
2011+
2012+ $ this ->getMethodParametersTestHelper ('/* ' . __FUNCTION__ . ' */ ' , $ expected );
2013+ }
2014+
19642015 /**
19652016 * Verify behaviour when a non-constructor function uses PHP 8 property promotion syntax.
19662017 *
0 commit comments