@@ -696,6 +696,7 @@ public function testPHP8ConstructorPropertyPromotionNoTypes()
696696 'type_hint ' => '' ,
697697 'nullable_type ' => false ,
698698 'property_visibility ' => 'public ' ,
699+ 'property_readonly ' => false ,
699700 ];
700701 $ expected [1 ] = [
701702 'name ' => '$y ' ,
@@ -707,6 +708,7 @@ public function testPHP8ConstructorPropertyPromotionNoTypes()
707708 'type_hint ' => '' ,
708709 'nullable_type ' => false ,
709710 'property_visibility ' => 'protected ' ,
711+ 'property_readonly ' => false ,
710712 ];
711713 $ expected [2 ] = [
712714 'name ' => '$z ' ,
@@ -718,6 +720,7 @@ public function testPHP8ConstructorPropertyPromotionNoTypes()
718720 'type_hint ' => '' ,
719721 'nullable_type ' => false ,
720722 'property_visibility ' => 'private ' ,
723+ 'property_readonly ' => false ,
721724 ];
722725
723726 $ this ->getMethodParametersTestHelper ('/* ' .__FUNCTION__ .' */ ' , $ expected );
@@ -742,6 +745,7 @@ public function testPHP8ConstructorPropertyPromotionWithTypes()
742745 'type_hint ' => 'float|int ' ,
743746 'nullable_type ' => false ,
744747 'property_visibility ' => 'protected ' ,
748+ 'property_readonly ' => false ,
745749 ];
746750 $ expected [1 ] = [
747751 'name ' => '$y ' ,
@@ -753,6 +757,7 @@ public function testPHP8ConstructorPropertyPromotionWithTypes()
753757 'type_hint ' => '?string ' ,
754758 'nullable_type ' => true ,
755759 'property_visibility ' => 'public ' ,
760+ 'property_readonly ' => false ,
756761 ];
757762 $ expected [2 ] = [
758763 'name ' => '$z ' ,
@@ -763,6 +768,7 @@ public function testPHP8ConstructorPropertyPromotionWithTypes()
763768 'type_hint ' => 'mixed ' ,
764769 'nullable_type ' => false ,
765770 'property_visibility ' => 'private ' ,
771+ 'property_readonly ' => false ,
766772 ];
767773
768774 $ this ->getMethodParametersTestHelper ('/* ' .__FUNCTION__ .' */ ' , $ expected );
@@ -787,6 +793,7 @@ public function testPHP8ConstructorPropertyPromotionAndNormalParam()
787793 'type_hint ' => 'int ' ,
788794 'nullable_type ' => false ,
789795 'property_visibility ' => 'public ' ,
796+ 'property_readonly ' => false ,
790797 ];
791798 $ expected [1 ] = [
792799 'name ' => '$normalArg ' ,
@@ -803,6 +810,42 @@ public function testPHP8ConstructorPropertyPromotionAndNormalParam()
803810 }//end testPHP8ConstructorPropertyPromotionAndNormalParam()
804811
805812
813+ /**
814+ * Verify recognition of PHP8 constructor with property promotion using PHP 8.1 readonly keyword.
815+ *
816+ * @return void
817+ */
818+ public function testPHP81ConstructorPropertyPromotionWithReadOnly ()
819+ {
820+ $ expected = [];
821+ $ expected [0 ] = [
822+ 'name ' => '$promotedProp ' ,
823+ 'content ' => 'public readonly ?int $promotedProp ' ,
824+ 'has_attributes ' => false ,
825+ 'pass_by_reference ' => false ,
826+ 'variable_length ' => false ,
827+ 'type_hint ' => '?int ' ,
828+ 'nullable_type ' => true ,
829+ 'property_visibility ' => 'public ' ,
830+ 'property_readonly ' => true ,
831+ ];
832+ $ expected [1 ] = [
833+ 'name ' => '$promotedToo ' ,
834+ 'content ' => 'readonly private string|bool &$promotedToo ' ,
835+ 'has_attributes ' => false ,
836+ 'pass_by_reference ' => true ,
837+ 'variable_length ' => false ,
838+ 'type_hint ' => 'string|bool ' ,
839+ 'nullable_type ' => false ,
840+ 'property_visibility ' => 'private ' ,
841+ 'property_readonly ' => true ,
842+ ];
843+
844+ $ this ->getMethodParametersTestHelper ('/* ' .__FUNCTION__ .' */ ' , $ expected );
845+
846+ }//end testPHP81ConstructorPropertyPromotionWithReadOnly()
847+
848+
806849 /**
807850 * Verify behaviour when a non-constructor function uses PHP 8 property promotion syntax.
808851 *
0 commit comments