Skip to content

Commit

Permalink
Set minim PHP version to PHP8
Browse files Browse the repository at this point in the history
- Adapt to new Attribute directory instead of the
  previous Annotation directory from underlying
  strings library (BC break)
- Cover tests with Psalm
  • Loading branch information
iquito committed Jun 15, 2021
1 parent 8eb0379 commit 00e2a3a
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 27 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ env:
- XDEBUG_MODE=coverage
language: php
php:
- '7.4'
- '8.0'

before_script:
Expand All @@ -18,8 +17,8 @@ before_script:

script:
- composer phpunit_clover
- if [ "${TRAVIS_PHP_VERSION:0:1}" == "8" ]; then composer phpstan; fi
- if [ "${TRAVIS_PHP_VERSION:0:1}" == "8" ]; then composer psalm; fi
- composer phpstan
- composer psalm
- composer phpcs
- if [ "$TRAVIS_PULL_REQUEST" == "false" -a "${TRAVIS_PHP_VERSION:0:1}" == "8" ]; then ./cc-test-reporter after-build -t clover --exit-code $TRAVIS_TEST_RESULT; fi

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
}
],
"require": {
"php": ">=7.4",
"php": ">=8.0",
"symfony/dependency-injection": "^5.0",
"squirrelphp/strings": "^0.9.3"
"squirrelphp/strings": "^0.10"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.3",
Expand Down
2 changes: 2 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.7.3@38c452ae584467e939d55377aaf83b5a26f19dd1"/>
7 changes: 7 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="src" />
<directory name="tests" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
<pluginClass class="Psalm\MockeryPlugin\Plugin"/>
</plugins>
</psalm>
22 changes: 22 additions & 0 deletions ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,26 @@
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation"/>
<rule ref="SlevomatCodingStandard.Functions.StrictCall"/>
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<rule ref="SlevomatCodingStandard.PHP.DisallowReference"/>
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable"/>
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/>
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat"/>
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding"/>
</ruleset>
5 changes: 2 additions & 3 deletions src/DependencyInjection/Compiler/ExtensionPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Squirrel\StringsBundle\DependencyInjection\Compiler;

use Squirrel\Strings\Annotation\StringFilterExtension;
use Squirrel\Strings\Annotation\StringFilterProcessor;
use Squirrel\Strings\Attribute\StringFilterExtension;
use Squirrel\Strings\Attribute\StringFilterProcessor;
use Squirrel\Strings\RandomStringGeneratorSelectInterface;
use Squirrel\Strings\StringFilterSelectInterface;
use Squirrel\Strings\Twig\StringExtension;
Expand All @@ -22,7 +22,6 @@ class ExtensionPass implements CompilerPassInterface
public function process(ContainerBuilder $container): void
{
$container->setDefinition(StringFilterProcessor::class, new Definition(StringFilterProcessor::class, [
new Reference('annotation_reader'),
new Reference(StringFilterSelectInterface::class),
]));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function process(ContainerBuilder $container): void

// Get all random string generator services and create constructor argument for Selector
$taggedServicesWithNames = $this->createGeneratorDefinitionList(
$container->findTaggedServiceIds('squirrel.strings.random')
$container->findTaggedServiceIds('squirrel.strings.random'),
);

// Add generators to Selector class
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/StringFilterPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function process(ContainerBuilder $container): void

// Get all string filter services and create constructor argument for Selector
$taggedServicesWithNames = $this->createFilterDefinitionList(
$container->findTaggedServiceIds('squirrel.strings.filter')
$container->findTaggedServiceIds('squirrel.strings.filter'),
);

// Add filters to Selector class
Expand Down
10 changes: 5 additions & 5 deletions tests/ExtensionPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Squirrel\StringsBundle\Tests;

use Squirrel\Strings\Annotation\StringFilterExtension;
use Squirrel\Strings\Annotation\StringFilterProcessor;
use Squirrel\Strings\Attribute\StringFilterExtension;
use Squirrel\Strings\Attribute\StringFilterProcessor;
use Squirrel\Strings\Filter\TrimFilter;
use Squirrel\Strings\StringFilterSelectInterface;
use Squirrel\Strings\Twig\StringExtension;
Expand All @@ -15,7 +15,7 @@

class ExtensionPassTest extends \PHPUnit\Framework\TestCase
{
public function testNoFormNoTwig()
public function testNoFormNoTwig(): void
{
$container = new ContainerBuilder();

Expand All @@ -32,7 +32,7 @@ public function testNoFormNoTwig()
$container->compile();
}

public function testFormAndTwig()
public function testFormAndTwig(): void
{
$container = new ContainerBuilder();

Expand All @@ -54,7 +54,7 @@ public function testFormAndTwig()
$container->compile();
}

protected function processCompilerPass(ContainerBuilder $container)
protected function processCompilerPass(ContainerBuilder $container): void
{
(new StringFilterPass())->process($container);
(new RandomStringGeneratorPass())->process($container);
Expand Down
8 changes: 4 additions & 4 deletions tests/RandomStringGeneratorPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class RandomStringGeneratorPassTest extends \PHPUnit\Framework\TestCase
{
public function testDefault()
public function testDefault(): void
{
$container = new ContainerBuilder();

Expand All @@ -34,7 +34,7 @@ public function testDefault()
$container->compile();
}

public function testNoGeneratorName()
public function testNoGeneratorName(): void
{
$this->expectException(StringException::class);

Expand All @@ -50,7 +50,7 @@ public function testNoGeneratorName()
$this->processCompilerPass($container);
}

public function testDuplicateGeneratorName()
public function testDuplicateGeneratorName(): void
{
$this->expectException(StringException::class);

Expand All @@ -66,7 +66,7 @@ public function testDuplicateGeneratorName()
$this->processCompilerPass($container);
}

protected function processCompilerPass(ContainerBuilder $container)
protected function processCompilerPass(ContainerBuilder $container): void
{
(new RandomStringGeneratorPass())->process($container);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/StringFilterPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class StringFilterPassTest extends \PHPUnit\Framework\TestCase
{
public function testDefault()
public function testDefault(): void
{
$container = new ContainerBuilder();

Expand All @@ -36,7 +36,7 @@ public function testDefault()
$container->compile();
}

public function testNoFilterName()
public function testNoFilterName(): void
{
$this->expectException(StringException::class);

Expand All @@ -53,7 +53,7 @@ public function testNoFilterName()
$this->processCompilerPass($container);
}

public function testDuplicateFilterName()
public function testDuplicateFilterName(): void
{
$this->expectException(StringException::class);

Expand All @@ -70,7 +70,7 @@ public function testDuplicateFilterName()
$this->processCompilerPass($container);
}

protected function processCompilerPass(ContainerBuilder $container)
protected function processCompilerPass(ContainerBuilder $container): void
{
(new StringFilterPass())->process($container);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/StringTesterPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class StringTesterPassTest extends \PHPUnit\Framework\TestCase
{
public function testDefault()
public function testDefault(): void
{
$container = new ContainerBuilder();

Expand All @@ -25,7 +25,7 @@ public function testDefault()
$container->compile();
}

protected function processCompilerPass(ContainerBuilder $container)
protected function processCompilerPass(ContainerBuilder $container): void
{
(new StringTesterPass())->process($container);
}
Expand Down
2 changes: 1 addition & 1 deletion vendor-bin/phpcs/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"squizlabs/php_codesniffer": "^3.5",
"slevomat/coding-standard": "^6.0"
"slevomat/coding-standard": "^7.0"
}
}
4 changes: 3 additions & 1 deletion vendor-bin/psalm/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"require": {
"vimeo/psalm": "^4.0"
"vimeo/psalm": "^4.0",
"psalm/plugin-phpunit": "^0.16",
"psalm/plugin-mockery": "^0.7"
}
}

0 comments on commit 00e2a3a

Please sign in to comment.