8000 feature #62 bump to PHP 7.1 (nicolas-grekas) · symfony/symfony@aebc14b · GitHub
[go: up one dir, main page]

Skip to content

Commit aebc14b

Browse files
feature #62 bump to PHP 7.1 (nicolas-grekas)
This PR was merged into the 1.2-dev branch. Discussion ---------- bump to PHP 7.1 Let's make maintaining this package easier. Commits ------- 8e10923 bump to PHP 7.1
2 parents 5e5e0c3 + 8e10923 commit aebc14b

14 files changed

+125
-126
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor/
22
composer.lock
33
phpunit.xml
4+
.php_cs.cache

.php_cs.dist

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
return PhpCsFixer\Config::create()
4+
->setRules([
5+
'@Symfony' => true,
6+
'@Symfony:risky' => true,
7+
'@PHPUnit48Migration:risky' => true,
8+
'php_unit_no_expectation_annotation' => false, // part of `PHPUnitXYMigration:risky` ruleset, to be enabled when PHPUnit 4.x support will be dropped, as we don't want to rewrite exceptions handling twice
9+
'array_syntax' => ['syntax' => 'short'],
10+
'fopen_flags' => false,
11+
'ordered_imports' => true,
12+
'protected_to_private' => false,
13+
// Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading
14+
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
15+
// Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading
16+
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
17+
])
18+
->setRiskyAllowed(true)
19+
->setFinder(
20+
PhpCsFixer\Finder::create()
21+
->in(__DIR__)
22+
->name('*.php')
23+
)
24+
;

.travis.yml

+1-23
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,18 @@ env:
99
global:
1010
- PHPUNIT_FLAGS="-v"
1111
- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit"
12-
- DEPENDENCIES="zendframework/zend-diactoros:^1.4.1 http-interop/http-factory-diactoros:^1.0"
1312

1413
matrix:
1514
fast_finish: true
1615
include:
1716
# Minimum supported dependencies with the latest and oldest PHP version
1817
- php: 7.2
1918
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
20-
- php: 5.3
21-
dist: 'precise'
22-
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors" DEPENDENCIES=""
2319

24-
# Test the latest stable release
25-
- php: 5.3
26-
dist: 'precise'
27-
env: DEPENDENCIES=""
28-
- php: 5.4
29-
env: DEPENDENCIES="zendframework/zend-diactoros:^1.4.1"
30-
- php: 5.5
31-
env: DEPENDENCIES="zendframework/zend-diactoros:^1.4.1"
32-
- php: 5.6
33-
env: DEPENDENCIES="zendframework/zend-diactoros:^1.4.1"
34-
- php: 7.0
3520
- php: 7.1
3621
- php: 7.2
3722
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text"
3823

39-
# Test LTS versions. This makes sure we do not use Symfony packages with version greater
40-
# than 2 or 3 respectively.
41-
- php: 7.2
42-
env: DEPENDENCIES="$DEPENDENCIES symfony/lts:^2 symfony/force-lowest:~2.8.0"
43-
- php: 7.2
44-
env: DEPENDENCIES="$DEPENDENCIES symfony/lts:^3 symfony/force-lowest:~3.4.0"
45-
4624
# Latest commit to master
4725
- php: 7.2
4826
env: STABILITY="dev"
@@ -66,4 +44,4 @@ script:
6644
- composer validate --strict --no-check-lock
6745
# simple-phpunit is the PHPUnit wrapper provided by the PHPUnit Bridge component and
6846
# it helps with testing legacy code and deprecations (composer require symfony/phpunit-bridge)
69-
- ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS
47+
- ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS

Factory/DiactorosFactory.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,7 @@ public function createRequest(Request $symfonyRequest)
5252
: \Zend\Diactoros\normalizeServer($symfonyRequest->server->all());
5353
$headers = $symfonyRequest->headers->all();
5454

55-
if (PHP_VERSION_ID < 50600) {
56-
$body = new DiactorosStream('php://temp', 'wb+');
57-
$body->write($symfonyRequest->getContent());
58-
} else {
59-
$body = new DiactorosStream($symfonyRequest->getContent(true));
60-
}
55+
$body = new DiactorosStream($symfonyRequest->getContent(true));
6156

