Skip to content

Commit 8d6c9fe

Browse files
committed
Fix phpunit 10.0 compatibility and upgrade some dependencies
1 parent 1c6f0e5 commit 8d6c9fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1342
-1579
lines changed

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.gitattributes export-ignore
22
.gitignore export-ignore
33
tests/ export-ignore
4+
5+
phpunit.xml
6+
psalm.xml

composer.json

+12-9
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,25 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^8.1",
19+
"php": "^7.4|^8.0",
2020
"ext-spl": "*",
2121
"ext-pcre": "*",
2222
"ext-json": "*",
2323
"ext-mbstring": "*",
24-
"phplrt/lexer-contracts": "^4.0",
25-
"phplrt/lexer-printer": "^4.0",
26-
"phplrt/source-contracts": "^4.0"
24+
"phplrt/source": "^3.4",
25+
"phplrt/lexer-contracts": "^3.4",
26+
"phplrt/exception": "^3.4"
2727
},
2828
"autoload": {
2929
"psr-4": {
3030
"Phplrt\\Lexer\\": "src"
31-
}
31+
},
32+
"files": [
33+
"src/polyfill.php"
34+
]
3235
},
3336
"require-dev": {
34-
"phpunit/phpunit": "^10.5|^11.0",
37+
"phpunit/phpunit": "^9.6|^10.0",
3538
"vimeo/psalm": "^5.21"
3639
},
3740
"autoload-dev": {
@@ -40,12 +43,12 @@
4043
}
4144
},
4245
"provide": {
43-
"phplrt/lexer-contracts-implementation": "^4.0"
46+
"phplrt/lexer-contracts-implementation": "^3.4"
4447
},
4548
"extra": {
4649
"branch-alias": {
47-
"dev-master": "4.x-dev",
48-
"dev-main": "4.x-dev"
50+
"dev-master": "3.x-dev",
51+
"dev-main": "3.x-dev"
4952
}
5053
},
5154
"config": {

phpunit.xml

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4-
colors="true"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
54
backupGlobals="true"
6-
stopOnFailure="false"
7-
processIsolation="false"
5+
backupStaticAttributes="false"
86
bootstrap="vendor/autoload.php"
9-
cacheDirectory="vendor/.phpunit.cache"
10-
backupStaticProperties="false"
7+
colors="true"
8+
convertErrorsToExceptions="true"
9+
convertNoticesToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
processIsolation="false"
12+
stopOnFailure="false"
1113
>
14+
<php>
15+
<ini name="error_reporting" value="-1"/>
16+
<ini name="memory_limit" value="-1"/>
17+
</php>
18+
1219
<testsuites>
1320
<testsuite name="unit">
1421
<directory>tests/Unit</directory>
@@ -18,16 +25,9 @@
1825
</testsuite>
1926
</testsuites>
2027

21-
<coverage/>
22-
23-
<source>
28+
<coverage>
2429
<include>
2530
<directory suffix=".php">src</directory>
2631
</include>
27-
</source>
28-
29-
<php>
30-
<ini name="error_reporting" value="-1"/>
31-
<ini name="memory_limit" value="-1"/>
32-
</php>
32+
</coverage>
3333
</phpunit>

resources/.deprecations.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Phplrt\Lexer\Buffer {
4+
5+
/**
6+
* @deprecated since phplrt 3.2 and will be removed in 4.0, use {@see \Phplrt\Buffer\ArrayBuffer} instead.
7+
*/
8+
class ArrayBuffer extends \Phplrt\Buffer\ArrayBuffer
9+
{
10+
}
11+
12+
/**
13+
* @deprecated since phplrt 3.2 and will be removed in 4.0, use {@see \Phplrt\Buffer\ExtrusiveBuffer} instead.
14+
*/
15+
class ExtrusiveBuffer extends \Phplrt\Buffer\ExtrusiveBuffer
16+
{
17+
}
18+
19+
/**
20+
* @deprecated since phplrt 3.2 and will be removed in 4.0, use {@see \Phplrt\Buffer\LazyBuffer} instead.
21+
*/
22+
class LazyBuffer extends \Phplrt\Buffer\LazyBuffer
23+
{
24+
}
25+
26+
/**
27+
* @deprecated since phplrt 3.2 and will be removed in 4.0, use {@see \Phplrt\Buffer\Buffer} instead.
28+
*/
29+
abstract class Buffer extends \Phplrt\Buffer\Buffer
30+
{
31+
}
32+
33+
}

src/Aliases/GeneratorInterface.php

-15
This file was deleted.

src/Aliases/OrderedGenerator.php

-46
This file was deleted.

src/Compiler/CompilerInterface.php

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Phplrt\Lexer\Compiler;
6+
7+
interface CompilerInterface
8+
{
9+
/**
10+
* @param array<non-empty-string, non-empty-string> $tokens
11+
* @return non-empty-string
12+
*/
13+
public function compile(array $tokens): string;
14+
}

src/Compiler/Markers.php

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Phplrt\Lexer\Compiler;
6+
7+
class Markers extends PCRECompiler
8+
{
9+
/**
10+
* @var string
11+
*/
12+
private const FORMAT_MARKER = '(?:(?:%s)(*MARK:%s))';
13+
14+
/**
15+
* @var string
16+
*/
17+
private const FORMAT_BODY = '\\G(?|%s)';
18+
19+
/**
20+
* @param array<array-key, string> $chunks
21+
* @return non-empty-string
22+
*
23+
* @psalm-suppress MoreSpecificReturnType
24+
* @psalm-suppress LessSpecificReturnStatement
25+
*/
26+
protected function buildTokens(array $chunks): string
27+
{
28+
return \sprintf(self::FORMAT_BODY, \implode('|', $chunks));
29+
}
30+
31+
/**
32+
* @param non-empty-string $name
33+
* @param non-empty-string $pattern
34+
* @return non-empty-string
35+
*/
36+
protected function buildToken(string $name, string $pattern): string
37+
{
38+
return \sprintf(self::FORMAT_MARKER, $pattern, $name);
39+
}
40+
}

0 commit comments

Comments
 (0)