99use PhpKafka \PhpAvroSchemaGenerator \Parser \DocCommentParser ;
1010use PhpKafka \PhpAvroSchemaGenerator \PhpClass \PhpClassPropertyInterface ;
1111use PhpParser \ParserFactory ;
12+ use PhpParser \PhpVersion ;
1213use PHPUnit \Framework \TestCase ;
1314
1415/**
@@ -20,7 +21,7 @@ public function testGetClassName(): void
2021 {
2122 $ filePath = __DIR__ . '/../../../example/classes/SomeTestClass.php ' ;
2223 $ propertyParser = new ClassPropertyParser (new DocCommentParser ());
23- $ parser = new ClassParser ((new ParserFactory ())->create (ParserFactory:: PREFER_PHP7 ), $ propertyParser );
24+ $ parser = new ClassParser ((new ParserFactory ())->createForVersion (PhpVersion:: fromComponents ( 8 , 2 ) ), $ propertyParser );
2425 $ parser ->setCode ((string ) file_get_contents ($ filePath ));
2526 self ::assertEquals ('SomeTestClass ' , $ parser ->getClassName ());
2627 self ::assertEquals ('SomeTestClass ' , $ parser ->getClassName ());
@@ -30,7 +31,7 @@ public function testGetClassNameForInterface(): void
3031 {
3132 $ filePath = __DIR__ . '/../../../example/classes/SomeTestInterface.php ' ;
3233 $ propertyParser = new ClassPropertyParser (new DocCommentParser ());
33- $ parser = new ClassParser ((new ParserFactory ())->create (ParserFactory:: PREFER_PHP7 ), $ propertyParser );
34+ $ parser = new ClassParser ((new ParserFactory ())->createForVersion (PhpVersion:: fromComponents ( 8 , 2 ) ), $ propertyParser );
3435 $ parser ->setCode ((string ) file_get_contents ($ filePath ));
3536 self ::assertNull ($ parser ->getClassName ());
3637 }
@@ -39,7 +40,7 @@ public function testGetNamespace(): void
3940 {
4041 $ filePath = __DIR__ . '/../../../example/classes/SomeTestClass.php ' ;
4142 $ propertyParser = new ClassPropertyParser (new DocCommentParser ());
42- $ parser = new ClassParser ((new ParserFactory ())->create (ParserFactory:: PREFER_PHP7 ), $ propertyParser );
43+ $ parser = new ClassParser ((new ParserFactory ())->createForVersion (PhpVersion:: fromComponents ( 8 , 2 ) ), $ propertyParser );
4344 $ parser ->setCode ((string ) file_get_contents ($ filePath ));
4445 self ::assertEquals ('PhpKafka \\PhpAvroSchemaGenerator \\Example ' , $ parser ->getNamespace ());
4546 self ::assertEquals ('PhpKafka \\PhpAvroSchemaGenerator \\Example ' , $ parser ->getNamespace ());
@@ -49,7 +50,7 @@ public function testGetProperties(): void
4950 {
5051 $ filePath = __DIR__ . '/../../../example/classes/SomeTestClass.php ' ;
5152 $ propertyParser = new ClassPropertyParser (new DocCommentParser ());
52- $ parser = new ClassParser ((new ParserFactory ())->create (ParserFactory:: PREFER_PHP7 ), $ propertyParser );
53+ $ parser = new ClassParser ((new ParserFactory ())->createForVersion (PhpVersion:: fromComponents ( 8 , 2 ) ), $ propertyParser );
5354 $ parser ->setCode ((string ) file_get_contents ($ filePath ));
5455 $ properties = $ parser ->getProperties ();
5556 self ::assertCount (16 , $ properties );
@@ -62,7 +63,7 @@ public function testGetProperties(): void
6263 public function testClassAndNamespaceAreNullWithNoCode (): void
6364 {
6465 $ propertyParser = new ClassPropertyParser (new DocCommentParser ());
65- $ parser = new ClassParser ((new ParserFactory ())->create (ParserFactory:: PREFER_PHP7 ), $ propertyParser );
66+ $ parser = new ClassParser ((new ParserFactory ())->createForVersion (PhpVersion:: fromComponents ( 8 , 2 ) ), $ propertyParser );
6667 $ refObject = new \ReflectionObject ($ parser );
6768 $ refProperty = $ refObject ->getProperty ('statements ' );
6869 $ refProperty ->setAccessible (true );
@@ -76,7 +77,7 @@ public function testClassAndNamespaceAreNullWithNoCode(): void
7677 public function testClassWithNoParent (): void
7778 {
7879 $ propertyParser = new ClassPropertyParser (new DocCommentParser ());
79- $ parser = new ClassParser ((new ParserFactory ())->create (ParserFactory:: PREFER_PHP7 ), $ propertyParser );
80+ $ parser = new ClassParser ((new ParserFactory ())->createForVersion (PhpVersion:: fromComponents ( 8 , 2 ) ), $ propertyParser );
8081 $ parser ->setCode ('<?php class foo {} ' );
8182 self ::assertNull ($ parser ->getNamespace ());
8283 self ::assertNull ($ parser ->getParentClassName ());
@@ -87,7 +88,7 @@ public function testClassWithNoParent(): void
8788 public function testClassWithNullableType (): void
8889 {
8990 $ propertyParser = new ClassPropertyParser (new DocCommentParser ());
90- $ parser = new ClassParser ((new ParserFactory ())->create (ParserFactory:: PREFER_PHP7 ), $ propertyParser );
91+ $ parser = new ClassParser ((new ParserFactory ())->createForVersion (PhpVersion:: fromComponents ( 8 , 2 ) ), $ propertyParser );
9192 $ parser ->setCode ('
9293 <?php
9394 class foo {
@@ -102,7 +103,7 @@ class foo {
102103 public function testClassWithUnionType (): void
103104 {
104105 $ propertyParser = new ClassPropertyParser (new DocCommentParser ());
105- $ parser = new ClassParser ((new ParserFactory ())->create (ParserFactory:: PREFER_PHP7 ), $ propertyParser );
106+ $ parser = new ClassParser ((new ParserFactory ())->createForVersion (PhpVersion:: fromComponents ( 8 , 2 ) ), $ propertyParser );
106107 $ parser ->setCode ('
107108 <?php
108109 class foo {
@@ -117,7 +118,7 @@ class foo {
117118 public function testClassWithDocUnionType (): void
118119 {
119120 $ propertyParser = new ClassPropertyParser (new DocCommentParser ());
120- $ parser = new ClassParser ((new ParserFactory ())->create (ParserFactory:: PREFER_PHP7 ), $ propertyParser );
121+ $ parser = new ClassParser ((new ParserFactory ())->createForVersion (PhpVersion:: fromComponents ( 8 , 2 ) ), $ propertyParser );
121122 $ parser ->setCode ('
122123 <?php
123124 class foo {
@@ -135,7 +136,7 @@ class foo {
135136 public function testClassWithAnnotations (): void
136137 {
137138 $ propertyParser = new ClassPropertyParser (new DocCommentParser ());
138- $ parser = new ClassParser ((new ParserFactory ())->create (ParserFactory:: PREFER_PHP7 ), $ propertyParser );
139+ $ parser = new ClassParser ((new ParserFactory ())->createForVersion (PhpVersion:: fromComponents ( 8 , 2 ) ), $ propertyParser );
139140 $ parser ->setCode ('
140141 <?php
141142 class foo {
@@ -159,7 +160,7 @@ class foo {
159160 public function testClassWithNoParentFile (): void
160161 {
161162 $ propertyParser = new ClassPropertyParser (new DocCommentParser ());
162- $ parser = new ClassParser ((new ParserFactory ())->create (ParserFactory:: PREFER_PHP7 ), $ propertyParser );
163+ $ parser = new ClassParser ((new ParserFactory ())->createForVersion (PhpVersion:: fromComponents ( 8 , 2 ) ), $ propertyParser );
163164 $ parser ->setCode ('<?php class foo extends \RuntimeException {private $x;} ' );
164165 $ properties = $ parser ->getProperties ();
165166 self ::assertEquals (1 , count ($ properties ));
0 commit comments