6257
$files = method_exists('Zend\Diactoros\ServerRequestFactory', 'normalizeFiles')
6358
? DiactorosRequestFactory::normalizeFiles($this->getFiles($symfonyRequest->files->all()))
@@ -95,7 +90,7 @@ public function createRequest(Request $symfonyRequest)
9590
*/
9691
private function getFiles(array $uploadedFiles)
9792
{
98-
$files = array();
93+
$files = [];
9994

10095
foreach ($uploadedFiles as $key => $value) {
10196
if (null === $value) {
@@ -157,7 +152,7 @@ public function createResponse(Response $symfonyResponse)
157152
if (!isset($headers['Set-Cookie']) && !isset($headers['set-cookie'])) {
158153
$cookies = $symfonyResponse->headers->getCookies();
159154
if (!empty($cookies)) {
160-
$headers['Set-Cookie'] = array();
155+
$headers['Set-Cookie'] = [];
161156
foreach ($cookies as $cookie) {
162157
$headers['Set-Cookie'][] = $cookie->__toString();
163158
}

Factory/HttpFoundationFactory.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Bridge\PsrHttpMessage\Factory;
1313

14-
use Psr\Http\Message\ServerRequestInterface;
1514
use Psr\Http\Message\ResponseInterface;
15+
use Psr\Http\Message\ServerRequestInterface;
1616
use Psr\Http\Message\UploadedFileInterface;
1717
use Psr\Http\Message\UriInterface;
1818
use Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface;
@@ -33,7 +33,7 @@ class HttpFoundationFactory implements HttpFoundationFactoryInterface
3333
*/
3434
public function createRequest(ServerRequestInterface $psrRequest)
3535
{
36-
$server = array();
36+
$server = [];
3737
$uri = $psrRequest->getUri();
3838

3939
if ($uri instanceof UriInterface) {
@@ -48,7 +48,7 @@ public function createRequest(ServerRequestInterface $psrRequest)
4848
$server = array_replace($server, $psrRequest->getServerParams());
4949

5050
$parsedBody = $psrRequest->getParsedBody();
51-
$parsedBody = is_array($parsedBody) ? $parsedBody : array();
51+
$parsedBody = \is_array($parsedBody) ? $parsedBody : [];
5252

5353
$request = new Request(
5454
$psrRequest->getQueryParams(),
@@ -73,7 +73,7 @@ public function createRequest(ServerRequestInterface $psrRequest)
7373
*/
7474
private function getFiles(array $uploadedFiles)
7575
{
76-
$files = array();
76+
$files = [];
7777

7878
foreach ($uploadedFiles as $key => $value) {
7979
if ($value instanceof UploadedFileInterface) {
@@ -141,7 +141,7 @@ protected function getTemporaryPath()
141141
public function createResponse(ResponseInterface $psrResponse)
142142
{
143143
$cookies = $psrResponse->getHeader('Set-Cookie');
144-
$psrResponse = $psrResponse->withHeader('Set-Cookie', array());
144+
$psrResponse = $psrResponse->withHeader('Set-Cookie', []);
145145

146146
$response = new Response(
147147
$psrResponse->getBody()->__toString(),

Factory/PsrHttpFactory.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,7 @@ public function createRequest(Request $symfonyRequest)
5858
$request = $request->withHeader($name, $value);
5959
}
6060

61-
if (PHP_VERSION_ID < 50600) {
62-
$body = $this->streamFactory->createStreamFromFile('php://temp', 'wb+');
63-
$body->write($symfonyRequest->getContent());
64-
} else {
65-
$body = $this->streamFactory->createStreamFromResource($symfonyRequest->getContent(true));
66-
}
61+
$body = $this->streamFactory->createStreamFromResource($symfonyRequest->getContent(true));
6762

6863
$request = $request
6964
->withBody($body)
@@ -89,7 +84,7 @@ public function createRequest(Request $symfonyRequest)
8984
*/
9085
private function getFiles(array $uploadedFiles)
9186
{
92-
$files = array();
87+
$files = [];
9388

9489
foreach ($uploadedFiles as $key => $value) {
9590
if (null === $value) {
@@ -158,7 +153,7 @@ public function createResponse(Response $symfonyResponse)
158153
$headers = $symfonyResponse->headers->all();
159154
$cookies = $symfonyResponse->headers->getCookies();
160155
if (!empty($cookies)) {
161-
$headers['Set-Cookie'] = array();
156+
$headers['Set-Cookie'] = [];
162157

163158
foreach ($cookies as $cookie) {
164159
$headers['Set-Cookie'][] = $cookie->__toString();

HttpFoundationFactoryInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Bridge\PsrHttpMessage;
1313

14-
use Psr\Http\Message\ServerRequestInterface;
1514
use Psr\Http\Message\ResponseInterface;
15+
use Psr\Http\Message\ServerRequestInterface;
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Response;
1818

HttpMessageFactoryInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Bridge\PsrHttpMessage;
1313

14-
use Psr\Http\Message\ServerRequestInterface;
1514
use Psr\Http\Message\ResponseInterface;
15+
use Psr\Http\Message\ServerRequestInterface;
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Response;
1818

Tests/Factory/AbstractHttpMessageFactoryTest.php

+36-31
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,36 @@ public function testCreateRequest()
4444
{
4545
$stdClass = new \stdClass();
4646
$request = D7AE new Request(
47-
array(
47+
[
4848
'foo' => '1',
49-
'bar' => array('baz' => '42'),
50-
),
51-
array(
52-
'twitter' => array(
49+
'bar' => ['baz' => '42'],
50+
],
51+
[
52+
'twitter' => [
5353
'@dunglas' => 'Kévin Dunglas',
5454
'@coopTilleuls' => 'Les-Tilleuls.coop',
55-
),
55+
],
5656
'baz' => '2',
57-
),
58-
array(
57+
],
58+
[
5959
'a1' => $stdClass,
60-
'a2' => array('foo' => 'bar'),
61-
),
62-
array(
60+
'a2' => ['foo' => 'bar'],
61+
],
62+
[
6363
'c1' => 'foo',
64-
'c2' => array('c3' => 'bar'),
65-
),
66-
array(
64+
'c2' => ['c3' => 'bar'],
65+
],
66+
[
6767
'f1' => $this->createUploadedFile('F1', 'f1.txt', 'text/plain', UPLOAD_ERR_OK),
68-
'foo' => array('f2' => $this->createUploadedFile('F2', 'f2.txt', 'text/plain', UPLOAD_ERR_OK)),
69-
),
70-
array(
68+
'foo' => ['f2' => $this->createUploadedFile('F2', 'f2.txt', 'text/plain', UPLOAD_ERR_OK)],
69+
],
70+
[
7171
'REQUEST_METHOD' => 'POST',
7272
'HTTP_HOST' => 'dunglas.fr',
7373
'HTTP_X_SYMFONY' => '2.8',
7474
'REQUEST_URI' => '/testCreateRequest?foo=1&bar[baz]=42',
7575
'QUERY_STRING' => 'foo=1&bar[baz]=42',
76-
),
76+
],
7777
'Content'
7878
);
7979

@@ -116,13 +116,13 @@ public function testCreateRequest()
116116
$this->assertEquals('POST', $serverParams['REQUEST_METHOD']);
117117
$this->assertEquals('2.8', $serverParams['HTTP_X_SYMFONY']);
118118
$this->assertEquals('POST', $psrRequest->getMethod());
119-
$this->assertEquals(array('2.8'), $psrRequest->getHeader('X-Symfony'));
119+
$this->assertEquals(['2.8'], $psrRequest->getHeader('X-Symfony'));
120120
}
121121

122122
public function testGetContentCanBeCalledAfterRequestCreation()
123123
{
124-
$header = array('HTTP_HOST' => 'dunglas.fr');
125-
$request = new Request(array(), array(), array(), array(), array(), $header, 'Content');
124+
$header = ['HTTP_HOST' => 'dunglas.fr'];
125+
$request = new Request([], [], [], [], [], $header, 'Content');
126126

127127
$psrRequest = $this->factory->createRequest($request);
128128

@@ -139,6 +139,7 @@ private function createUploadedFile($content, $originalName, $mimeType, $error)
139139
// Symfony 4.1+
140140
return new UploadedFile($path, $originalName, $mimeType, $error, true);
141141
}
142+
142143
return new UploadedFile($path, $originalName, $mimeType, filesize($path), $error, true);
143144
}
144145

@@ -147,14 +148,14 @@ public function testCreateResponse()
147148
$response = new Response(
148149
'Response content.',
149150
202,
150-
array('X-Symfony' => array('3.4'))
151+
['X-Symfony' => ['3.4']]
151152
);
152-
$response->headers->setCookie(new Cookie('city', 'Lille', new \DateTime('Wed, 13 Jan 2021 22:23:01 GMT'), '/', null, false, true, false, ''));
153+
$response->headers->setCookie(new Cookie('city', 'Lille', new \DateTime('Wed, 13 Jan 2021 22:23:01 GMT'), '/', null, false, true, false, null));
153154

154155
$psrResponse = $this->factory->createResponse($response);
155156
$this->assertEquals('Response content.', $psrResponse->getBody()->__toString());
156157
$this->assertEquals(202, $psrResponse->getStatusCode());
157-
$this->assertEquals(array('3.4'), $psrResponse->getHeader('X-Symfony'));
158+
$this->assertEquals(['3.4'], $psrResponse->getHeader('X-Symfony'));
158159

159160
$cookieHeader = $psrResponse->getHeader('Set-Cookie');
160161
$this->assertInternalType('array', $cookieHeader);
@@ -201,17 +202,21 @@ public function testUploadErrNoFile()
201202
$this->assertEquals(UPLOAD_ERR_NO_FILE, $file->getError());
202203
$this->assertFalse($file->getSize(), 'SplFile::getSize() returns false on error');
203204

204-
$request = new Request(array(), array(), array(), array(),
205-
array(
205+
$request = new Request(
206+
[],
207+
[],
208+
[],
209+
[],
210+
[
206211
'f1' => $file,
207-
'f2' => array('name' => null, 'type' => null, 'tmp_name' => null, 'error' => UPLOAD_ERR_NO_FILE, 'size' => 0),
208-
),
209-
array(
212+
'f2' => ['name' => null, 'type' => null, 'tmp_name' => null, 'error' => UPLOAD_ERR_NO_FILE, 'size' => 0],
213+
],
214+
[
210215
'REQUEST_METHOD' => 'POST',
211216
'HTTP_HOST' => 'dunglas.fr',
212217
'HTTP_X_SYMFONY' => '2.8',
213-
),
214-
'Content'
218+
],
219+
'Content'
215220
);
216221

217222
$psrRequest = $this->factory->createRequest($request);

0 commit comments

Comments
 (0)
0