Skip to content

Commit 2256435

Browse files
authored
Code standards updated to PHP 7.3 (#54)
1 parent b7a7d49 commit 2256435

File tree

16 files changed

+45
-35
lines changed

16 files changed

+45
-35
lines changed

.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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
vendor
22
.idea
33
.phpunit.result.cache
4+
composer.lock
45
composer.phar

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 1.5
4+
5+
* Removed support for `PHP 7.1` and `PHP 7.2`.
6+
* Use strict types in the source code.
7+
38
## 1.4
49

510
* Added **_Fluent Interface_** support, this allows you to add `it`'s and `should`'s chained to a `specify` or `describe`.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013-2020 Codeception PHP Testing Framework
3+
Copyright (c) 2013-2021 Codeception PHP Testing Framework
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Inspired by MiniTest of Ruby now you combine BDD and classical TDD style in one
1313

1414
## Installation
1515

16-
*Requires PHP >= 7.1*
16+
*Requires PHP >= 7.3*
1717

1818
* Install with Composer:
1919

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.3
1+
1.5.0

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
}
1515
],
1616
"require": {
17-
"php": ">=7.1.0",
18-
"myclabs/deep-copy": "~1.1",
19-
"phpunit/phpunit": ">=7.0 <10.0"
17+
"php": ">=7.3.0",
18+
"myclabs/deep-copy": "^1.10",
19+
"phpunit/phpunit": "^8.0|^9.0"
2020
},
2121
"autoload": {
2222
"psr-0": {

src/Codeception/Specify.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Codeception;
46

src/Codeception/Specify/ObjectProperty.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

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

57
use ReflectionProperty;
@@ -47,10 +49,7 @@ public function __construct($owner, $property, $value = null)
4749
$this->initValue = ($value === null ? $this->getValue() : $value);
4850
}
4951

50-
/**
51-
* @return string
52-
*/
53-
public function getName()
52+
public function getName(): string
5453
{
5554
return $this->property->getName();
5655
}

src/Codeception/Specify/ResultPrinter.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

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

57
use PHPUnit\TextUI\DefaultResultPrinter;
@@ -10,10 +12,7 @@ class_alias(\PHPUnit\TextUI\ResultPrinter::class, DefaultResultPrinter::class);
1012

1113
class ResultPrinter extends DefaultResultPrinter
1214
{
13-
/**
14-
* @param string $progress
15-
*/
16-
protected function writeProgress(string $progress) : void
15+
protected function writeProgress(string $progress): void
1716
{
1817
$this->write($progress);
1918
$this->column++;
@@ -25,6 +24,4 @@ protected function writeProgress(string $progress) : void
2524
}
2625
}
2726
}
28-
29-
3027
}

src/Codeception/Specify/SpecifyHooks.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

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

57
use Closure;
@@ -29,19 +31,17 @@ trait SpecifyHooks
2931

3032
private $specifyName = '';
3133

32-
/**
33-
* @return SpecifyTest
34-
*/
35-
private function getCurrentSpecifyTest()
34+
private function getCurrentSpecifyTest(): SpecifyTest
3635
{
3736
return $this->currentSpecifyTest;
3837
}
38+
3939
/**
4040
* @param string $specification
4141
* @param Closure|null $callable
4242
* @param callable|array $params
4343
*/
44-
private function runSpec($specification, Closure $callable = null, $params = [])
44+
private function runSpec(string $specification, Closure $callable = null, $params = [])
4545
{
4646
if (!$callable) {
4747
return;
@@ -100,7 +100,7 @@ private function runSpec($specification, Closure $callable = null, $params = [])
100100
* @param $params
101101
* @return array
102102
*/
103-
private function getSpecifyExamples($params)
103+
private function getSpecifyExamples($params): array
104104
{
105105
if (isset($params['examples'])) {
106106
if (!is_array($params['examples'])) {
@@ -111,10 +111,7 @@ private function getSpecifyExamples($params)
111111
return [[]];
112112
}
113113

114-
/**
115-
* @return ReflectionClass|null
116-
*/
117-
private function specifyGetPhpUnitReflection()
114+
private function specifyGetPhpUnitReflection(): ?ReflectionClass
118115
{
119116
if ($this instanceof TestCase) {
120117
return new ReflectionClass(TestCase::class);
@@ -137,7 +134,7 @@ private function specifyCheckMockObjects()
137134
/**
138135
* @param ObjectProperty[] $properties
139136
*/
140-
private function specifyRestoreProperties($properties)
137+
private function specifyRestoreProperties(array $properties)
141138
{
142139
foreach ($properties as $property) {
143140
$property->restoreValue();
@@ -147,7 +144,7 @@ private function specifyRestoreProperties($properties)
147144
/**
148145
* @return ObjectProperty[]
149146
*/
150-
private function getSpecifyObjectProperties()
147+
private function getSpecifyObjectProperties(): array
151148
{
152149
$objectReflection = new ReflectionObject($this);
153150
$properties = $objectReflection->getProperties();
@@ -184,7 +181,7 @@ private function getSpecifyObjectProperties()
184181
return $clonedProperties;
185182
}
186183

187-
private function specifyGetClassPrivateProperties()
184+
private function specifyGetClassPrivateProperties(): array
188185
{
189186
static $properties = [];
190187

@@ -201,7 +198,7 @@ private function specifyGetClassPrivateProperties()
201198
/**
202199
* @param ObjectProperty[] $properties
203200
*/
204-
private function specifyCloneProperties($properties)
201+
private function specifyCloneProperties(array $properties)
205202
{
206203
foreach ($properties as $property) {
207204
$propertyValue = $property->getValue();

src/Codeception/Specify/SpecifyTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

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

57
use PHPUnit\Framework\AssertionFailedError;
@@ -33,7 +35,7 @@ public function toString() : string
3335
return $this->name;
3436
}
3537

36-
public function getName($withDataSet = true)
38+
public function getName($withDataSet = true): string
3739
{
3840
if ($withDataSet && !empty($this->example)) {
3941
$exporter = new Exporter();
@@ -52,7 +54,7 @@ public function getName($withDataSet = true)
5254
* The return value is cast to an integer.
5355
* @since 5.1.0
5456
*/
55-
public function count()
57+
public function count(): int
5658
{
5759
return 1;
5860
}

tests/ObjectPropertyTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use Codeception\Specify\ObjectProperty;
46

5-
class ObjectPropertyTest extends SpecifyUnitTest
7+
final class ObjectPropertyTest extends SpecifyUnitTest
68
{
79
private $private = 'private';
810

tests/SpecifyTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use PHPUnit\Framework\IncompleteTestError;
46

57
class SpecifyTest extends SpecifyUnitTest

tests/_bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<?php
2+
23
require_once __DIR__.'/../vendor/autoload.php';
34
require_once __DIR__ . '/_support/SpecifyUnitTest.php';

tests/_support/SpecifyUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use PHPUnit\Framework\TestCase;
46

57
class SpecifyUnitTest extends TestCase

0 commit comments

Comments
 (0)