Skip to content

Commit

Permalink
Add YieldReady attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
iquito committed May 1, 2024
1 parent 97738f7 commit c71b02f
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 42 deletions.
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@
],
"require": {
"php": ">=7.2.5",
"twig/twig": "^3.0"
"twig/twig": "^3.9"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.3",
"captainhook/plugin-composer": "^5.0",
"phpunit/phpunit": "^8.0|^9.0"
"phpunit/phpunit": "^10.0"
},
"config": {
"sort-packages": false
"sort-packages": false,
"allow-plugins": {
"bamarni/composer-bin-plugin": true,
"captainhook/plugin-composer": true
}
},
"autoload": {
"psr-4": {
Expand All @@ -47,9 +51,11 @@
"psalm_base": "vendor/bin/psalm --set-baseline=psalm-baseline.xml",
"phpunit": "vendor/bin/phpunit --colors=always",
"phpunit_clover": "vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml",
"phpunit_migrate": "vendor/bin/phpunit --configuration=phpunit.xml.dist --migrate-configuration",
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html tests/_reports",
"phpcs": "vendor/bin/phpcs --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --colors src tests",
"phpcsfix": "vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --cache=.phpcs-cache src tests",
"phpcs_diff": "vendor/bin/phpcs -s --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --colors src tests",
"phpcs_fix": "vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --cache=.phpcs-cache src tests",
"binupdate": "@composer bin all update --ansi",
"bininstall": "@composer bin all install --ansi"
}
Expand Down
21 changes: 7 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<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">
<coverage includeUncoveredFiles="false"/>
<testsuites>
<testsuite name="Unit Tests">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
27 changes: 9 additions & 18 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.13.1@5cf660f63b548ccd4a56f62d916ee4d6028e01a3">
<file src="src/PhpSyntaxExtension.php">
<InternalClass occurrences="4">
<code>ExpressionParser::OPERATOR_LEFT</code>
<code>ExpressionParser::OPERATOR_LEFT</code>
<code>ExpressionParser::OPERATOR_LEFT</code>
<code>ExpressionParser::OPERATOR_LEFT</code>
</InternalClass>
</file>
<files psalm-version="5.23.1@8471a896ccea3526b26d082f4461eeea467f10a4">
<file src="src/TokenParser/BreakOrContinueTokenParser.php">
<InternalMethod occurrences="3">
<code>getSourceContext</code>
<code>getSourceContext</code>
<code>getSourceContext</code>
<InternalMethod>
<code><![CDATA[getSourceContext]]></code>
<code><![CDATA[getSourceContext]]></code>
<code><![CDATA[getSourceContext]]></code>
</InternalMethod>
<UnsafeInstantiation occurrences="1">
<code>new $nodeClass($loopNumber, $lineno, $this-&gt;getTag())</code>
<UnsafeInstantiation>
<code><![CDATA[new $nodeClass($loopNumber, $lineno, $this->getTag())]]></code>
</UnsafeInstantiation>
</file>
<file src="src/TokenParser/ForeachTokenParser.php">
<InternalMethod occurrences="2">
<code>getSourceContext</code>
<code>parseExpression</code>
<InternalMethod>
<code><![CDATA[getSourceContext]]></code>
</InternalMethod>
</file>
</files>
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="src" />
Expand Down
2 changes: 1 addition & 1 deletion ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
Expand Down
2 changes: 2 additions & 0 deletions src/TokenParser/BreakNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace Squirrel\TwigPhpSyntax\TokenParser;

use Twig\Attribute\YieldReady;
use Twig\Compiler;
use Twig\Node\Node;

#[YieldReady]
class BreakNode extends Node
{
/**
Expand Down
2 changes: 2 additions & 0 deletions src/TokenParser/ContinueNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace Squirrel\TwigPhpSyntax\TokenParser;

use Twig\Attribute\YieldReady;
use Twig\Compiler;
use Twig\Node\Node;

#[YieldReady]
class ContinueNode extends Node
{
/**
Expand Down
4 changes: 2 additions & 2 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

class IntegrationTest extends IntegrationTestCase
{
public function getExtensions()
public function getExtensions(): array
{
return [
new PhpSyntaxExtension(),
];
}

public function getFixturesDir()
public function getFixturesDir(): string
{
return __DIR__ . '/Fixtures/';
}
Expand Down
9 changes: 7 additions & 2 deletions vendor-bin/phpcs/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"require": {
"squizlabs/php_codesniffer": "^3.5",
"slevomat/coding-standard": "^7.0"
"squizlabs/php_codesniffer": "^3.7.2",
"slevomat/coding-standard": "^8.0"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
2 changes: 1 addition & 1 deletion vendor-bin/psalm/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"vimeo/psalm": "^4.0"
"vimeo/psalm": "^5.0"
}
}

0 comments on commit c71b02f

Please sign in to comment.