Skip to content

Commit 39a4a9f

Browse files
authored
Merge pull request #90 from Codeception/improve-types
Improve types and code style
2 parents 57b35f9 + 9bb73d2 commit 39a4a9f

File tree

18 files changed

+419
-258
lines changed

18 files changed

+419
-258
lines changed

.github/workflows/main.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@ name: CI
33
on: [push, pull_request]
44

55
jobs:
6+
phpcs:
7+
name: Code style
8+
runs-on: 'ubuntu-latest'
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
13+
- name: Install PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: '8.1'
17+
ini-values: memory_limit=-1, date.timezone='UTC'
18+
tools: phpcs
19+
20+
- name: Check production code style
21+
run: phpcs src/
22+
23+
- name: Check test code style
24+
run: phpcs tests/ --standard=tests/phpcs.xml
625
tests:
726
runs-on: ubuntu-latest
827

@@ -11,7 +30,7 @@ jobs:
1130

1231
strategy:
1332
matrix:
14-
php: [8.0, 8.1]
33+
php: [8.0, 8.1, 8.2]
1534

1635
steps:
1736
- name: Checkout code

phpcs.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Codeception">
3+
<description>Codeception code standard</description>
4+
<rule ref="PSR12">
5+
<exclude name="Generic.Files.LineLength.TooLong"/>
6+
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
7+
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
8+
</rule>
9+
</ruleset>

src/Codeception/Constraint/JsonContains.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,8 @@
1616

1717
class JsonContains extends Constraint
1818
{
19-
/**
20-
* @var array
21-
*/
22-
protected $expected;
23-
24-
public function __construct(array $expected)
19+
public function __construct(protected array $expected)
2520
{
26-
$this->expected = $expected;
2721
}
2822

2923
/**

src/Codeception/Constraint/JsonType.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,17 @@
1313

1414
class JsonType extends Constraint
1515
{
16-
/**
17-
* @var array
18-
*/
19-
protected $jsonType;
20-
/**
21-
* @var bool
22-
*/
23-
private $match;
24-
25-
public function __construct(array $jsonType, bool $match = true)
26-
{
27-
$this->jsonType = $jsonType;
28-
$this->match = $match;
16+
public function __construct(
17+
protected array $jsonType,
18+
private bool $match = true
19+
) {
2920
}
3021

3122
/**
3223
* Evaluates the constraint for parameter $other. Returns true if the
3324
* constraint is met, false otherwise.
3425
*
35-
* @param mixed $jsonArray Value or object to evaluate.
26+
* @param array|JsonArray $jsonArray Value or object to evaluate.
3627
*/
3728
protected function matches($jsonArray): bool
3829
{

0 commit comments

Comments
 (0)