Skip to content

Commit c71b02f

Browse files
committed
Add YieldReady attributes
1 parent 97738f7 commit c71b02f

File tree

10 files changed

+43
-42
lines changed

10 files changed

+43
-42
lines changed

composer.json

+10-4
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@
1818
],
1919
"require": {
2020
"php": ">=7.2.5",
21-
"twig/twig": "^3.0"
21+
"twig/twig": "^3.9"
2222
},
2323
"require-dev": {
2424
"bamarni/composer-bin-plugin": "^1.3",
2525
"captainhook/plugin-composer": "^5.0",
26-
"phpunit/phpunit": "^8.0|^9.0"
26+
"phpunit/phpunit": "^10.0"
2727
},
2828
"config": {
29-
"sort-packages": false
29+
"sort-packages": false,
30+
"allow-plugins": {
31+
"bamarni/composer-bin-plugin": true,
32+
"captainhook/plugin-composer": true
33+
}
3034
},
3135
"autoload": {
3236
"psr-4": {
@@ -47,9 +51,11 @@
4751
"psalm_base": "vendor/bin/psalm --set-baseline=psalm-baseline.xml",
4852
"phpunit": "vendor/bin/phpunit --colors=always",
4953
"phpunit_clover": "vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml",
54+
"phpunit_migrate": "vendor/bin/phpunit --configuration=phpunit.xml.dist --migrate-configuration",
5055
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html tests/_reports",
5156
"phpcs": "vendor/bin/phpcs --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --colors src tests",
52-
"phpcsfix": "vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --cache=.phpcs-cache src tests",
57+
"phpcs_diff": "vendor/bin/phpcs -s --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --colors src tests",
58+
"phpcs_fix": "vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --cache=.phpcs-cache src tests",
5359
"binupdate": "@composer bin all update --ansi",
5460
"bininstall": "@composer bin all install --ansi"
5561
}

phpunit.xml.dist

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit
4-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.1/phpunit.xsd"
6-
backupGlobals="false"
7-
colors="true"
8-
bootstrap="vendor/autoload.php"
9-
>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php">
3+
<coverage includeUncoveredFiles="false"/>
104
<testsuites>
115
<testsuite name="Unit Tests">
126
<directory>tests</directory>
137
</testsuite>
148
</testsuites>
15-
16-
<filter>
17-
<whitelist>
18-
<directory suffix=".php">src</directory>
19-
</whitelist>
20-
</filter>
9+
<source>
10+
<include>
11+
<directory>src</directory>
12+
</include>
13+
</source>
2114
</phpunit>

psalm-baseline.xml

+9-18
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.13.1@5cf660f63b548ccd4a56f62d916ee4d6028e01a3">
3-
<file src="src/PhpSyntaxExtension.php">
4-
<InternalClass occurrences="4">
5-
<code>ExpressionParser::OPERATOR_LEFT</code>
6-
<code>ExpressionParser::OPERATOR_LEFT</code>
7-
<code>ExpressionParser::OPERATOR_LEFT</code>
8-
<code>ExpressionParser::OPERATOR_LEFT</code>
9-
</InternalClass>
10-
</file>
2+
<files psalm-version="5.23.1@8471a896ccea3526b26d082f4461eeea467f10a4">
113
<file src="src/TokenParser/BreakOrContinueTokenParser.php">
12-
<InternalMethod occurrences="3">
13-
<code>getSourceContext</code>
14-
<code>getSourceContext</code>
15-
<code>getSourceContext</code>
4+
<InternalMethod>
5+
<code><![CDATA[getSourceContext]]></code>
6+
<code><![CDATA[getSourceContext]]></code>
7+
<code><![CDATA[getSourceContext]]></code>
168
</InternalMethod>
17-
<UnsafeInstantiation occurrences="1">
18-
<code>new $nodeClass($loopNumber, $lineno, $this-&gt;getTag())</code>
9+
<UnsafeInstantiation>
10+
<code><![CDATA[new $nodeClass($loopNumber, $lineno, $this->getTag())]]></code>
1911
</UnsafeInstantiation>
2012
</file>
2113
<file src="src/TokenParser/ForeachTokenParser.php">
22-
<InternalMethod occurrences="2">
23-
<code>getSourceContext</code>
24-
<code>parseExpression</code>
14+
<InternalMethod>
15+
<code><![CDATA[getSourceContext]]></code>
2516
</InternalMethod>
2617
</file>
2718
</files>

psalm.xml

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
xmlns="https://getpsalm.org/schema/config"
66
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
77
errorBaseline="psalm-baseline.xml"
8+
findUnusedBaselineEntry="true"
9+
findUnusedCode="false"
810
>
911
<projectFiles>
1012
<directory name="src" />

ruleset.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
5353
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
5454
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
55-
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHintSpacing"/>
55+
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
5656
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
5757
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
5858
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>

src/TokenParser/BreakNode.php

+2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace Squirrel\TwigPhpSyntax\TokenParser;
44

5+
use Twig\Attribute\YieldReady;
56
use Twig\Compiler;
67
use Twig\Node\Node;
78

9+
#[YieldReady]
810
class BreakNode extends Node
911
{
1012
/**

src/TokenParser/ContinueNode.php

+2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace Squirrel\TwigPhpSyntax\TokenParser;
44

5+
use Twig\Attribute\YieldReady;
56
use Twig\Compiler;
67
use Twig\Node\Node;
78

9+
#[YieldReady]
810
class ContinueNode extends Node
911
{
1012
/**

tests/IntegrationTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
class IntegrationTest extends IntegrationTestCase
99
{
10-
public function getExtensions()
10+
public function getExtensions(): array
1111
{
1212
return [
1313
new PhpSyntaxExtension(),
1414
];
1515
}
1616

17-
public function getFixturesDir()
17+
public function getFixturesDir(): string
1818
{
1919
return __DIR__ . '/Fixtures/';
2020
}

vendor-bin/phpcs/composer.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"require": {
3-
"squizlabs/php_codesniffer": "^3.5",
4-
"slevomat/coding-standard": "^7.0"
3+
"squizlabs/php_codesniffer": "^3.7.2",
4+
"slevomat/coding-standard": "^8.0"
5+
},
6+
"config": {
7+
"allow-plugins": {
8+
"dealerdirect/phpcodesniffer-composer-installer": true
9+
}
510
}
611
}

vendor-bin/psalm/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"require": {
3-
"vimeo/psalm": "^4.0"
3+
"vimeo/psalm": "^5.0"
44
}
55
}

0 commit comments

Comments
 (0)