Skip to content

Commit

Permalink
#22 - bugfixes (also: #21, #14) (#23)
Browse files Browse the repository at this point in the history
* #22 - double quote fixer bugfix

* #21 - deprecation fix

* #14 - missing dev-dependencies added

* #22 - Docker removed from GHA
  • Loading branch information
krzysztofrewak authored May 18, 2021
1 parent d8e4a5b commit fa02efc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
1 change: 0 additions & 1 deletion .env.example

This file was deleted.

11 changes: 4 additions & 7 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Run the Docker containers
run: docker-compose up -d

- name: Cache composer dependencies
uses: actions/cache@v2
with:
Expand All @@ -25,13 +22,13 @@ jobs:
${{ runner.os }}-composer-
- name: Validate composer.json
run: docker-compose run php composer validate
run: composer validate

- name: Install dependencies
run: docker-compose run php composer install --prefer-dist --no-progress --no-suggest
run: composer install --prefer-dist --no-progress

- name: Run code style checker
run: docker-compose run php composer ecs
run: composer ecs

- name: Run tests
run: docker-compose run php composer test
run: composer test
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"type": "library",
"require": {
"php": "^8.0",
"symplify/easy-coding-standard": "^9.2"
"symplify/easy-coding-standard": "^9.3.12"
},
"require-dev": {
"jetbrains/phpstorm-attributes": "^1.0",
"phpunit/phpunit": "^9.5"
},
"authors": [
{
Expand All @@ -26,8 +30,5 @@
"ecs": "./vendor/bin/ecs check",
"ecsf": "./vendor/bin/ecs check --fix",
"test": "./vendor/bin/phpunit tests --colors always"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
}
}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ services:
image: ghcr.io/blumilksoftware/php:8.0.3.1
container_name: blumilk-codestyle-php
working_dir: /application
user: ${CURRENT_UID}
user: ${CURRENT_UID:-1000}
volumes:
- .:/application
7 changes: 4 additions & 3 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Blumilk\Codestyle\Configuration\SetLists;
use Blumilk\Codestyle\Configuration\SkippedRules;
use JetBrains\PhpStorm\ArrayShape;
use JetBrains\PhpStorm\Pure;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator as Container;
use Symplify\EasyCodingStandard\ValueObject\Option;

Expand All @@ -24,7 +23,6 @@ class Config
protected SkippedRules $skipped;
protected AdditionalRules $rules;

#[Pure]
public function __construct(
?Paths $paths = null,
?SetLists $sets = null,
Expand All @@ -43,10 +41,13 @@ public function config(): callable

return static function (Container $container) use ($sets, $skipped, $rules, $paths): void {
$parameters = $container->parameters();
$parameters->set(Option::SETS, $sets);
$parameters->set(Option::SKIP, $skipped);
$parameters->set(Option::PATHS, $paths);

foreach ($sets as $set) {
$container->import($set);
}

$services = $container->services();
foreach ($rules as $rule => $configuration) {
$service = $services->set($rule);
Expand Down
7 changes: 5 additions & 2 deletions src/Fixers/DoubleQuoteFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PhpCsFixer\AbstractFixer;
use PhpCsFixer\FixerDefinition\CodeSample;
use PhpCsFixer\FixerDefinition\FixerDefinition;
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;
use SplFileInfo;

Expand Down Expand Up @@ -34,12 +35,13 @@ public function isCandidate(Tokens $tokens): bool

protected function applyFix(SplFileInfo $file, Tokens $tokens): void
{
foreach ($tokens as $token) {
foreach ($tokens as $index => $token) {
if (!$token->isGivenKind(T_CONSTANT_ENCAPSED_STRING)) {
continue;
}

$content = $token->getContent();
$prefix = "";
if (
$content[0] === "'" &&
!str_contains($content, '"') &&
Expand All @@ -49,7 +51,8 @@ protected function applyFix(SplFileInfo $file, Tokens $tokens): void
$content = substr($content, 1, -1);
$content = str_replace("\\'", "'", $content);
$content = str_replace("\\$", "$", $content);
$token->setContent("\"" . $content . "\"");

$tokens[$index] = new Token([T_CONSTANT_ENCAPSED_STRING, $prefix . "\"" . $content . "\""]);
}
}
}
Expand Down

0 comments on commit fa02efc

Please sign in to comment.