Skip to content

Commit

Permalink
Merge pull request #32 from janlam7/phpcs-tool-9
Browse files Browse the repository at this point in the history
Update phpcs-tool to 9.1.0 with Hostnet-Level-1
  • Loading branch information
janlam7 committed May 4, 2022
2 parents 1873611 + 41da694 commit 6ac755f
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ jobs:
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: phpunit
run: php vendor/bin/phpunit
- name: phpcs
run: php vendor/bin/phpcs
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"symfony/yaml": "^4.4|^5.0"
},
"require-dev": {
"hostnet/phpcs-tool": "^8.3",
"hostnet/phpcs-tool": "^9.1.0",
"phpunit/phpunit": "^9.5.6",
"symfony/finder": "^5.0"
},
Expand All @@ -32,5 +32,11 @@
"classmap": [
"test/Functional/Fixtures/TestKernel.php"
]
},
"config": {
"allow-plugins": {
"hostnet/*": true,
"dealerdirect/phpcodesniffer-composer-installer": false
}
}
}
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<ruleset name="entity-translation-bundle">
<exclude-pattern>test/Functional/Fixtures/cache/</exclude-pattern>
<exclude-pattern>test/Functional/Fixtures/TestKernel.php</exclude-pattern>
<rule ref="Hostnet" />
<rule ref="Hostnet-Level-1" />
</ruleset>
4 changes: 2 additions & 2 deletions src/DependencyInjection/EnumTranslationCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ protected function registerEnums(ContainerBuilder $container, array $enum_files)

// convert the flatten keys into a list of enum classes.
$enums = array_unique(array_map(function ($str) {
$parts = explode(".", $str);
$parts = explode('.', $str);
array_pop($parts);

return preg_replace_callback(
'/_(.?)/',
function ($matches) {
return strtoupper($matches[1]);
},
implode("\\", array_map('ucfirst', $parts))
implode('\\', array_map('ucfirst', $parts))
);
}, array_keys($this->flattenKeys($translations))));

Expand Down
10 changes: 5 additions & 5 deletions test/DependencyInjection/EnumTranslationCompilerPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class EnumTranslationCompilerPassTest extends TestCase
/**
* @dataProvider processLoadYamlFilesProvider
*/
public function testProcessLoadYamlFiles($resource_path)
public function testProcessLoadYamlFiles($resource_path): void
{
$resources = realpath($resource_path);
$container = new ContainerBuilder();
Expand All @@ -44,7 +44,7 @@ public function processLoadYamlFilesProvider()
yield [__DIR__ . '/../Mock/Resources/translations/enum.en.yaml'];
}

public function testProcess()
public function testProcess(): void
{
$resources = realpath(__DIR__ . '/../Mock/Resources/translations/enum.en.yml');
$container = new ContainerBuilder();
Expand All @@ -63,7 +63,7 @@ public function testProcess()
$this->assertEquals(['addResource', ['enum', $resources, 'en', MockEnum::class]], $calls[0]);
}

public function testProcessNotYml()
public function testProcessNotYml(): void
{
$resources = realpath(__DIR__ . '/../MockXml/Resources/translations/enum.en.xml');
$container = new ContainerBuilder();
Expand All @@ -80,7 +80,7 @@ public function testProcessNotYml()
$pass->process($container);
}

public function testProcessNoTrans()
public function testProcessNoTrans(): void
{
$container = new ContainerBuilder();
$translator = new Definition();
Expand All @@ -98,7 +98,7 @@ public function testProcessNoTrans()
$this->assertEquals(0, count($calls));
}

public function testProcessNoArray()
public function testProcessNoArray(): void
{
$resources = realpath(__DIR__ . '/../MockNoArray/Resources/translations/enum.en.yml');
$container = new ContainerBuilder();
Expand Down
8 changes: 4 additions & 4 deletions test/Functional/Fixtures/Enum/PostStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

final class PostStatus
{
const AWAITING_APPROVAL = 'awaiting approval';
const VISIBLE = 'visible';
const DELETED = 'deleted';
const HIDDEN = 'hidden';
public const AWAITING_APPROVAL = 'awaiting approval';
public const VISIBLE = 'visible';
public const DELETED = 'deleted';
public const HIDDEN = 'hidden';

/**
* @codeCoverageIgnore private by design because this is an ENUM class
Expand Down
4 changes: 2 additions & 2 deletions test/Functional/Fixtures/Enum/ReplyStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

final class ReplyStatus
{
const CLOSED = 0;
const OPEN = 1;
public const CLOSED = 0;
public const OPEN = 1;

/**
* @codeCoverageIgnore private by design because this is an ENUM class
Expand Down
2 changes: 1 addition & 1 deletion test/HostnetEntityTranslationBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
class HostnetEntityTranslationBundleTest extends TestCase
{
public function testBuild()
public function testBuild(): void
{
$container = new ContainerBuilder();

Expand Down
6 changes: 3 additions & 3 deletions test/Mock/MockEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class MockEnum
{
const FOO = 1;
const BAR = 2;
const FOO_BAR = 3;
public const FOO = 1;
public const BAR = 2;
public const FOO_BAR = 3;
}
6 changes: 3 additions & 3 deletions test/MockArray/MockArrayEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class MockArrayEnum
{
const FOO = 1;
const BAR = 2;
const FOO_ARRAY = [1, 2];
public const FOO = 1;
public const BAR = 2;
public const FOO_ARRAY = [1, 2];
}
6 changes: 3 additions & 3 deletions test/MockNoArray/MockNoArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class MockNoArray
{
const FOO = 1;
const BAR = 2;
const FOO_BAR = 3;
public const FOO = 1;
public const BAR = 2;
public const FOO_BAR = 3;
}
6 changes: 3 additions & 3 deletions test/MockNoTrans/MockNoTransEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class MockNoTransEnum
{
const FOO = 1;
const BAR = 2;
const FOO_BAR = 3;
public const FOO = 1;
public const BAR = 2;
public const FOO_BAR = 3;
}
6 changes: 3 additions & 3 deletions test/MockXml/MockXmlEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class MockXmlEnum
{
const FOO = 1;
const BAR = 2;
const FOO_BAR = 3;
public const FOO = 1;
public const BAR = 2;
public const FOO_BAR = 3;
}

0 comments on commit 6ac755f

Please sign in to comment.