Skip to content

Commit

Permalink
Update cs-fixer config and apply it
Browse files Browse the repository at this point in the history
  • Loading branch information
theseer committed Dec 12, 2020
1 parent dd023ed commit 55d3140
Show file tree
Hide file tree
Showing 314 changed files with 4,188 additions and 785 deletions.
77 changes: 55 additions & 22 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,37 @@

require __DIR__ . '/tools/php-cs-fixer.d/PhpdocSingleLineVarFixer.php';

$header = file_get_contents(__DIR__ . '/tools/php-cs-fixer.d/header.txt');

return PhpCsFixer\Config::create()
->registerCustomFixers([
new \PharIo\CSFixer\PhpdocSingleLineVarFixer()
])
->setRiskyAllowed(true)
->setRules(
[
'PharIo/phpdoc_single_line_var_fixer' => true,
'PharIo/phpdoc_single_line_var_fixer' => true,

'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'operators' => [
'=' => 'align_single_space_minimal',
'=>' => 'align',
],
],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => false,
'blank_line_before_statement' => [
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => false,
'blank_line_before_statement' => [
'statements' => [
'break',
'continue',
'declare',
'default',
'die',
'do',
'exit',
'for',
'foreach',
'if',
Expand All @@ -43,13 +48,13 @@ return PhpCsFixer\Config::create()
'yield',
],
],
'braces' => [
'braces' => [
'allow_single_line_closure' => false,
'position_after_anonymous_constructs' => 'same',
'position_after_control_structures' => 'same',
'position_after_functions_and_oop_constructs' => 'same'
],
'cast_spaces' => ['space' => 'none'],
'cast_spaces' => ['space' => 'none'],

// This fixer removes the blank line at class start, no way to disable that, so we disable the fixer :(
//'class_attributes_separation' => ['elements' => ['const', 'method', 'property']],
Expand All @@ -64,12 +69,21 @@ return PhpCsFixer\Config::create()
'dir_constant' => true,
'elseif' => true,
'encoding' => true,
'explicit_indirect_variable' => true,
'explicit_string_variable' => true,
'full_opening_tag' => true,
'fully_qualified_strict_types' => true,
'function_declaration' => [
'closure_function_spacing' => 'one'
'function_declaration' => true,
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
'header_comment' => ['header' => $header, 'separate' => 'none'],
'heredoc_to_nowdoc' => true,
'increment_style' => [
'style' => PhpCsFixer\Fixer\Operator\IncrementStyleFixer::STYLE_POST,
],
'header_comment' => false,
'indentation_type' => true,
'is_null' => true,
'line_ending' => true,
Expand All @@ -80,13 +94,15 @@ return PhpCsFixer\Config::create()
'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'magic_method_casing' => true,
'method_argument_space' => ['ensure_fully_multiline' => true],
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => true,
'native_constant_invocation' => true,
'native_function_casing' => true,
'native_function_invocation' => true,
'native_constant_invocation' => false,
'native_function_casing' => false,
'native_function_invocation' => false,
'native_function_type_declaration_casing' => true,
'new_with_braces' => false,
'no_alias_functions' => true,
'no_alternative_syntax' => true,
Expand All @@ -109,9 +125,12 @@ return PhpCsFixer\Config::create()
'no_short_echo_tag' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
],
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
Expand Down Expand Up @@ -153,10 +172,20 @@ return PhpCsFixer\Config::create()
'method_private_static',
],
],
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'ordered_imports' => [
'imports_order' => [
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CONST,
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_FUNCTION,
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CLASS,
]
],
'ordered_interfaces' => [
'direction' => 'ascend',
'order' => 'alpha',
],
'phpdoc_add_missing_param_annotation' => false,
'phpdoc_align' => true,
'phpdoc_annotation_without_dot' => true,
'phpdoc_annotation_without_dot' => false,
'phpdoc_indent' => true,
'phpdoc_no_access' => true,
'phpdoc_no_empty_return' => true,
Expand All @@ -166,6 +195,7 @@ return PhpCsFixer\Config::create()
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_to_comment' => false,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
Expand All @@ -177,16 +207,19 @@ return PhpCsFixer\Config::create()
'protected_to_private' => true,
'return_assignment' => true,
'return_type_declaration' => ['space_before' => 'none'],
'self_accessor' => false,
'self_accessor' => true,
'self_static_accessor' => true,
'semicolon_after_instruction' => true,
'set_type_to_cast' => true,
'short_scalar_cast' => true,
'simplified_null_return' => true,
'simple_to_complex_string_variable' => true,
'simplified_null_return' => false,
'single_blank_line_at_eof' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'standardize_not_equals' => true,
'strict_param' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline_array' => false,
'trim_array_spaces' => true,
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Phar.io - Phive

