Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Install coding-standard and php_codesniffer #471

Merged
merged 1 commit into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@
'no_unused_imports' => true,
'concat_space' => ['spacing' => 'one'],
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'ordered_imports' => [
'imports_order' => [
'class',
'function',
'const',
],
'sort_algorithm' => 'none',
],
'single_quote' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
Expand Down
2 changes: 1 addition & 1 deletion Resources/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
use TYPO3\Surf\Cli\Symfony\ConsoleApplication;
use TYPO3\Surf\Cli\Symfony\ConsoleOutputFactory;
use TYPO3\Surf\Cli\Symfony\Logger\ConsoleHandler;
Expand All @@ -18,6 +17,7 @@
use TYPO3\Surf\Domain\Model\SimpleWorkflow;
use TYPO3\Surf\Integration\Factory;
use TYPO3\Surf\Integration\FactoryInterface;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
Expand Down
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"phpstan/phpstan-webmozart-assert": "^1.0",
"phpunit/phpunit": "^8.0",
"rector/rector": "^0.12",
"slevomat/coding-standard": "^7.0",
"squizlabs/php_codesniffer": "^3.6",
"timeweb/phpstan-enum": "^3.0"
},
"config": {
Expand All @@ -37,7 +39,8 @@
},
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"extra": {
Expand All @@ -62,6 +65,9 @@
"bin/surf"
],
"scripts": {
"phpstan": "phpstan analyse --ansi"
"phpstan": "phpstan analyse --ansi",
"php-cs-fixer": "vendor/bin/php-cs-fixer fix --diff",
"check-style": "vendor/bin/phpcs -p --standard=ruleset.xml --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests",
"fix-style": "vendor/bin/phpcbf -p --standard=ruleset.xml --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests"
}
}
172 changes: 157 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
<!-- include all sniffs in the PSR2 standard -->
<rule ref="PSR2"/>

<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="300"/>
<property name="absoluteLineLimit" value="0"/>
</properties>
</rule>

<rule ref="vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Namespaces/AlphabeticallySortedUsesSniff.php">
<properties>
<property name="caseSensitive" value="true"/>
<property name="caseSensitive" value="false"/>
</properties>
</rule>

Expand Down
15 changes: 7 additions & 8 deletions src/Task/Test/HttpTestTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\RequestException;
use function GuzzleHttp\headers_from_lines;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use TYPO3\Surf\Domain\Model\Application;
Expand All @@ -24,6 +23,7 @@
use TYPO3\Surf\Domain\Service\ShellCommandServiceAwareInterface;
use TYPO3\Surf\Domain\Service\ShellCommandServiceAwareTrait;
use TYPO3\Surf\Exception\TaskExecutionException;
use function GuzzleHttp\headers_from_lines;

/**
* A task for testing HTTP request
Expand Down Expand Up @@ -160,17 +160,16 @@ protected function testSingleHeader(string $headerValue, string $expectedValue):
return false;
}

// = Value equals
if (strpos($expectedValue, '=') === 0) {
// = Value equals
$result = $headerValue === trim(substr($expectedValue, 1));
} // < Intval smaller than
elseif (strpos($expectedValue, '<') === 0) {
} elseif (strpos($expectedValue, '<') === 0) {
// < Intval smaller than
$result = (int)$headerValue < (int)substr($expectedValue, 1);
} // > Intval bigger than
elseif (strpos($expectedValue, '>') === 0) {
} elseif (strpos($expectedValue, '>') === 0) {
// > Intval bigger than
$result = (int)$headerValue > (int)substr($expectedValue, 1);
} // Default
else {
} else {
$result = $headerValue === $expectedValue;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Domain/Model/SimpleWorkflowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ protected function buildDeployment(array &$executedTasks = [])
$mockLogger = $this->createMock(LoggerInterface::class);
// Enable log to console to debug tests
// $mockLogger->expects(self::any())->method('log')->will($this->returnCallback(function($message) {
// echo $message . chr(10);
// echo $message . chr(10);
// }));
$deployment->setLogger($mockLogger);

Expand Down
27 changes: 27 additions & 0 deletions tests/Unit/Domain/Service/CustomTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace TYPO3\Surf\Tests\Unit\Domain\Service;

use TYPO3\Surf\Domain\Model\Application;
use TYPO3\Surf\Domain\Model\Deployment;
use TYPO3\Surf\Domain\Model\Node;
use TYPO3\Surf\Domain\Model\Task;
use TYPO3\Surf\Domain\Service\ShellCommandService;
use TYPO3\Surf\Domain\Service\ShellCommandServiceAwareInterface;
use TYPO3\Surf\Domain\Service\ShellCommandServiceAwareTrait;

class CustomTask extends Task implements ShellCommandServiceAwareInterface
{
use ShellCommandServiceAwareTrait;

public function execute(Node $node, Application $application, Deployment $deployment, array $options = []): void
{
}

public function getShell(): ShellCommandService
{
return $this->shell;
}
}
Loading