Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code standards updated to PHP 7.3 #54

Merged
merged 2 commits into from May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
php: [7.1, 7.2, 7.3, 7.4, 8.0]
php: [7.3, 7.4, 8.0]

steps:
- name: Checkout code
Expand Down
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
vendor
.idea
.phpunit.result.cache
composer.lock
composer.phar
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog

## 1.5

* Removed support for `PHP 7.1` and `PHP 7.2`.
* Use strict types in the source code.

## 1.4

* Added **_Fluent Interface_** support, this allows you to add `it`'s and `should`'s chained to a `specify` or `describe`.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)

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

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -13,7 +13,7 @@ Inspired by MiniTest of Ruby now you combine BDD and classical TDD style in one

## Installation

*Requires PHP >= 7.1*
*Requires PHP >= 7.3*

* Install with Composer:

Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.4.3
1.5.0
6 changes: 3 additions & 3 deletions composer.json
Expand Up @@ -14,9 +14,9 @@
}
],
"require": {
"php": ">=7.1.0",
"myclabs/deep-copy": "~1.1",
"phpunit/phpunit": ">=7.0 <10.0"
"php": ">=7.3.0",
"myclabs/deep-copy": "^1.10",
"phpunit/phpunit": "^8.0|^9.0"
},
"autoload": {
"psr-0": {
Expand Down
4 changes: 3 additions & 1 deletion src/Codeception/Specify.php
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Codeception;

Expand Down
7 changes: 3 additions & 4 deletions src/Codeception/Specify/ObjectProperty.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Codeception\Specify;

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

/**
* @return string
*/
public function getName()
public function getName(): string
{
return $this->property->getName();
}
Expand Down
9 changes: 3 additions & 6 deletions src/Codeception/Specify/ResultPrinter.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Codeception\Specify;

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

class ResultPrinter extends DefaultResultPrinter
{
/**
* @param string $progress
*/
protected function writeProgress(string $progress) : void
protected function writeProgress(string $progress): void
{
$this->write($progress);
$this->column++;
Expand All @@ -25,6 +24,4 @@ protected function writeProgress(string $progress) : void
}
}
}


}
25 changes: 11 additions & 14 deletions src/Codeception/Specify/SpecifyHooks.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Codeception\Specify;

use Closure;
Expand Down Expand Up @@ -29,19 +31,17 @@ trait SpecifyHooks

private $specifyName = '';

/**
* @return SpecifyTest
*/
private function getCurrentSpecifyTest()
private function getCurrentSpecifyTest(): SpecifyTest
{
return $this->currentSpecifyTest;
}

/**
* @param string $specification
* @param Closure|null $callable
* @param callable|array $params
*/
private function runSpec($specification, Closure $callable = null, $params = [])
private function runSpec(string $specification, Closure $callable = null, $params = [])
{
if (!$callable) {
return;
Expand Down Expand Up @@ -100,7 +100,7 @@ private function runSpec($specification, Closure $callable = null, $params = [])
* @param $params
* @return array
*/
private function getSpecifyExamples($params)
private function getSpecifyExamples($params): array
{
if (isset($params['examples'])) {
if (!is_array($params['examples'])) {
Expand All @@ -111,10 +111,7 @@ private function getSpecifyExamples($params)
return [[]];
}

/**
* @return ReflectionClass|null
*/
private function specifyGetPhpUnitReflection()
private function specifyGetPhpUnitReflection(): ?ReflectionClass
{
if ($this instanceof TestCase) {
return new ReflectionClass(TestCase::class);
Expand All @@ -137,7 +134,7 @@ private function specifyCheckMockObjects()
/**
* @param ObjectProperty[] $properties
*/
private function specifyRestoreProperties($properties)
private function specifyRestoreProperties(array $properties)
{
foreach ($properties as $property) {
$property->restoreValue();
Expand All @@ -147,7 +144,7 @@ private function specifyRestoreProperties($properties)
/**
* @return ObjectProperty[]
*/
private function getSpecifyObjectProperties()
private function getSpecifyObjectProperties(): array
{
$objectReflection = new ReflectionObject($this);
$properties = $objectReflection->getProperties();
Expand Down Expand Up @@ -184,7 +181,7 @@ private function getSpecifyObjectProperties()
return $clonedProperties;
}

private function specifyGetClassPrivateProperties()
private function specifyGetClassPrivateProperties(): array
{
static $properties = [];

Expand All @@ -201,7 +198,7 @@ private function specifyGetClassPrivateProperties()
/**
* @param ObjectProperty[] $properties
*/
private function specifyCloneProperties($properties)
private function specifyCloneProperties(array $properties)
{
foreach ($properties as $property) {
$propertyValue = $property->getValue();
Expand Down
6 changes: 4 additions & 2 deletions src/Codeception/Specify/SpecifyTest.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Codeception\Specify;

use PHPUnit\Framework\AssertionFailedError;
Expand Down Expand Up @@ -33,7 +35,7 @@ public function toString() : string
return $this->name;
}

public function getName($withDataSet = true)
public function getName($withDataSet = true): string
{
if ($withDataSet && !empty($this->example)) {
$exporter = new Exporter();
Expand All @@ -52,7 +54,7 @@ public function getName($withDataSet = true)
* The return value is cast to an integer.
* @since 5.1.0
*/
public function count()
public function count(): int
{
return 1;
}
Expand Down
4 changes: 3 additions & 1 deletion tests/ObjectPropertyTest.php
@@ -1,8 +1,10 @@
<?php

declare(strict_types=1);

use Codeception\Specify\ObjectProperty;

class ObjectPropertyTest extends SpecifyUnitTest
final class ObjectPropertyTest extends SpecifyUnitTest
{
private $private = 'private';

Expand Down
2 changes: 2 additions & 0 deletions tests/SpecifyTest.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use PHPUnit\Framework\IncompleteTestError;

class SpecifyTest extends SpecifyUnitTest
Expand Down
1 change: 1 addition & 0 deletions tests/_bootstrap.php
@@ -1,3 +1,4 @@
<?php

require_once __DIR__.'/../vendor/autoload.php';
require_once __DIR__ . '/_support/SpecifyUnitTest.php';
2 changes: 2 additions & 0 deletions tests/_support/SpecifyUnitTest.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use PHPUnit\Framework\TestCase;

class SpecifyUnitTest extends TestCase
Expand Down