Copyright (c) 2015-2017 Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors
Copyright (c) 2015-2020 Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
15 changes: 13 additions & 2 deletions src/Factory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<?php declare(strict_types = 1);
/*
* This file is part of Phive.
*
* Copyright (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Phive;

use const PHP_OS;
use function getcwd;
use PharIo\GnuPG\Factory as GnuPGFactory;
use PharIo\Version\VersionConstraintParser;

Expand Down Expand Up @@ -50,7 +61,7 @@ public function getHelpCommand(): HelpCommand {

public function getSkelCommand(): SkelCommand {
return new SkelCommand(
new SkelCommandConfig($this->request->parse(new SkelContext()), \getcwd()),
new SkelCommandConfig($this->request->parse(new SkelContext()), getcwd()),
$this->getOutput(),
$this->getPhiveVersion()
);
Expand Down Expand Up @@ -325,7 +336,7 @@ private function getGit(): Git {

private function getEnvironment(): Environment {
if (null === $this->environment) {
$this->environment = (new EnvironmentLocator())->getEnvironment(\PHP_OS);
$this->environment = (new EnvironmentLocator())->getEnvironment(PHP_OS);
}

return $this->environment;
Expand Down
13 changes: 12 additions & 1 deletion src/GithubAliasResolverException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php declare(strict_types = 1);
/*
* This file is part of Phive.
*
* Copyright (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Phive;

class GithubAliasResolverException extends \Exception {
use Exception;

class GithubAliasResolverException extends Exception {
}
9 changes: 9 additions & 0 deletions src/PhiveContext.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?php declare(strict_types = 1);
/*
* This file is part of Phive.
*
* Copyright (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Phive;

use PharIo\Phive\Cli\GeneralContext;
Expand Down
13 changes: 12 additions & 1 deletion src/commands/CommandLocator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<?php declare(strict_types = 1);
/*
* This file is part of Phive.
*
* Copyright (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Phive;

use function sprintf;

class CommandLocator implements Cli\CommandLocator {

/** @var Factory */
Expand Down Expand Up @@ -81,7 +92,7 @@ public function getCommand(string $command): Cli\Command {

default: {
throw new Cli\CommandLocatorException(
\sprintf('Command "%s" is not a valid command', $command),
sprintf('Command "%s" is not a valid command', $command),
Cli\CommandLocatorException::UnknownCommand
);
}
Expand Down
13 changes: 12 additions & 1 deletion src/commands/composer/ComposerCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<?php declare(strict_types = 1);
/*
* This file is part of Phive.
*
* Copyright (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Phive;

use function sprintf;

class ComposerCommand extends InstallCommand {

/** @var ComposerService */
Expand All @@ -26,7 +37,7 @@ public function execute(): void {
$targetDirectory = $this->getConfig()->getTargetDirectory();

foreach ($this->composerService->findCandidates($this->getConfig()->getComposerFilename()) as $candidate) {
if (!$this->input->confirm(\sprintf('Install %s ?', $candidate->asString()))) {
if (!$this->input->confirm(sprintf('Install %s ?', $candidate->asString()))) {
continue;
}
$this->installRequestedPhar($candidate, $targetDirectory);
Expand Down
9 changes: 9 additions & 0 deletions src/commands/composer/ComposerCommandConfig.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?php declare(strict_types = 1);
/*
* This file is part of Phive.
*
* Copyright (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Phive;

use PharIo\FileSystem\Directory;
Expand Down
9 changes: 9 additions & 0 deletions src/commands/composer/ComposerContext.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?php declare(strict_types = 1);
/*
* This file is part of Phive.
*
* Copyright (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Phive;

use PharIo\Phive\Cli\GeneralContext;
Expand Down
18 changes: 15 additions & 3 deletions src/commands/composer/ComposerService.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<?php declare(strict_types = 1);
/*
* This file is part of Phive.
*
* Copyright (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Phive;

use function sprintf;
use Exception;
use InvalidArgumentException;
use PharIo\FileSystem\Filename;
use PharIo\Version\VersionConstraintParser;

Expand All @@ -25,7 +37,7 @@ public function findCandidates(Filename $composerFilename): array {
$aliasName = $this->sourcesList->getAliasForComposerAlias(new ComposerAlias($required));
$versionConstraint = $parser->parse($constraint);
$list[] = new RequestedPhar(new PharAlias($aliasName), $versionConstraint, $versionConstraint);
} catch (\Exception $e) {
} catch (Exception $e) {
continue;
}
}
Expand All @@ -35,8 +47,8 @@ public function findCandidates(Filename $composerFilename): array {

private function getRequires(Filename $composerFilename): array {
if (!$composerFilename->exists()) {
throw new \InvalidArgumentException(
\sprintf('Specified file %s does not exist', $composerFilename->asString())
throw new InvalidArgumentException(
sprintf('Specified file %s does not exist', $composerFilename->asString())
);
}

Expand Down
9 changes: 9 additions & 0 deletions src/commands/default/DefaultCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?php declare(strict_types = 1);
/*
* This file is part of Phive.
*
* Copyright (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Phive;

class DefaultCommand implements Cli\Command {
Expand Down
9 changes: 9 additions & 0 deletions src/commands/default/DefaultCommandConfig.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?php declare(strict_types = 1);
/*
* This file is part of Phive.
*
* Copyright (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Phive;

class DefaultCommandConfig {
Expand Down
Loading

0 comments on commit 55d3140

Please sign in to comment.