Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TavoNiievez committed Jul 28, 2024
1 parent e03e2d9 commit d6ac43b
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ updates:
package-ecosystem: composer
directory: "/"
schedule:
interval: weekly
interval: monthly
versioning-strategy: auto
groups:
dev-dependencies:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
php: [8.0, 8.1, 8.2, 8.3]
php: [8.1, 8.2, 8.3]

steps:
- name: Checkout code
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@
],
"homepage": "https://codeception.com/",
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-json": "*",
"codeception/codeception": "*@dev",
"codeception/lib-innerbrowser": "*@dev",
"guzzlehttp/guzzle": "^7.4",
"symfony/browser-kit": "^5.4 || ^6.0 || ^7.0"
"symfony/browser-kit": "^5.4 | ^6.0 | ^7.0"
},
"require-dev": {
"ext-curl": "*",
"squizlabs/php_codesniffer": "^3.10",
"phpstan/phpstan": "^1.10",
"rector/rector": "^1.0",
"aws/aws-sdk-php": "^3.199",
"codeception/module-rest": "^2.0 || *@dev"
"codeception/module-rest": "^2.0 | *@dev"
},
"conflict": {
"codeception/codeception": "<5.0",
Expand Down
4 changes: 1 addition & 3 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
<arg name="parallel" value="5"/>
<arg value="np"/>

<!-- Don't hide tokenizer exceptions -->
<rule ref="Internal.Tokenizer.Exception">
<type>error</type>
</rule>

<!-- Include the whole PSR12 standard -->

<rule ref="PSR12"/>

<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
Expand Down
3 changes: 1 addition & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
parameters:
paths:
- ./src
# The level 9 is the highest level (with check for mixed type)
level: 6
level: 5
47 changes: 0 additions & 47 deletions rector.php

This file was deleted.

18 changes: 9 additions & 9 deletions src/Codeception/Lib/Connector/Guzzle.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected function createResponse(Psr7Response $psr7Response): BrowserKitRespons
$matches
);

if (($matchesMeta === 0 || $matchesMeta === false) && isset($headers['Refresh'])) {
if (!$matchesMeta && isset($headers['Refresh'])) {
// match by header
preg_match(
'#^\s*(\d*)\s*;\s*url=(.*)#i',
Expand Down Expand Up @@ -181,7 +181,7 @@ protected function getAbsoluteUri(string $uri): string
return Uri::mergeUrls((string)$baseUri, $uri);
}

protected function doRequest(object $request): BrowserKitResponse
protected function doRequest(object $request)
{
/** @var BrowserKitRequest $request **/
$guzzleRequest = new Psr7Request(
Expand All @@ -208,12 +208,12 @@ protected function doRequest(object $request): BrowserKitResponse
} else {
$response = $this->client->send($guzzleRequest, $options);
}
} catch (RequestException $requestException) {
if (!$requestException->hasResponse()) {
throw $requestException;
} catch (RequestException $exception) {
if (!$exception->hasResponse()) {
throw $exception;
}

$response = $requestException->getResponse();
$response = $exception->getResponse();
}

// @phpstan-ignore-next-line
Expand All @@ -223,10 +223,10 @@ protected function doRequest(object $request): BrowserKitResponse
/**
* @return array<string, mixed>
*/
protected function extractHeaders(BrowserKitRequest $browserKitRequest): array
protected function extractHeaders(BrowserKitRequest $request): array
{
$headers = [];
$server = $browserKitRequest->getServer();
$server = $request->getServer();

$contentHeaders = ['Content-Length' => true, 'Content-Md5' => true, 'Content-Type' => true];
foreach ($server as $header => $val) {
Expand Down Expand Up @@ -310,7 +310,7 @@ protected function mapFiles(array $requestFiles, ?string $arrayName = ''): array
{
$files = [];
foreach ($requestFiles as $name => $info) {
if ($arrayName !== null && $arrayName !== '' && $arrayName !== '0') {
if (!empty($arrayName)) {
$name = $arrayName . '[' . $name . ']';
}

Expand Down
19 changes: 10 additions & 9 deletions src/Codeception/Module/PhpBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,19 @@ class PhpBrowser extends InnerBrowser implements Remote, MultiSession
'connect_timeout'
];

/**
* @var Guzzle
*/
public ?AbstractBrowser $client = null;

public ?GuzzleClient $guzzle = null;

public function _initialize(): void
public function _initialize()
{
$this->_initializeSession();
}

public function _before(TestInterface $test): void
public function _before(TestInterface $test)
{
if (!$this->client instanceof AbstractBrowser) {
$this->client = new Guzzle();
Expand All @@ -139,7 +142,7 @@ public function _before(TestInterface $test): void
$this->_prepareSession();
}

public function _getUrl(): string
public function _getUrl()
{
return $this->config['url'];
}
Expand Down Expand Up @@ -185,7 +188,7 @@ public function amOnSubdomain(string $subdomain): void
$this->_reconfigure($config);
}

protected function onReconfigure(): void
protected function onReconfigure()
{
$this->_prepareSession();
}
Expand Down Expand Up @@ -249,16 +252,14 @@ public function _prepareSession(): void
$defaults['handler'] = $handlerStack;
$this->guzzle = new GuzzleClient($defaults);

if ($this->client instanceof Guzzle) {
$this->client->setRefreshMaxInterval($this->config['refresh_max_interval']);
$this->client->setClient($this->guzzle);
}
$this->client->setRefreshMaxInterval($this->config['refresh_max_interval']);
$this->client->setClient($this->guzzle);
}

/**
* @return array<string, mixed>
*/
public function _backupSession(): array
public function _backupSession()
{
return [
'client' => $this->client,
Expand Down

0 comments on commit d6ac43b

Please sign in to comment.