Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

New coding standard #17

Merged
merged 5 commits into from
Apr 30, 2018
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
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,24 @@ To do so:

## Running Coding Standards Checks

This component uses [php-cs-fixer](http://cs.sensiolabs.org/) for coding
This component uses [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) for coding
standards checks, and provides configuration for our selected checks.
`php-cs-fixer` is installed by default via Composer.
`phpcs` is installed by default via Composer.

To run checks only:

```console
$ ./vendor/bin/php-cs-fixer fix . -v --diff --dry-run --config-file=.php_cs
$ composer cs-check
```

To have `php-cs-fixer` attempt to fix problems for you, omit the `--dry-run`
flag:
`phpcs` also includes a tool for fixing most CS violations, `phpcbf`:


```console
$ ./vendor/bin/php-cs-fixer fix . -v --diff --config-file=.php_cs
$ composer cs-fix
```

If you allow php-cs-fixer to fix CS issues, please re-run the tests to ensure
If you allow `phpcbf` to fix CS issues, please re-run the tests to ensure
they pass, and make sure you add and commit the changes after verification.

## Recommended Workflow for Contributions
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"zendframework/zend-view": "^2.6.3"
},
"require-dev": {
"squizlabs/php_codesniffer": "^2.3.1",
"phpunit/PHPUnit": "^4.5",
"zendframework/zend-filter": "^2.6.1",
"zendframework/zend-form": "^2.7"
"zendframework/zend-form": "^2.7",
"zendframework/zend-coding-standard": "~1.0.0"
},
"suggest": {
"zendframework/zend-filter": "^2.6.1, to filter rendered results"
Expand Down
43 changes: 36 additions & 7 deletions composer.lock

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

15 changes: 1 addition & 14 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
<?xml version="1.0"?>
<ruleset name="Zend Framework coding standard">
<description>Zend Framework coding standard</description>

<!-- display progress -->
<arg value="p"/>
<arg name="colors"/>

<!-- inherit rules from: -->
<rule ref="PSR2"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="./vendor/zendframework/zend-coding-standard/ruleset.xml"/>

<!-- Paths to check -->
<file>src</file>
Expand Down
2 changes: 1 addition & 1 deletion src/ResponseSender/ConsoleResponseSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function sendContent(SendResponseEvent $event)
public function __invoke(SendResponseEvent $event)
{
$response = $event->getResponse();
if (!$response instanceof Response) {
if (! $response instanceof Response) {
return;
}

Expand Down
8 changes: 4 additions & 4 deletions src/View/RouteNotFoundStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ public function handleRouteNotFoundError(MvcEvent $e)
$usage = $this->getConsoleUsage($console, $scriptName, $mm);

// Inject the text into view
$result = $banner ? rtrim($banner, "\r\n") : '';
$result .= $usage ? "\n\n" . trim($usage, "\r\n") : '';
$result = $banner ? rtrim($banner, "\r\n") : '';
$result .= $usage ? "\n\n" . trim($usage, "\r\n") : '';
$result .= "\n"; // to ensure we output a final newline
$result .= $this->reportNotFoundReason($e);
$model->setResult($result);
Expand Down Expand Up @@ -392,7 +392,7 @@ protected function renderTable($data, $cols, $consoleWidth)
for ($x = 1; $x <= $cols; $x += 1) {
$maxW[$x] = 0;
foreach ($data as $row) {
$maxW[$x] = max($maxW[$x], $strWrapper->strlen($row[$x-1]) + $padding * 2);
$maxW[$x] = max($maxW[$x], $strWrapper->strlen($row[$x - 1]) + $padding * 2);
}
}

Expand All @@ -419,7 +419,7 @@ protected function renderTable($data, $cols, $consoleWidth)
* (minus 1 character to prevent double wrapping at the edge of the
* screen).
*/
$maxW[$cols] = $consoleWidth - $width -1;
$maxW[$cols] = $consoleWidth - $width - 1;
$table = new Table\Table();
$table->setColumnWidths($maxW);
$table->setDecorator(new Table\Decorator\Blank());
Expand Down
6 changes: 3 additions & 3 deletions test/Router/SimpleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,12 @@ public static function routeProvider()
'mandatory-literal-namedAlternative-match-1' => [
'foo ( bar | baz ):altGroup',
['foo','bar'],
['foo' => null, 'altGroup'=>'bar', 'bar' => true, 'baz' => false]
['foo' => null, 'altGroup' => 'bar', 'bar' => true, 'baz' => false]
],
'mandatory-literal-namedAlternative-match-2' => [
'foo ( bar | baz ):altGroup9',
['foo','baz'],
['foo' => null, 'altGroup9'=>'baz', 'bar' => false, 'baz' => true]
['foo' => null, 'altGroup9' => 'baz', 'bar' => false, 'baz' => true]
],
'mandatory-literal-namedAlternative-mismatch' => [
'foo ( bar | baz ):altGroup9',
Expand Down Expand Up @@ -410,7 +410,7 @@ public static function routeProvider()
'optional-literal-namedAlternative-mismatch' => [
'foo [ bar | baz ]:altGroup9',
['foo'],
['foo' => null, 'altGroup9'=> null, 'bar' => false, 'baz' => false]
['foo' => null, 'altGroup9' => null, 'bar' => false, 'baz' => false]
],

// -- value params
Expand Down
4 changes: 2 additions & 2 deletions test/View/ExceptionStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function testPrepareExceptionViewModelErrorsThatMustGetSameResult()
$this->strategy->attach($events);

$exception = new \Exception('some exception');
$event = new MvcEvent(MvcEvent::EVENT_DISPATCH_ERROR, null, ['exception'=>$exception]);
$event = new MvcEvent(MvcEvent::EVENT_DISPATCH_ERROR, null, ['exception' => $exception]);
$event->setResult('something');
$event->setError($error);
$event->setParams(['exception' => $exception]);
Expand Down Expand Up @@ -235,7 +235,7 @@ public function testPrepareExceptionRendersPreviousMessages()
$i++;
} while ($i < count($messages));

$event = new MvcEvent(MvcEvent::EVENT_DISPATCH_ERROR, null, ['exception'=>$exception]);
$event = new MvcEvent(MvcEvent::EVENT_DISPATCH_ERROR, null, ['exception' => $exception]);
$event->setError('user-defined-error');

$events->triggerEvent($event); //$this->strategy->prepareExceptionViewModel($event);
Expand Down
1 change: 0 additions & 1 deletion test/View/TestAsset/ConsoleModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ public function getConsoleBanner()

public function getConsoleUsage()
{

}
}