Skip to content

Commit

Permalink
csfixed
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Apr 27, 2017
1 parent a96ef4b commit 257eb43
Show file tree
Hide file tree
Showing 40 changed files with 322 additions and 194 deletions.
75 changes: 36 additions & 39 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,47 @@ Asset Packagist
@link https://github.com/hiqdev/asset-packagist
@package asset-packagist
@license BSD-3-Clause
@copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
@copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
EOF;

Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);

return Symfony\CS\Config\Config::create()
return PhpCsFixer\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
'-align_double_arrow', /// Align double arrow symbols in consecutive lines
'-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
'-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"
'-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
'-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
'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_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', /// 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()
->setRiskyAllowed(true)
->setRules(array(
'@Symfony' => true,
'header_comment' => [
'header' => $header,
'separate' => 'bottom',
'location' => 'after_declare_strict',
'commentType' => 'PHPDoc',
],
'binary_operator_spaces' => [
'align_double_arrow' => null,
'align_equals' => null,
],
'concat_space' => ['spacing' => 'one'],
'array_syntax' => ['syntax' => 'short'],
'blank_line_before_return' => false,
'phpdoc_align' => false,
'phpdoc_scalar' => false,
'phpdoc_separation' => false,
'phpdoc_to_comment' => false,
'method_argument_space' => false,
'ereg_to_preg' => true,
'blank_line_after_opening_tag' => true,
'single_blank_line_before_namespace' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
'pre_increment' => true,
'strict_comparison' => true,
'strict_param' => true,
'no_multiline_whitespace_before_semicolons' => true,
))
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
->notPath('vendor')
->notPath('runtime')
->notPath('web/assets')
)
)
;
9 changes: 4 additions & 5 deletions src/assets/AppAsset.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php

/*
* Asset Packagist
/**
* Asset Packagist.
*
* @link https://github.com/hiqdev/asset-packagist
* @see https://github.com/hiqdev/asset-packagist
* @package asset-packagist
* @license BSD-3-Clause
* @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
* @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
*/

namespace hiqdev\assetpackagist\assets;
Expand Down
14 changes: 11 additions & 3 deletions src/commands/AbstractPackageCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* Asset Packagist.
*
* @see https://github.com/hiqdev/asset-packagist
* @package asset-packagist
* @license BSD-3-Clause
* @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
*/

namespace hiqdev\assetpackagist\commands;

Expand All @@ -24,15 +32,15 @@ abstract class AbstractPackageCommand extends Component implements Job
protected $packageRepository;

/**
* Triggers event before run
* Triggers event before run.
*/
public function beforeRun()
{
$this->trigger(self::EVENT_BEFORE_RUN);
}

/**
* Triggers event after run
* Triggers event after run.
*/
public function afterRun()
{
Expand All @@ -54,7 +62,7 @@ public function __construct(AssetPackage $package, PackageRepository $packageRep
}

/**
* Reloads package on wake up to ensure it is up to date
* Reloads package on wake up to ensure it is up to date.
*
* @void
*/
Expand Down
10 changes: 8 additions & 2 deletions src/commands/CollectDependenciesCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* Asset Packagist.
*
* @see https://github.com/hiqdev/asset-packagist
* @package asset-packagist
* @license BSD-3-Clause
* @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
*/

namespace hiqdev\assetpackagist\commands;

Expand All @@ -9,8 +17,6 @@
/**
* Class CollectDependenciesCommand collects dependencies for a certain package
* and publishes tasks to update them.
*
* @package hiqdev\assetpackagist\commands
*/
class CollectDependenciesCommand extends AbstractPackageCommand
{
Expand Down
13 changes: 8 additions & 5 deletions src/commands/PackageUpdateCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* Asset Packagist.
*
* @see https://github.com/hiqdev/asset-packagist
* @package asset-packagist
* @license BSD-3-Clause
* @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
*/

namespace hiqdev\assetpackagist\commands;

Expand All @@ -10,8 +18,6 @@
/**
* Class PackageUpdateCommand runs package update command and creates tasks to
* fetch its dependencies.
*
* @package hiqdev\assetpackagist\commands
*/
class PackageUpdateCommand extends AbstractPackageCommand
{
Expand All @@ -37,7 +43,6 @@ public function run()
Yii::$app->queue->push(Yii::createObject(CollectDependenciesCommand::class, [$this->package]));
}


$this->afterRun();
}

Expand Down Expand Up @@ -69,6 +74,4 @@ private function transformException(\Exception $e)

return false;
}


}
21 changes: 10 additions & 11 deletions src/components/Storage.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php

