Skip to content

Commit bb37dc4

Browse files
committed
Remove unused discovery, add CS fixing
1 parent 337f04d commit bb37dc4

10 files changed

+72
-45
lines changed

.php_cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
/*
4+
* In order to make it work, fabpot/php-cs-fixer and sllh/php-cs-fixer-styleci-bridge must be installed globally
5+
* with composer.
6+
*
7+
* @link https://github.com/Soullivaneuh/php-cs-fixer-styleci-bridge
8+
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer
9+
*/
10+
11+
use SLLH\StyleCIBridge\ConfigBridge;
12+
13+
return ConfigBridge::create();

.styleci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
preset: symfony
2+
3+
finder:
4+
exclude:
5+
- "spec"
6+
path:
7+
- "src"
8+
9+
enabled:
10+
- short_array_syntax

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log
22

33

4+
## 0.4.0 - 2016-03-02
5+
6+
### Removed
7+
8+
- Discovery dependency
9+
10+
411
## 0.3.1 - 2016-02-11
512

613
### Changed

composer.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"php": ">=5.4",
1919
"phpunit/phpunit": "^4.5",
2020
"php-http/httplug": "^1.0",
21-
"php-http/discovery": "~0.7",
2221
"php-http/message": "^1.0",
2322
"guzzlehttp/psr7": "^1.0",
2423
"th3n3rd/cartesian-product": "^0.3"
@@ -33,9 +32,7 @@
3332
],
3433
"extra": {
3534
"branch-alias": {
36-
"dev-master": "0.4-dev"
35+
"dev-master": "0.5-dev"
3736
}
38-
},
39-
"prefer-stable": true,
40-
"minimum-stability": "beta"
37+
}
4138
}

src/FeatureTestListener.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@ public function startTest(\PHPUnit_Framework_Test $test)
1818
$feature = $feature[0];
1919
}
2020

21-
echo sprintf("%-40.s : ", $feature);
21+
echo sprintf('%-40.s : ', $feature);
2222
}
2323

2424
public function endTest(\PHPUnit_Framework_Test $test, $time)
2525
{
2626
if (!$this->lastTestFailed) {
27-
echo $this->formatWithColor('fg-green', "Supported"). "\n";
27+
echo $this->formatWithColor('fg-green', 'Supported')."\n";
2828
} else {
29-
echo $this->formatWithColor('fg-red', "Not supported"). "\n";
29+
echo $this->formatWithColor('fg-red', 'Not supported')."\n";
3030
}
3131

3232
$this->lastTestFailed = false;
3333
}
3434

3535
private function extractFeature(\PHPUnit_Framework_Test $test)
3636
{
37-
$class = get_class($test);
38-
$method = $test->getName();
37+
$class = get_class($test);
38+
$method = $test->getName();
3939
$reflection = new \ReflectionMethod($class, $method);
4040

4141
return $this->parseDocBlock($reflection->getDocComment(), '@feature');
@@ -50,7 +50,7 @@ private function parseDocBlock($doc_block, $tag)
5050
}
5151

5252
$regex = "/{$tag} (.*)(\\r\\n|\\r|\\n)/U";
53-
preg_match_all( $regex, $doc_block, $matches );
53+
preg_match_all($regex, $doc_block, $matches);
5454

