From 94284dfc58950bc8220129309bbb0731750a06fb Mon Sep 17 00:00:00 2001 From: Andrii Vasyliev Date: Tue, 23 Aug 2016 13:12:17 +0000 Subject: [PATCH] csfixed --- .php_cs | 17 +++++++++-------- src/Plugin.php | 31 ++++++++++++++++--------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/.php_cs b/.php_cs index 6b38401..3ee00a2 100644 --- a/.php_cs +++ b/.php_cs @@ -15,6 +15,7 @@ return Symfony\CS\Config\Config::create() ->setUsingCache(true) ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) ->fixers([ + 'header_comment', /// Add, replace or remove header comment '-long_array_syntax', /// Arrays should use the long syntax '-php4_constructor', /// Convert PHP4-style constructors to __construct. Warning! This could change code behavior '-phpdoc_var_to_type', /// @var should always be written as @type @@ -22,26 +23,27 @@ return Symfony\CS\Config\Config::create() '-unalign_double_arrow', /// Unalign double arrow symbols in consecutive lines '-align_equals', /// Align equals symbols in consecutive lines '-unalign_equals', /// Unalign equals symbols in consecutive lines - '-blankline_after_open_tag', /// Ensure there is no code on the same line as the PHP open tag and it is followed by a blankline '-phpdoc_no_empty_return', /// @return void and @return null annotations should be omitted from phpdocs '-empty_return', /// A return statement wishing to return nothing should be simply "return" - '-return', /// An empty line feed should precede a return statement + '-blank_line_before_return', /// n empty line feed should precede a return statement + '-phpdoc_align', /// All items of the @param, @throws, @return, @var, and @type phpdoc tags must be aligned vertically '-phpdoc_params', /// All items of the @param, @throws, @return, @var, and @type phpdoc tags must be aligned vertically '-phpdoc_scalar', /// Scalar types should always be written in the same form. "int", not "integer"; "bool", not "boolean" '-phpdoc_separation', /// Annotations of a different type are separated by a single blank line '-phpdoc_to_comment', /// Docblocks should only be used on structural elements - 'header_comment', /// Add, replace or remove header comment + '-method_argument_space', /// In method arguments and method call, there MUST NOT be a space before each comma and there MUST be one space after each comma + '-concat_without_spaces', /// Concatenation should be used without spaces 'concat_with_spaces', /// Concatenation should be used with at least one whitespace around 'ereg_to_preg', /// Replace deprecated ereg regular expression functions with preg. Warning! This could change code behavior - 'multiline_spaces_before_semicolon', /// Multi-line whitespace before closing semicolon are prohibited - 'newline_after_open_tag', /// Ensure there is no code on the same line as the PHP open tag + 'blank_line_after_opening_tag', /// Ensure there is no code on the same line as the PHP open tag and it is followed by a blankline 'single_blank_line_before_namespace', /// There should be no blank lines before a namespace declaration - 'ordered_use', /// Ordering use statements + 'ordered_imports', /// Ordering use statements 'phpdoc_order', /// Annotations in phpdocs should be ordered so that @param come first, then @throws, then @return 'pre_increment', /// Pre incrementation/decrementation should be used if possible 'short_array_syntax', /// PHP arrays should use the PHP 5.4 short-syntax - 'strict', /// Comparison should be strict. Warning! This could change code behavior + 'strict_comparison', /// Comparison should be strict. (Risky fixer!) 'strict_param', /// Functions should be used with $strict param. Warning! This could change code behavior + 'no_multiline_whitespace_before_semicolons', /// Multi-line whitespace before closing semicolon are prohibited ]) ->finder( Symfony\CS\Finder\DefaultFinder::create() @@ -49,6 +51,5 @@ return Symfony\CS\Config\Config::create() ->notPath('vendor') ->notPath('runtime') ->notPath('web/assets') - ->notPath('tests/unit/UnitTester.php') ) ; diff --git a/src/Plugin.php b/src/Plugin.php index 4dfc3b7..63f78e0 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -28,11 +28,11 @@ */ class Plugin implements PluginInterface, EventSubscriberInterface { - const PACKAGE_TYPE = 'yii2-extension'; - const EXTRA_OPTION_NAME = 'config-plugin'; - const OUTPUT_PATH = 'hiqdev/config'; - const BASE_DIR_SAMPLE = ''; - const VENDOR_DIR_SAMPLE = '/vendor'; + const PACKAGE_TYPE = 'yii2-extension'; + const EXTRA_OPTION_NAME = 'config-plugin'; + const OUTPUT_PATH = 'hiqdev/config'; + const BASE_DIR_SAMPLE = ''; + const VENDOR_DIR_SAMPLE = '/vendor'; /** * @var PackageInterface[] the array of active composer packages @@ -40,12 +40,12 @@ class Plugin implements PluginInterface, EventSubscriberInterface protected $packages; /** - * @var string absolute path to the package base directory. + * @var string absolute path to the package base directory */ protected $baseDir; /** - * @var string absolute path to vendor directory. + * @var string absolute path to vendor directory */ protected $vendorDir; @@ -58,7 +58,7 @@ class Plugin implements PluginInterface, EventSubscriberInterface * @var array assembled config data */ protected $data = [ - 'aliases' => [], + 'aliases' => [], 'extensions' => [], ]; @@ -140,7 +140,7 @@ public function processPackage(PackageInterface $package) } $extension = [ - 'name' => $package->getName(), + 'name' => $package->getName(), 'version' => $package->getVersion(), ]; if ($package->getVersion() === '9999999-dev') { @@ -170,10 +170,10 @@ public function processPackage(PackageInterface $package) } $this->raw[$package->getName()] = [ - 'package' => $package, + 'package' => $package, 'extension' => $extension, - 'aliases' => $aliases, - 'files' => (array) $files, + 'aliases' => $aliases, + 'files' => (array) $files, ]; } @@ -187,7 +187,7 @@ public function assembleConfigs() $allAliases = []; $extensions = []; $rawConfigs = [ - 'aliases' => [], + 'aliases' => [], 'extensions' => [], ]; @@ -209,7 +209,7 @@ public function assembleConfigs() foreach ($rawConfigs as $name => $configs) { if (!in_array($name, ['params', 'aliases', 'extensions'], true)) { $configs[] = [ - 'params' => $this->data['params'], + 'params' => $this->data['params'], 'aliases' => $this->data['aliases'], ]; } @@ -245,6 +245,7 @@ protected function readConfigFile(PackageInterface $package, $file) } } extract($this->data); + return (array) require $__path; } @@ -365,7 +366,7 @@ public function getPackages() /** * Returns ordered list of packages: * - listed earlier in the composer.json will get earlier in the list - * - childs before parents + * - childs before parents. * @return \Composer\Package\PackageInterface[] */ public function findPackages()