Skip to content

Commit f016ebe

Browse files
authored
Code standards updated to PHP 7.3 (#9)
1 parent 3891d9c commit f016ebe

6 files changed

Lines changed: 62 additions & 46 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
strategy:
1010
matrix:
11-
php: [7.1, 7.2, 7.3, 7.4, 8.0]
11+
php: [7.3, 7.4, 8.0]
1212

1313
steps:
1414
- name: Checkout code

composer.json

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
{
2-
"name":"codeception/module-mezzio",
3-
"description":"Codeception module for Mezzio framework",
4-
"keywords":["codeception", "mezzio"],
5-
"homepage":"http://codeception.com/",
6-
"type":"library",
7-
"license":"MIT",
8-
"authors":[
9-
{
10-
"name":"Gintautas Miselis"
11-
}
12-
],
13-
"minimum-stability": "RC",
14-
"require": {
15-
"php": ">=5.6.0 <9.0",
16-
"codeception/lib-innerbrowser": "^1.0",
17-
"codeception/codeception": "^4.0"
18-
},
19-
"require-dev": {
20-
"codeception/module-rest": "dev-master",
21-
"mezzio/mezzio": "~2.0 | ~3.0"
22-
},
23-
"autoload":{
24-
"classmap": ["src/"]
25-
},
26-
"config": {
27-
"classmap-authoritative": true
28-
}
2+
"name": "codeception/module-mezzio",
3+
"description": "Codeception module for Mezzio framework",
4+
"keywords": [ "codeception", "mezzio" ],
5+
"homepage": "https://codeception.com/",
6+
"type": "library",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Gintautas Miselis"
11+
}
12+
],
13+
"minimum-stability": "RC",
14+
"require": {
15+
"php": "^7.3 || ^8.0",
16+
"codeception/lib-innerbrowser": "^1.0",
17+
"codeception/codeception": "^4.0"
18+
},
19+
"require-dev": {
20+
"codeception/module-rest": "^1.0",
21+
"mezzio/mezzio": "^3.0"
22+
},
23+
"autoload": {
24+
"classmap": [
25+
"src/"
26+
]
27+
},
28+
"config": {
29+
"classmap-authoritative": true
30+
}
2931
}

readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ A Codeception module for Mezzio framework.
77
[![Total Downloads](https://poser.pugx.org/codeception/module-mezzio/downloads)](https://packagist.org/packages/codeception/module-mezzio)
88
[![License](https://poser.pugx.org/codeception/module-mezzio/license)](/LICENSE)
99

10+
## Requirements
11+
12+
* `PHP 7.3` or higher.
13+
1014
## Installation
1115

1216
```

src/Codeception/Lib/Connector/Mezzio.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Codeception\Lib\Connector;
36

47
use Codeception\Configuration;
58
use Codeception\Lib\Connector\Mezzio\ResponseCollector;
9+
use Exception;
10+
use Interop\Container\ContainerInterface;
611
use Symfony\Component\BrowserKit\AbstractBrowser as Client;
712
use Symfony\Component\BrowserKit\Response;
813
use Symfony\Component\BrowserKit\Request as BrowserKitRequest;
@@ -23,7 +28,7 @@ class Mezzio extends Client
2328
private $responseCollector;
2429

2530
/**
26-
* @var \Interop\Container\ContainerInterface
31+
* @var ContainerInterface
2732
*/
2833
private $container;
2934

@@ -34,9 +39,7 @@ class Mezzio extends Client
3439

3540
/**
3641
* @param BrowserKitRequest $request
37-
*
38-
* @return Response
39-
* @throws \Exception
42+
* @throws Exception
4043
*/
4144
public function doRequest($request)
4245
{
@@ -115,7 +118,7 @@ public function doRequest($request)
115118
);
116119
}
117120

118-
private function convertFiles(array $files)
121+
private function convertFiles(array $files): array
119122
{
120123
$fileObjects = [];
121124
foreach ($files as $fieldName => $file) {
@@ -136,7 +139,7 @@ private function convertFiles(array $files)
136139
return $fileObjects;
137140
}
138141

139-
private function extractHeaders(BrowserKitRequest $request)
142+
private function extractHeaders(BrowserKitRequest $request): array
140143
{
141144
$headers = [];
142145
$server = $request->getServer();
@@ -155,7 +158,7 @@ private function extractHeaders(BrowserKitRequest $request)
155158
return $headers;
156159
}
157160

158-
public function initApplication()
161+
public function initApplication(): Application
159162
{
160163
$cwd = getcwd();
161164
$projectDir = Configuration::projectDir();
@@ -191,7 +194,7 @@ public function initApplication()
191194
return $app;
192195
}
193196

194-
private function initResponseCollector()
197+
private function initResponseCollector(): void
195198
{
196199
if (!method_exists($this->application, 'getEmitter')) {
197200
//Does not exist in Mezzio v3
@@ -210,21 +213,18 @@ private function initResponseCollector()
210213
$emitterStack->unshift($this->responseCollector);
211214
}
212215

213-
public function getContainer()
216+
public function getContainer(): ContainerInterface
214217
{
215218
return $this->container;
216219
}
217220

218-
/**
219-
* @param Application
220-
*/
221-
public function setApplication(Application $application)
221+
public function setApplication(Application $application): void
222222
{
223223
$this->application = $application;
224224
$this->initResponseCollector();
225225
}
226226

227-
public function setConfig(array $config)
227+
public function setConfig(array $config): void
228228
{
229229
$this->config = $config;
230230
}

src/Codeception/Lib/Connector/Mezzio/ResponseCollector.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Codeception\Lib\Connector\Mezzio;
36

7+
use LogicException;
48
use Psr\Http\Message\ResponseInterface;
59
use Laminas\Diactoros\Response\EmitterInterface;
610

@@ -16,15 +20,15 @@ public function emit(ResponseInterface $response)
1620
$this->response = $response;
1721
}
1822

19-
public function getResponse()
23+
public function getResponse(): ResponseInterface
2024
{
2125
if ($this->response === null) {
22-
throw new \LogicException('Response wasn\'t emitted yet');
26+
throw new LogicException('Response wasn\'t emitted yet');
2327
}
2428
return $this->response;
2529
}
2630

27-
public function clearResponse()
31+
public function clearResponse(): void
2832
{
2933
$this->response = null;
3034
}

src/Codeception/Module/Mezzio.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Codeception\Module;
36

47
use Codeception\Lib\Framework;
@@ -31,6 +34,9 @@
3134
*/
3235
class Mezzio extends Framework implements DoctrineProvider
3336
{
37+
/**
38+
* @var array
39+
*/
3440
protected $config = [
3541
'container' => 'config/container.php',
3642
'recreateApplicationBetweenTests' => true,
@@ -73,7 +79,7 @@ public function _before(TestInterface $test)
7379
if ($this->config['recreateApplicationBetweenTests'] != false && $this->config['recreateApplicationBetweenRequests'] == false) {
7480
$this->application = $this->client->initApplication();
7581
$this->container = $this->client->getContainer();
76-
} elseif (isset($this->application)) {
82+
} elseif ($this->application !== null) {
7783
$this->client->setApplication($this->application);
7884
}
7985
}

0 commit comments

Comments
 (0)