File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,11 +17,13 @@ public function __construct(PhpVersion $phpVersion)
1717
1818 public function create (): Lexer
1919 {
20- if ($ this ->phpVersion ->getVersionId () < = PHP_VERSION_ID ) {
20+ if ($ this ->phpVersion ->getVersionId () == = PHP_VERSION_ID ) {
2121 return new Lexer ();
2222 }
2323
24- return new Lexer \Emulative ();
24+ return new Lexer \Emulative ([
25+ 'phpVersion ' => $ this ->phpVersion ->getVersionString (),
26+ ]);
2527 }
2628
2729}
Original file line number Diff line number Diff line change @@ -17,6 +17,15 @@ public function getVersionId(): int
1717 return $ this ->versionId ;
1818 }
1919
20+ public function getVersionString (): string
21+ {
22+ $ first = (int ) floor ($ this ->versionId / 10000 );
23+ $ second = (int ) floor (($ this ->versionId % 10000 ) / 100 );
24+ $ third = (int ) floor ($ this ->versionId % 100 );
25+
26+ return $ first . '. ' . $ second . ($ third !== 0 ? '. ' . $ third : '' );
27+ }
28+
2029 public function supportsNullCoalesceAssign (): bool
2130 {
2231 return $ this ->versionId >= 70400 ;
Original file line number Diff line number Diff line change @@ -14,41 +14,49 @@ public function dataCreate(): array
1414 null ,
1515 null ,
1616 PHP_VERSION_ID ,
17+ null ,
1718 ],
1819 [
1920 70200 ,
2021 null ,
2122 70200 ,
23+ '7.2 ' ,
2224 ],
2325 [
2426 70200 ,
2527 '7.4.6 ' ,
2628 70200 ,
29+ '7.2 ' ,
2730 ],
2831 [
2932 null ,
3033 '7.4.6 ' ,
3134 70406 ,
35+ '7.4.6 ' ,
3236 ],
3337 [
3438 null ,
3539 '7.0 ' ,
3640 70100 ,
41+ '7.1 ' ,
3742 ],
3843 [
3944 null ,
4045 '7.1.1 ' ,
4146 70101 ,
47+ '7.1.1 ' ,
4248 ],
4349 [
4450 null ,
4551 '5.4.1 ' ,
4652 70100 ,
53+ '7.1 ' ,
4754 ],
4855 [
4956 null ,
5057 '8.1 ' ,
5158 80000 ,
59+ '8.0 ' ,
5260 ],
5361 ];
5462 }
@@ -58,16 +66,24 @@ public function dataCreate(): array
5866 * @param int|null $versionId
5967 * @param string|null $composerPhpVersion
6068 * @param int $expectedVersion
69+ * @param string|null $expectedVersionString
6170 */
6271 public function testCreate (
6372 ?int $ versionId ,
6473 ?string $ composerPhpVersion ,
65- int $ expectedVersion
74+ int $ expectedVersion ,
75+ ?string $ expectedVersionString
6676 ): void
6777 {
6878 $ factory = new PhpVersionFactory ($ versionId , $ composerPhpVersion );
6979 $ phpVersion = $ factory ->create ();
7080 $ this ->assertSame ($ expectedVersion , $ phpVersion ->getVersionId ());
81+
82+ if ($ expectedVersionString === null ) {
83+ return ;
84+ }
85+
86+ $ this ->assertSame ($ expectedVersionString , $ phpVersion ->getVersionString ());
7187 }
7288
7389}
You can’t perform that action at this time.
0 commit comments