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

[cs] Place CS rules in config file #38

Merged
merged 3 commits into from
Jun 4, 2015
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ install:
script:
- if [[ $EXECUTE_COVERAGE == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi
- if [[ $EXECUTE_COVERAGE != 'true' ]]; then ./vendor/bin/phpunit ; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs --standard=PSR2 src test ; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs ; fi

after_script:
- if [[ $EXECUTE_COVERAGE == 'true' ]]; then composer require satooshi/php-coveralls:dev-master ; fi
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"require-dev": {
"phpunit/PHPUnit": "~4.6",
"squizlabs/php_codesniffer": "~2.0"
"squizlabs/php_codesniffer": "^2.3.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why this specific version and up? What changed specifically with 2.3.1 that is needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

long array rule not exists before 2.3.1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea they didn't follow semantic versioning about to raise feature number when new sniffs are added

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, cool; was just curious. :)

},
"provide": {
"psr/http-message-implementation": "~1.0.0"
Expand Down
21 changes: 21 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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>

<!-- Paths to check -->
<file>src</file>
<file>test</file>
</ruleset>
2 changes: 1 addition & 1 deletion src/HeaderSecurity.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static function assertValid($value)
throw new InvalidArgumentException('Invalid header value');
}
}

/**
* Assert whether or not a header name is valid.
*
Expand Down
2 changes: 1 addition & 1 deletion src/RequestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function withUri(UriInterface $uri, $preserveHost = false)
}

$new->headerNames['host'] = 'Host';
$new->headers['Host'] = array($host);
$new->headers['Host'] = [$host];

return $new;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Response implements ResponseInterface
*
* @var array
*/
private $phrases = array(
private $phrases = [
// INFORMATIONAL CODES
100 => 'Continue',
101 => 'Switching Protocols',
Expand Down Expand Up @@ -92,7 +92,7 @@ class Response implements ResponseInterface
507 => 'Insufficient Storage',
508 => 'Loop Detected',
511 => 'Network Authentication Required',
);
];

/**
* @var string
Expand Down
2 changes: 1 addition & 1 deletion src/ServerRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public static function normalizeFiles(array $files)
*/
public static function marshalHeaders(array $server)
{
$headers = array();
$headers = [];
foreach ($server as $key => $value) {
if (strpos($key, 'HTTP_COOKIE') === 0) {
// Cookies are handled using the $_COOKIE superglobal
Expand Down
2 changes: 1 addition & 1 deletion src/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function seek($offset, $whence = SEEK_SET)
if (! $this->resource) {
throw new RuntimeException('No resource available; cannot seek position');
}

if (! $this->isSeekable()) {
throw new RuntimeException('Stream is not seekable');
}
Expand Down
8 changes: 4 additions & 4 deletions src/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function moveTo($targetPath)

$this->moved = true;
}

/**
* {@inheritdoc}
*
Expand All @@ -168,7 +168,7 @@ public function getSize()
{
return $this->size;
}

/**
* {@inheritdoc}
*
Expand All @@ -179,7 +179,7 @@ public function getError()
{
return $this->error;
}

/**
* {@inheritdoc}
*
Expand All @@ -190,7 +190,7 @@ public function getClientFilename()
{
return $this->clientFilename;
}

/**
* {@inheritdoc}
*/
Expand Down
76 changes: 38 additions & 38 deletions test/HeaderSecurityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ class HeaderSecurityTest extends TestCase
*/
public function getFilterValues()
{
return array(
array("This is a\n test", "This is a test"),
array("This is a\r test", "This is a test"),
array("This is a\n\r test", "This is a test"),
array("This is a\r\n test", "This is a\r\n test"),
array("This is a \r\ntest", "This is a test"),
array("This is a \r\n\n test", "This is a test"),
array("This is a\n\n test", "This is a test"),
array("This is a\r\r test", "This is a test"),
array("This is a \r\r\n test", "This is a \r\n test"),
array("This is a \r\n\r\ntest", "This is a test"),
array("This is a \r\n\n\r\n test", "This is a \r\n test")
);
return [
["This is a\n test", "This is a test"],
["This is a\r test", "This is a test"],
["This is a\n\r test", "This is a test"],
["This is a\r\n test", "This is a\r\n test"],
["This is a \r\ntest", "This is a test"],
["This is a \r\n\n test", "This is a test"],
["This is a\n\n test", "This is a test"],
["This is a\r\r test", "This is a test"],
["This is a \r\r\n test", "This is a \r\n test"],
["This is a \r\n\r\ntest", "This is a test"],
["This is a \r\n\n\r\n test", "This is a \r\n test"]
];
}

/**
Expand All @@ -54,19 +54,19 @@ public function testFiltersValuesPerRfc7230($value, $expected)

public function validateValues()
{
return array(
array("This is a\n test", 'assertFalse'),
array("This is a\r test", 'assertFalse'),
array("This is a\n\r test", 'assertFalse'),
array("This is a\r\n test", 'assertTrue'),
array("This is a \r\ntest", 'assertFalse'),
array("This is a \r\n\n test", 'assertFalse'),
array("This is a\n\n test", 'assertFalse'),
array("This is a\r\r test", 'assertFalse'),
array("This is a \r\r\n test", 'assertFalse'),
array("This is a \r\n\r\ntest", 'assertFalse'),
array("This is a \r\n\n\r\n test", 'assertFalse')
);
return [
["This is a\n test", 'assertFalse'],
["This is a\r test", 'assertFalse'],
["This is a\n\r test", 'assertFalse'],
["This is a\r\n test", 'assertTrue'],
["This is a \r\ntest", 'assertFalse'],
["This is a \r\n\n test", 'assertFalse'],
["This is a\n\n test", 'assertFalse'],
["This is a\r\r test", 'assertFalse'],
["This is a \r\r\n test", 'assertFalse'],
["This is a \r\n\r\ntest", 'assertFalse'],
["This is a \r\n\n\r\n test", 'assertFalse']
];
}

/**
Expand All @@ -80,18 +80,18 @@ public function testValidatesValuesPerRfc7230($value, $assertion)

public function assertValues()
{
return array(
array("This is a\n test"),
array("This is a\r test"),
array("This is a\n\r test"),
array("This is a \r\ntest"),
array("This is a \r\n\n test"),
array("This is a\n\n test"),
array("This is a\r\r test"),
array("This is a \r\r\n test"),
array("This is a \r\n\r\ntest"),
array("This is a \r\n\n\r\n test")
);
return [
["This is a\n test"],
["This is a\r test"],
["This is a\n\r test"],
["This is a \r\ntest"],
["This is a \r\n\n test"],
["This is a\n\n test"],
["This is a\r\r test"],
["This is a \r\r\n test"],
["This is a \r\n\r\ntest"],
["This is a \r\n\n\r\n test"]
];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public function testGetHostHeaderReturnsUriHostWhenPresent()
{
$request = new Request('http://example.com');
$header = $request->getHeader('host');
$this->assertEquals(array('example.com'), $header);
$this->assertEquals(['example.com'], $header);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/TestAsset/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class HeaderStack
/**
* @var array
*/
private static $data = array();
private static $data = [];

/**
* Reset state
*/
public static function reset()
{
self::$data = array();
self::$data = [];
}

/**
Expand Down