5555
if (empty($matches[1])) {
5656
return [];
@@ -59,7 +59,7 @@ private function parseDocBlock($doc_block, $tag)
5959
$matches = $matches[1];
6060

6161
foreach ($matches as $ix => $match) {
62-
$matches[ $ix ] = trim( $match );
62+
$matches[ $ix ] = trim($match);
6363
}
6464

6565
return $matches;

src/HttpAsyncClientTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testSuccessiveCallMustUseResponseInterface()
4444
$this->assertInstanceOf('Http\Promise\Promise', $promise);
4545

4646
$response = null;
47-
$promise->then()->then()->then(function ($r) use(&$response) {
47+
$promise->then()->then()->then(function ($r) use (&$response) {
4848
$response = $r;
4949

5050
return $response;
@@ -71,8 +71,8 @@ public function testSuccessiveInvalidCallMustUseException()
7171
$this->assertInstanceOf('Http\Promise\Promise', $promise);
7272

7373
$exception = null;
74-
$response = null;
75-
$promise->then()->then()->then(function ($r) use(&$response) {
74+
$response = null;
75+
$promise->then()->then()->then(function ($r) use (&$response) {
7676
$response = $r;
7777

7878
return $response;
@@ -96,7 +96,7 @@ public function testSuccessiveInvalidCallMustUseException()
9696
public function testAsyncSendRequest($method, $uri, array $headers, $body)
9797
{
9898
if ($body != null) {
99-
$headers['Content-Length'] = (string)strlen($body);
99+
$headers['Content-Length'] = (string) strlen($body);
100100
}
101101

102102
$request = self::$messageFactory->createRequest(
@@ -110,7 +110,7 @@ public function testAsyncSendRequest($method, $uri, array $headers, $body)
110110
$this->assertInstanceOf('Http\Promise\Promise', $promise);
111111

112112
$response = null;
113-
$promise->then(function ($r) use(&$response) {
113+
$promise->then(function ($r) use (&$response) {
114114
$response = $r;
115115

116116
return $response;
@@ -138,11 +138,11 @@ public function testSendAsyncWithInvalidUri()
138138
);
139139

140140
$exception = null;
141-
$response = null;
142-
$promise = $this->httpAsyncClient->sendAsyncRequest($request);
141+
$response = null;
142+
$promise = $this->httpAsyncClient->sendAsyncRequest($request);
143143
$this->assertInstanceOf('Http\Promise\Promise', $promise);
144144

145-
$promise->then(function ($r) use(&$response) {
145+
$promise->then(function ($r) use (&$response) {
146146
$response = $r;
147147

148148
return $response;
@@ -169,7 +169,7 @@ public function testSendAsyncRequestWithOutcome($uriAndOutcome, $protocolVersion
169169
}
170170

171171
if ($body != null) {
172-
$headers['Content-Length'] = (string)strlen($body);
172+
$headers['Content-Length'] = (string) strlen($body);
173173
}
174174

175175
$request = self::$messageFactory->createRequest(
@@ -184,8 +184,8 @@ public function testSendAsyncRequestWithOutcome($uriAndOutcome, $protocolVersion
184184
$outcome['protocolVersion'] = $protocolVersion;
185185

186186
$response = null;
187-
$promise = $this->httpAsyncClient->sendAsyncRequest($request);
188-
$promise->then(function ($r) use(&$response) {
187+
$promise = $this->httpAsyncClient->sendAsyncRequest($request);
188+
$promise->then(function ($r) use (&$response) {
189189
$response = $r;
190190

191191
return $response;

src/HttpBaseTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Http\Client\Tests;
44

5-
use Http\Discovery\MessageFactoryDiscovery;
65
use Http\Message\MessageFactory;
6+
use Http\Message\MessageFactory\GuzzleMessageFactory;
77
use Nerd\CartesianProduct\CartesianProduct;
88
use Psr\Http\Message\ResponseInterface;
99

@@ -24,10 +24,10 @@ abstract class HttpBaseTest extends \PHPUnit_Framework_TestCase
2424
*/
2525
protected $defaultOptions = [
2626
'protocolVersion' => '1.1',
27-
'statusCode' => 200,
28-
'reasonPhrase' => 'OK',
29-
'headers' => ['Content-Type' => 'text/html'],
30-
'body' => 'Ok',
27+
'statusCode' => 200,
28+
'reasonPhrase' => 'OK',
29+
'headers' => ['Content-Type' => 'text/html'],
30+
'body' => 'Ok',
3131
];
3232

3333
/**
@@ -36,7 +36,7 @@ abstract class HttpBaseTest extends \PHPUnit_Framework_TestCase
3636
protected $defaultHeaders = [
3737
'Connection' => 'close',
3838
'User-Agent' => 'PHP HTTP Adapter',
39-
'Content-Length' => '0'
39+
'Content-Length' => '0',
4040
];
4141

4242
/**
@@ -45,7 +45,7 @@ abstract class HttpBaseTest extends \PHPUnit_Framework_TestCase
4545
public static function setUpBeforeClass()
4646
{
4747
self::$logPath = PHPUnitUtility::getFile(true, 'php-http-adapter.log');
48-
self::$messageFactory = MessageFactoryDiscovery::find();
48+
self::$messageFactory = new GuzzleMessageFactory();
4949
}
5050

5151
/**
@@ -65,9 +65,9 @@ public function requestProvider()
6565
{
6666
$sets = [
6767
'methods' => $this->getMethods(),
68-
'uris' => [$this->getUri()],
68+
'uris' => [$this->getUri()],
6969
'headers' => $this->getHeaders(),
70-
'body' => $this->getBodies(),
70+
'body' => $this->getBodies(),
7171
];
7272

7373
$cartesianProduct = new CartesianProduct($sets);
@@ -81,10 +81,10 @@ public function requestProvider()
8181
public function requestWithOutcomeProvider()
8282
{
8383
$sets = [
84-
'urisAndOutcomes' => $this->getUrisAndOutcomes(),
84+
'urisAndOutcomes' => $this->getUrisAndOutcomes(),
8585
'protocolVersions' => $this->getProtocolVersions(),
86-
'headers' => $this->getHeaders(),
87-
'body' => $this->getBodies(),
86+
'headers' => $this->getHeaders(),
87+
'body' => $this->getBodies(),
8888
];
8989

9090
$cartesianProduct = new CartesianProduct($sets);
@@ -137,23 +137,23 @@ private function getUrisAndOutcomes()
137137
[
138138
$this->getUri(['client_error' => true]),
139139
[
140-
'statusCode' => 400,
140+
'statusCode' => 400,
141141
'reasonPhrase' => 'Bad Request',
142142
],
143143
],
144144
[
145145
$this->getUri(['server_error' => true]),
146146
[
147-
'statusCode' => 500,
147+
'statusCode' => 500,
148148
'reasonPhrase' => 'Internal Server Error',
149149
],
150150
],
151151
[
152152
$this->getUri(['redirect' => true]),
153153
[
154-
'statusCode' => 302,
154+
'statusCode' => 302,
155155
'reasonPhrase' => 'Found',
156-
'body' => 'Redirect',
156+
'body' => 'Redirect',
157157
],
158158
],
159159
];

src/HttpClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ abstract protected function createHttpAdapter();
4242
public function testSendRequest($method, $uri, array $headers, $body)
4343
{
4444
if ($body != null) {
45-
$headers['Content-Length'] = (string)strlen($body);
45+
$headers['Content-Length'] = (string) strlen($body);
4646
}
4747

4848
$request = self::$messageFactory->createRequest(
@@ -74,7 +74,7 @@ public function testSendRequestWithOutcome($uriAndOutcome, $protocolVersion, arr
7474
}
7575

7676
if ($body != null) {
77-
$headers['Content-Length'] = (string)strlen($body);
77+
$headers['Content-Length'] = (string) strlen($body);
7878
}
7979

8080
$request = self::$messageFactory->createRequest(

src/HttpFeatureTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Http\Client\Tests;
44

55
use Http\Client\HttpClient;
6-
use Http\Discovery\MessageFactoryDiscovery;
76
use Http\Message\MessageFactory;
7+
use Http\Message\MessageFactory\GuzzleMessageFactory;
88

99
abstract class HttpFeatureTest extends \PHPUnit_Framework_TestCase
1010
{
@@ -18,7 +18,7 @@ abstract class HttpFeatureTest extends \PHPUnit_Framework_TestCase
1818
*/
1919
public static function setUpBeforeClass()
2020
{
21-
self::$messageFactory = MessageFactoryDiscovery::find();
21+
self::$messageFactory = new GuzzleMessageFactory();
2222
}
2323

2424
/**

src/PHPUnitUtility.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class PHPUnitUtility
1212
/**
1313
* Gets the uri.
1414
*
15-
* @return string|boolean The uri or FALSE if there is none.
15+
* @return string|bool The uri or FALSE if there is none.
1616
*/
1717
public static function getUri()
1818
{
@@ -22,7 +22,7 @@ public static function getUri()
2222
/**
2323
* Gets the file.
2424
*
25-
* @param boolean $tmp TRUE if the file should be in the "/tmp" directory else FALSE.
25+
* @param bool $tmp TRUE if the file should be in the "/tmp" directory else FALSE.
2626
* @param string|null $name The name.
2727
*
2828
* @return string The file.

0 commit comments

Comments
 (0)