@@ -696,6 +696,7 @@ public function testPHP8ConstructorPropertyPromotionNoTypes()
696
696
'type_hint ' => '' ,
697
697
'nullable_type ' => false ,
698
698
'property_visibility ' => 'public ' ,
699
+ 'property_readonly ' => false ,
699
700
];
700
701
$ expected [1 ] = [
701
702
'name ' => '$y ' ,
@@ -707,6 +708,7 @@ public function testPHP8ConstructorPropertyPromotionNoTypes()
707
708
'type_hint ' => '' ,
708
709
'nullable_type ' => false ,
709
710
'property_visibility ' => 'protected ' ,
711
+ 'property_readonly ' => false ,
710
712
];
711
713
$ expected [2 ] = [
712
714
'name ' => '$z ' ,
@@ -718,6 +720,7 @@ public function testPHP8ConstructorPropertyPromotionNoTypes()
718
720
'type_hint ' => '' ,
719
721
'nullable_type ' => false ,
720
722
'property_visibility ' => 'private ' ,
723
+ 'property_readonly ' => false ,
721
724
];
722
725
723
726
$ this ->getMethodParametersTestHelper ('/* ' .__FUNCTION__ .' */ ' , $ expected );
@@ -742,6 +745,7 @@ public function testPHP8ConstructorPropertyPromotionWithTypes()
742
745
'type_hint ' => 'float|int ' ,
743
746
'nullable_type ' => false ,
744
747
'property_visibility ' => 'protected ' ,
748
+ 'property_readonly ' => false ,
745
749
];
746
750
$ expected [1 ] = [
747
751
'name ' => '$y ' ,
@@ -753,6 +757,7 @@ public function testPHP8ConstructorPropertyPromotionWithTypes()
753
757
'type_hint ' => '?string ' ,
754
758
'nullable_type ' => true ,
755
759
'property_visibility ' => 'public ' ,
760
+ 'property_readonly ' => false ,
756
761
];
757
762
$ expected [2 ] = [
758
763
'name ' => '$z ' ,
@@ -763,6 +768,7 @@ public function testPHP8ConstructorPropertyPromotionWithTypes()
763
768
'type_hint ' => 'mixed ' ,
764
769
'nullable_type ' => false ,
765
770
'property_visibility ' => 'private ' ,
771
+ 'property_readonly ' => false ,
766
772
];
767
773
768
774
$ this ->getMethodParametersTestHelper ('/* ' .__FUNCTION__ .' */ ' , $ expected );
@@ -787,6 +793,7 @@ public function testPHP8ConstructorPropertyPromotionAndNormalParam()
787
793
'type_hint ' => 'int ' ,
788
794
'nullable_type ' => false ,
789
795
'property_visibility ' => 'public ' ,
796
+ 'property_readonly ' => false ,
790
797
];
791
798
$ expected [1 ] = [
792
799
'name ' => '$normalArg ' ,
@@ -803,6 +810,42 @@ public function testPHP8ConstructorPropertyPromotionAndNormalParam()
803
810
}//end testPHP8ConstructorPropertyPromotionAndNormalParam()
804
811
805
812
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
+
806
849
/**
807
850
* Verify behaviour when a non-constructor function uses PHP 8 property promotion syntax.
808
851
*
0 commit comments