Skip to content

Commit be2d682

Browse files
committed
Code standards updated to PHP 7.2
1 parent bd1d991 commit be2d682

File tree

9 files changed

+121
-106
lines changed

9 files changed

+121
-106
lines changed

composer.json

+41-39
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
{
2-
"name":"codeception/module-phalcon4",
3-
"description":"Codeception module for Phalcon 4 framework",
4-
"keywords":["codeception", "phalcon", "phalcon4"],
5-
"homepage":"https://codeception.com/",
6-
"type":"library",
7-
"license":"MIT",
8-
"authors": [
9-
{
10-
"name": "Phalcon Team",
11-
"email": "[email protected]",
12-
"homepage": "https://phalcon.io/en/team"
13-
},
14-
{
15-
"name": "Codeception Team",
16-
"email": "[email protected]",
17-
"homepage": "http://codeception.com/"
18-
}
19-
],
20-
"require": {
21-
"php": ">=7.2.0",
22-
"ext-phalcon": ">=4",
23-
"codeception/codeception": "^4.0",
24-
"codeception/lib-innerbrowser": "^1.0",
25-
"codeception/module-asserts": "^1.0",
26-
"codeception/module-phpbrowser": "^1.0",
27-
"codeception/module-db": "^1.0"
28-
},
29-
"require-dev": {
30-
"codeception/util-robohelpers": "dev-master",
31-
"vlucas/phpdotenv": "^4.1",
32-
"squizlabs/php_codesniffer": "^3.4",
33-
"vimeo/psalm": "^3.6"
34-
},
35-
"autoload":{
36-
"classmap": ["src/"]
37-
},
38-
"config": {
39-
"classmap-authoritative": true
40-
}
2+
"name": "codeception/module-phalcon4",
3+
"description": "Codeception module for Phalcon 4 framework",
4+
"keywords": [ "codeception", "phalcon", "phalcon4" ],
5+
"homepage": "https://codeception.com/",
6+
"type": "library",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Phalcon Team",
11+
"email": "[email protected]",
12+
"homepage": "https://phalcon.io/en/team"
13+
},
14+
{
15+
"name": "Codeception Team",
16+
"email": "[email protected]",
17+
"homepage": "https://codeception.com/"
18+
}
19+
],
20+
"require": {
21+
"php": ">=7.2.0",
22+
"ext-json": "*",
23+
"codeception/codeception": "^4.0",
24+
"codeception/lib-innerbrowser": "^1.0",
25+
"codeception/module-asserts": "^1.0",
26+
"codeception/module-phpbrowser": "^1.0",
27+
"codeception/module-db": "^1.0"
28+
},
29+
"require-dev": {
30+
"codeception/util-robohelpers": "dev-master",
31+
"vlucas/phpdotenv": "^4.1",
32+
"squizlabs/php_codesniffer": "^3.4",
33+
"vimeo/psalm": "^3.6"
34+
},
35+
"autoload": {
36+
"classmap": [
37+
"src/"
38+
]
39+
},
40+
"config": {
41+
"classmap-authoritative": true
42+
}
4143
}

readme.md

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

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

1216
```

src/Codeception/Lib/Connector/Phalcon4.php

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Codeception\Lib\Connector;
46

57
use Closure;
@@ -9,13 +11,15 @@
911
use Phalcon\Http;
1012
use Phalcon\Mvc\Application;
1113
use Phalcon\Mvc\Micro as MicroApplication;
14+
use ReflectionException;
1215
use ReflectionProperty;
1316
use RuntimeException;
14-
use Symfony\Component\BrowserKit\AbstractBrowser as Client;
17+
use Symfony\Component\BrowserKit\AbstractBrowser;
1518
use Symfony\Component\BrowserKit\Cookie;
19+
use Symfony\Component\BrowserKit\Request;
1620
use Symfony\Component\BrowserKit\Response;
1721

18-
class Phalcon4 extends Client
22+
class Phalcon4 extends AbstractBrowser
1923
{
2024
use PhpSuperGlobalsConverter;
2125

@@ -30,7 +34,7 @@ class Phalcon4 extends Client
3034
*
3135
* @param mixed $application
3236
*/
33-
public function setApplication($application)
37+
public function setApplication($application): void
3438
{
3539
$this->application = $application;
3640
}
@@ -43,10 +47,11 @@ public function setApplication($application)
4347
public function getApplication()
4448
{
4549
$application = $this->application;
46-
4750
if ($application instanceof Closure) {
4851
return $application();
49-
} elseif (is_string($application)) {
52+
}
53+
54+
if (is_string($application)) {
5055
/** @noinspection PhpIncludeInspection */
5156
return require $application;
5257
}
@@ -57,12 +62,11 @@ public function getApplication()
5762
/**
5863
* Makes a request.
5964
*
60-
* @param \Symfony\Component\BrowserKit\Request $request
65+
* @param Request $request
6166
*
62-
* @return \Symfony\Component\BrowserKit\Response
63-
* @throws \RuntimeException
67+
* @throws RuntimeException|ReflectionException
6468
*/
65-
public function doRequest($request)
69+
public function doRequest($request): Response
6670
{
6771
$application = $this->getApplication();
6872
if (!$application instanceof Application && !$application instanceof MicroApplication) {
@@ -99,7 +103,7 @@ public function doRequest($request)
99103
$_POST = $_REQUEST;
100104
}
101105

102-
parse_str($queryString, $output);
106+
parse_str((string) $queryString, $output);
103107
foreach ($output as $k => $v) {
104108
$_GET[$k] = $v;
105109
}
@@ -125,12 +129,14 @@ public function doRequest($request)
125129

126130
$headersProperty = new ReflectionProperty($headers, 'headers');
127131
$headersProperty->setAccessible(true);
132+
128133
$headers = $headersProperty->getValue($headers);
129134
if (!is_array($headers)) {
130135
$headers = [];
131136
}
132137

133138
$cookiesProperty = new ReflectionProperty($di['cookies'], 'cookies');
139+
134140
$cookiesProperty->setAccessible(true);
135141
$cookies = $cookiesProperty->getValue($di['cookies']);
136142
if (is_array($cookies)) {
@@ -156,7 +162,7 @@ public function doRequest($request)
156162

157163
return new Response(
158164
$response->getContent() ?: '',
159-
$status ? $status : 200,
165+
$status !== 0 ? $status : 200,
160166
$headers
161167
);
162168
}

0 commit comments

Comments
 (0)