/*
* Asset Packagist
/**
* Asset Packagist.
*
* @link https://github.com/hiqdev/asset-packagist
* @see https://github.com/hiqdev/asset-packagist
* @package asset-packagist
* @license BSD-3-Clause
* @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
* @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
*/

namespace hiqdev\assetpackagist\components;
Expand All @@ -24,7 +23,7 @@ class Storage extends Component implements StorageInterface
protected $_locker;

/**
* @inheritdoc
* {@inheritdoc}
*/
public function init()
{
Expand All @@ -41,7 +40,7 @@ protected function getLocker()
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function getNextId()
{
Expand Down Expand Up @@ -75,7 +74,7 @@ protected function getLastIdPath()
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function writePackage(AssetPackage $package)
{
Expand Down Expand Up @@ -113,7 +112,7 @@ public function writePackage(AssetPackage $package)
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function readPackage(AssetPackage $package)
{
Expand Down Expand Up @@ -209,7 +208,7 @@ protected function writePackagesJson($hash)
}

/**
* Creates directory $dir and sets chmod 777
* Creates directory $dir and sets chmod 777.
* @param string $dir
* @return bool whether the directory was created successfully
*/
Expand Down Expand Up @@ -242,7 +241,7 @@ protected function readProvider($path)
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function listPackages()
{
Expand Down
24 changes: 17 additions & 7 deletions src/components/StorageInterface.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<?php
/**
* Asset Packagist.
*
* @see https://github.com/hiqdev/asset-packagist
* @package asset-packagist
* @license BSD-3-Clause
* @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
*/

namespace hiqdev\assetpackagist\components;

use hiqdev\assetpackagist\models\AssetPackage;

/**
* Interface StorageInterface
*
* @package hiqdev\assetpackagist\components
* Interface StorageInterface.
*/
interface StorageInterface
{
Expand All @@ -19,17 +25,21 @@ interface StorageInterface
* 0 - string sha256 hash of the package
* 1 - array[] releases
*
* Returns null, when package does not exist.
* Returns null, when package does not exist
*/
public function readPackage(AssetPackage $package); // TODO: use interface instead
public function readPackage(AssetPackage $package);

// TODO: use interface instead

/**
* Writes the $package to the storage
* Writes the $package to the storage.
*
* @param AssetPackage $package
* @return string hash or the package on success
*/
public function writePackage(AssetPackage $package); // TODO: use interface instead
public function writePackage(AssetPackage $package);

// TODO: use interface instead

// TODO: PHPDoc
public function getNextId();
Expand Down
10 changes: 9 additions & 1 deletion src/config/common.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* Asset Packagist.
*
* @see https://github.com/hiqdev/asset-packagist
* @package asset-packagist
* @license BSD-3-Clause
* @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
*/

return [
'id' => 'asset-packagist',
Expand All @@ -14,7 +22,7 @@
'dsn' => 'mysql:host=localhost;dbname=' . $params['db.name'],
'username' => $params['db.username'],
'password' => $params['db.password'],
'charset' => 'utf8'
'charset' => 'utf8',
],
'queue' => [
'class' => \zhuravljov\yii\queue\db\Queue::class,
Expand Down
11 changes: 5 additions & 6 deletions src/config/hidev.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php

/*
* Asset Packagist
/**
* Asset Packagist.
*
* @link https://github.com/hiqdev/asset-packagist
* @see https://github.com/hiqdev/asset-packagist
* @package asset-packagist
* @license BSD-3-Clause
* @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
* @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
*/

return [
Expand All @@ -31,7 +30,7 @@
'class' => \hiqdev\assetpackagist\log\StdoutTarget::class,
'categories' => ['hiqdev\assetpackagist\commands\*'],
'exportInterval' => 1,
'logVars' => []
'logVars' => [],
],
],
],
Expand Down
9 changes: 4 additions & 5 deletions src/config/hisite.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php

/*
* Asset Packagist
/**
* Asset Packagist.
*
* @link https://github.com/hiqdev/asset-packagist
* @see https://github.com/hiqdev/asset-packagist
* @package asset-packagist
* @license BSD-3-Clause
* @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
* @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
*/

return [
Expand Down

0 comments on commit 257eb43

Please sign in to comment.