diff --git a/cli/ConfigValidation/ValidateConfigCommand.php b/cli/ConfigValidation/ValidateConfigCommand.php index 357a51b90..5fada70e7 100644 --- a/cli/ConfigValidation/ValidateConfigCommand.php +++ b/cli/ConfigValidation/ValidateConfigCommand.php @@ -24,9 +24,9 @@ class ValidateConfigCommand extends Command { const NAME = 'validate-config'; const DEFAULT_SCHEMA = __DIR__ . '/../../app/config/schema.json'; const ERROR_RETURN_CODE = 1; + const OK_RETURN_CODE = 0; - protected function configure() - { + protected function configure(): void { $this->setName( self::NAME ) ->setDescription( 'Validate configuration files' ) ->setHelp( 'This command merges the specified configuration files and validates them against a JSON schema' ) @@ -50,8 +50,7 @@ protected function configure() ); } - protected function execute( InputInterface $input, OutputInterface $output ) - { + protected function execute( InputInterface $input, OutputInterface $output ): int { $configObject = $this->loadConfigObjectFromFiles( $input->getArgument( 'config_file' ) ); if ( $input->getOption( 'dump-config' ) ) { @@ -66,7 +65,7 @@ protected function execute( InputInterface $input, OutputInterface $output ) ); if ( $validator->passes() ) { - return null; + return self::OK_RETURN_CODE; } $renderer = new ValidationErrorRenderer( $schema ); @@ -78,8 +77,9 @@ protected function execute( InputInterface $input, OutputInterface $output ) } /** - * @param array $configFiles * @throws \RuntimeException + * @param array $configFiles + * @return \stdClass */ private function loadConfigObjectFromFiles( array $configFiles ): \stdClass { $configReader = new ConfigReader( diff --git a/cli/FundraisingCli.php b/cli/FundraisingCli.php index b10f6ae06..500c32efc 100644 --- a/cli/FundraisingCli.php +++ b/cli/FundraisingCli.php @@ -18,7 +18,7 @@ class FundraisingCli { */ private $app; - public function newApplication() :Application { + public function newApplication(): Application { $this->app = new Application(); $this->setApplicationInfo(); $this->registerCommands(); diff --git a/composer.json b/composer.json index ace48a2a8..c651c5d0d 100644 --- a/composer.json +++ b/composer.json @@ -71,8 +71,9 @@ "mikey179/vfsStream": "~1.6", "wmde/psr-log-test-doubles": "~2.1", - "squizlabs/php_codesniffer": "~2.7", + "squizlabs/php_codesniffer": "~2.8", "phpmd/phpmd": "~2.3", + "slevomat/coding-standard": "^2.3", "symfony/browser-kit": "^3.2", "silex/web-profiler": "~2.0", @@ -116,7 +117,7 @@ "@validate-app-config" ], "phpcs": [ - "vendor/bin/phpcs src/ tests/ contexts/ cli/ --standard=phpcs.xml --extensions=php -sp" + "vendor/bin/phpcs" ], "phpmd": [ "vendor/bin/phpmd src/ text phpmd.xml" diff --git a/composer.lock b/composer.lock index 1e96dcfe8..77a339813 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "90bc84305c1531583310c88094e92d3c", + "content-hash": "5dffd6dd7c0ad857fbd14d4f443f7c53", "packages": [ { "name": "addwiki/mediawiki-api-base", @@ -4193,6 +4193,43 @@ "homepage": "http://silex.sensiolabs.org/", "time": "2017-04-23T23:11:39+00:00" }, + { + "name": "slevomat/coding-standard", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/slevomat/coding-standard.git", + "reference": "aa73a1122ca38ead2c3b07e3086b3b7dd796d018" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/aa73a1122ca38ead2c3b07e3086b3b7dd796d018", + "reference": "aa73a1122ca38ead2c3b07e3086b3b7dd796d018", + "shasum": "" + }, + "require": { + "php": "^7.0", + "squizlabs/php_codesniffer": "~2.8.1" + }, + "require-dev": { + "jakub-onderka/php-parallel-lint": "0.9.2", + "phing/phing": "2.16", + "phpstan/phpstan": "0.6.4", + "phpunit/phpunit": "6.1.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "SlevomatCodingStandard\\": "SlevomatCodingStandard" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Slevomat Coding Standard for PHP_CodeSniffer extends Consistence Coding Standard by providing sniffs with additional checks.", + "time": "2017-05-04T14:02:28+00:00" + }, { "name": "sorien/silex-dbal-profiler", "version": "2.0.0", diff --git a/contexts/DonationContext/src/Validation/DonorValidator.php b/contexts/DonationContext/src/Validation/DonorValidator.php index a10c4f32c..2a4987be6 100644 --- a/contexts/DonationContext/src/Validation/DonorValidator.php +++ b/contexts/DonationContext/src/Validation/DonorValidator.php @@ -1,5 +1,7 @@ ValidPayPalNotificationRequest::PAYER_ID, 'paypal_subscr_id' => ValidPayPalNotificationRequest::SUBSCRIBER_ID, diff --git a/contexts/DonationContext/tests/Integration/DataAccess/DoctrineDonationEventLoggerTest.php b/contexts/DonationContext/tests/Integration/DataAccess/DoctrineDonationEventLoggerTest.php index 8de14eae9..1352cd6e8 100644 --- a/contexts/DonationContext/tests/Integration/DataAccess/DoctrineDonationEventLoggerTest.php +++ b/contexts/DonationContext/tests/Integration/DataAccess/DoctrineDonationEventLoggerTest.php @@ -1,5 +1,6 @@ + + src/ + tests/ + contexts/ + cli/ + + + + + - @@ -32,8 +41,7 @@ - - + @@ -112,4 +120,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Factories/FunFunFactory.php b/src/Factories/FunFunFactory.php index 26e3d3a81..37f9fc84d 100644 --- a/src/Factories/FunFunFactory.php +++ b/src/Factories/FunFunFactory.php @@ -428,10 +428,10 @@ private function newPimple(): Container { }; $pimple['content_page_selector'] = function () { - $json = (new SimpleFileFetcher())->fetchFile($this->getI18nDirectory() . '/data/pages.json'); - $config = json_decode($json, true) ?? []; + $json = (new SimpleFileFetcher())->fetchFile( $this->getI18nDirectory() . '/data/pages.json' ); + $config = json_decode( $json, true ) ?? []; - return new PageSelector($config); + return new PageSelector( $config ); }; $pimple['content_provider'] = function () { diff --git a/src/Factories/TwigFactory.php b/src/Factories/TwigFactory.php index 39ed6184e..22d76e060 100644 --- a/src/Factories/TwigFactory.php +++ b/src/Factories/TwigFactory.php @@ -20,13 +20,13 @@ class TwigFactory { private $cachePath; private $locale; - public function __construct(array $config, string $cachePath, string $locale) { + public function __construct( array $config, string $cachePath, string $locale ) { $this->config = $config; $this->cachePath = $cachePath; $this->locale = $locale; } - public function newFileSystemLoader(): ? Twig_Loader_Filesystem { + public function newFileSystemLoader(): ?Twig_Loader_Filesystem { if ( empty( $this->config['loaders']['filesystem'] ) ) { return null; } @@ -84,6 +84,6 @@ public function newFilePrefixFilter( FilePrefixer $filePrefixer ) { } public function newTwigEnvironmentConfigurator() { - return new TwigEnvironmentConfigurator($this->config, $this->cachePath); + return new TwigEnvironmentConfigurator( $this->config, $this->cachePath ); } } \ No newline at end of file diff --git a/src/Infrastructure/PiwikEvents.php b/src/Infrastructure/PiwikEvents.php index a8e9a2936..0ff0f5577 100644 --- a/src/Infrastructure/PiwikEvents.php +++ b/src/Infrastructure/PiwikEvents.php @@ -1,5 +1,7 @@ composeRegex( [ preg_quote( $badMatch, '#' ) ] ), $whiteMatch ); diff --git a/tests/EdgeToEdge/TranslatorTest.php b/tests/EdgeToEdge/TranslatorTest.php index 0da774a04..5d6adfb28 100644 --- a/tests/EdgeToEdge/TranslatorTest.php +++ b/tests/EdgeToEdge/TranslatorTest.php @@ -17,7 +17,7 @@ class TranslatorTest extends WebRouteTestCase { public function testGivenDefinedMessageKey_responseContainsTranslatedMessages() { $client = $this->createClient( [], - function (FunFunFactory $factory) { + function ( FunFunFactory $factory ) { $factory->setTranslator( $this->newTranslator( [ 'page_not_found' => 'Seite nicht gefunden' ], 'de' ) ); } ); diff --git a/tests/Integration/Factories/TranslationFactoryTest.php b/tests/Integration/Factories/TranslationFactoryTest.php index 0186c365e..c0d26522c 100644 --- a/tests/Integration/Factories/TranslationFactoryTest.php +++ b/tests/Integration/Factories/TranslationFactoryTest.php @@ -8,7 +8,8 @@ use WMDE\Fundraising\Frontend\Factories\TranslationFactory; class TranslationFactoryTest extends \PHPUnit\Framework\TestCase { - public function testLoadersAreSet(){ + + public function testLoadersAreSet(): void { $factory = new TranslationFactory(); $loader = new ArrayLoader(); $translator = $factory->create( ['array' => $loader] ); diff --git a/tests/Integration/Presentation/Presenters/DonationConfirmationHtmlPresenterTest.php b/tests/Integration/Presentation/Presenters/DonationConfirmationHtmlPresenterTest.php index 546649e16..b944dd17e 100644 --- a/tests/Integration/Presentation/Presenters/DonationConfirmationHtmlPresenterTest.php +++ b/tests/Integration/Presentation/Presenters/DonationConfirmationHtmlPresenterTest.php @@ -1,5 +1,7 @@ createMock( TextPolicyValidator::class ); $textPolicy->method( $this->anything() )->willReturn( true ); $validator = new FieldTextPolicyValidator( $textPolicy ); $this->assertTrue( $validator->validate( 'tiny cat' )->isSuccessful() ); } - public function testGivenHarmfulText_itFails(){ + public function testGivenHarmfulText_itFails(): void { $textPolicy = $this->createMock( TextPolicyValidator::class ); $textPolicy->method( $this->anything() )->willReturn( false ); $validator = new FieldTextPolicyValidator( $textPolicy ); $this->assertFalse( $validator->validate( 'mean tiger' )->isSuccessful() ); } - public function testGivenHarmfulText_itProvidesAConstraintViolation(){ + public function testGivenHarmfulText_itProvidesAConstraintViolation(): void { $textPolicy = $this->createMock( TextPolicyValidator::class ); $textPolicy->method( $this->anything() )->willReturn( false ); $validator = new FieldTextPolicyValidator( $textPolicy );