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

Commit

Permalink
Merge b761e59 into 86d5a28
Browse files Browse the repository at this point in the history
  • Loading branch information
Maks3w committed May 31, 2015
2 parents 86d5a28 + b761e59 commit 0b29a65
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 47 deletions.
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"
},
"provide": {
"psr/http-message-implementation": "~1.0.0"
Expand Down
17 changes: 17 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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"/>


<!-- Paths to check -->
<file>src</file>
<file>test</file>
</ruleset>
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
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

0 comments on commit 0b29a65

Please sign in to comment.