Skip to content

Commit 339d40a

Browse files
authored
Merge branch 'master' into feature/dump-exception
2 parents 8c03ad6 + 08a14f8 commit 339d40a

File tree

115 files changed

+674
-686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+674
-686
lines changed

.github/ISSUE_TEMPLATE/Bug_report.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: "🐛 Bug Report"
3+
about: "If something isn't working as expected 🤔"
4+
5+
---
6+
7+
Version: ?.?.?
8+
9+
### Bug Description
10+
... A clear and concise description of what the bug is. A good bug report shouldn't leave others needing to chase you up for more information.
11+
12+
### Steps To Reproduce
13+
... If possible a minimal demo of the problem ...
14+
15+
### Expected Behavior
16+
... A clear and concise description of what you expected to happen.
17+
18+
### Possible Solution
19+
... Only if you have suggestions on a fix for the bug
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name: "🚀 Feature Request"
3+
about: "I have a suggestion (and may want to implement it) 🙂"
4+
5+
---
6+
7+
- Is your feature request related to a problem? Please describe.
8+
- Explain your intentions.
9+
- It's up to you to make a strong case to convince the project's developers of the merits of this feature.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: "🤗 Support Question"
3+
about: "If you have a question 💬, please check out our forum!"
4+
5+
---
6+
7+
--------------^ Click "Preview" for a nicer view!
8+
We primarily use GitHub as an issue tracker; for usage and support questions, please check out these resources below. Thanks! 😁.
9+
10+
* Nette Forum: https://forum.nette.org
11+
* Nette Gitter: https://gitter.im/nette/nette
12+
* Slack (czech): https://pehapkari.slack.com/messages/C2R30BLKA

.github/ISSUE_TEMPLATE/Support_us.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: "❤️ Support us"
3+
about: "If you would like to support our efforts in maintaining this project 🙌"
4+
5+
---
6+
7+
--------------^ Click "Preview" for a nicer view!
8+
9+
> https://nette.org/donate
10+
11+
Help support Nette!
12+
13+
We develop Nette Framework for more than 14 years. In order to make your life more comfortable. Nette cares about the safety of your sites. Nette saves you time. And gives job opportunities.
14+
15+
Nette earns you money. And is absolutely free.
16+
17+
To ensure future development and improving the documentation, we need your donation.
18+
19+
Whether you are chief of IT company which benefits from Nette, or developer who goes for advice on our forum, if you like Nette, [please make a donation now](https://nette.org/donate).
20+
21+
Thank you!

.github/issue_template.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/pull_request_template.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
- bug fix? yes/no <!-- #issue numbers, if any -->
2-
- new feature? yes/no
1+
- bug fix / new feature? <!-- #issue numbers, if any -->
32
- BC break? yes/no
43
- doc PR: nette/docs#??? <!-- highly welcome, see https://nette.org/en/writing -->
54

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
language: php
22
php:
3-
- 5.6
4-
- 7.0
53
- 7.1
64
- 7.2
75

@@ -31,11 +29,11 @@ jobs:
3129
php: 7.1
3230
install:
3331
# Install Nette Code Checker
34-
- travis_retry composer create-project nette/code-checker temp/code-checker ~2 --no-progress
32+
- travis_retry composer create-project nette/code-checker temp/code-checker ^3.0 --no-progress
3533
# Install Nette Coding Standard
3634
- travis_retry composer create-project nette/coding-standard temp/coding-standard --no-progress
3735
script:
38-
- php temp/code-checker/src/code-checker.php --short-arrays
36+
- php temp/code-checker/src/code-checker.php --strict-types -i "tests/*/fixtures*" -i tests/Runner/find-tests
3937
- php temp/coding-standard/ecs check src tests --config tests/coding-standard.neon;
4038

4139

appveyor.yml

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,33 @@ init:
88
- SET ANSICON=121x90 (121x90)
99

1010
install:
11-
# Install PHP 5.6
12-
- IF EXIST c:\php\56 (SET PHP=0) ELSE (SET PHP=1)
13-
- IF %PHP%==1 mkdir c:\php\56
14-
- IF %PHP%==1 cd c:\php\56
15-
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.6.30-Win32-VC11-x86.zip
16-
- IF %PHP%==1 7z x php-5.6.30-Win32-VC11-x86.zip >nul
17-
- IF %PHP%==1 del /Q *.zip
18-
19-
# Install PHP 7.0
20-
- IF EXIST c:\php\70 (SET PHP=0) ELSE (SET PHP=1)
21-
- IF %PHP%==1 mkdir c:\php\70
22-
- IF %PHP%==1 cd c:\php\70
23-
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-7.0.20-Win32-VC14-x86.zip
24-
- IF %PHP%==1 7z x php-7.0.20-Win32-VC14-x86.zip >nul
25-
- IF %PHP%==1 del /Q *.zip
26-
2711
# Install PHP 7.1
2812
- IF EXIST c:\php\71 (SET PHP=0) ELSE (SET PHP=1)
2913
- IF %PHP%==1 mkdir c:\php\71
3014
- IF %PHP%==1 cd c:\php\71
31-
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-7.1.6-Win32-VC14-x86.zip
32-
- IF %PHP%==1 7z x php-7.1.6-Win32-VC14-x86.zip >nul
15+
- IF %PHP%==1 curl https://windows.php.net/downloads/releases/archives/php-7.1.6-Win32-VC14-x64.zip --output php.zip
16+
- IF %PHP%==1 7z x php.zip >nul
3317
- IF %PHP%==1 del /Q *.zip
3418

35-
# Install PHP 7.1 x64
36-
- IF EXIST c:\php\71x64 (SET PHP=0) ELSE (SET PHP=1)
37-
- IF %PHP%==1 mkdir c:\php\71x64
38-
- IF %PHP%==1 cd c:\php\71x64
39-
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-7.1.6-Win32-VC14-x64.zip
40-
- IF %PHP%==1 7z x php-7.1.6-Win32-VC14-x64.zip >nul
19+
# Install PHP 7.2
20+
- IF EXIST c:\php\72 (SET PHP=0) ELSE (SET PHP=1)
21+
- IF %PHP%==1 mkdir c:\php\72
22+
- IF %PHP%==1 cd c:\php\72
23+
- IF %PHP%==1 curl https://windows.php.net/downloads/releases/archives/php-7.2.2-Win32-VC15-x64.zip --output php.zip
24+
- IF %PHP%==1 7z x php.zip >nul
4125
- IF %PHP%==1 del /Q *.zip
4226

4327
- cd c:\projects\tester
4428

4529
test_script:
46-
- c:\php\56\php src\tester tests -s -p c:\php\56\php
47-
- c:\php\56\php src\tester tests -s -p c:\php\56\php-cgi
48-
49-
- c:\php\70\php src\tester tests -s -p c:\php\70\php
50-
- c:\php\70\php src\tester tests -s -p c:\php\70\php-cgi
51-
- c:\php\70\php src\tester tests -s -p c:\php\70\phpdbg
52-
5330
- c:\php\71\php src\tester tests -s -p c:\php\71\php
5431
- c:\php\71\php src\tester tests -s -p c:\php\71\php-cgi
5532
- c:\php\71\php src\tester tests -s -p c:\php\71\phpdbg
5633

57-
- c:\php\71x64\php src\tester tests -s -p c:\php\71x64\php
58-
- c:\php\71x64\php src\tester tests -s -p c:\php\71x64\php-cgi
59-
- c:\php\71x64\php src\tester tests -s -p c:\php\71x64\phpdbg
34+
- c:\php\72\php src\tester tests -s -p c:\php\72\php
35+
- c:\php\72\php src\tester tests -s -p c:\php\72\php-cgi
36+
- c:\php\72\php src\tester tests -s -p c:\php\72\phpdbg
37+
38+
on_failure:
39+
# Print *.actual content
40+
- for /r %%x in (*.actual) do ( type "%%x" )

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
}
1616
],
1717
"require": {
18-
"php": ">=5.6.0"
18+
"php": ">=7.1"
1919
},
2020
"autoload": {
2121
"classmap": ["src/"]
2222
},
2323
"bin": ["src/tester"],
2424
"extra": {
25-
"branch-alias": { "dev-master": "2.0-dev" }
25+
"branch-alias": { "dev-master": "2.1-dev" }
2626
}
2727
}

readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ composer require nette/tester --dev
2929

3030
Alternatively, you can download the [tester.phar](https://github.com/nette/tester/releases) file.
3131

32-
Nette Tester requires PHP 5.6.0 and supports PHP up to 7.2. Collecting and processing
32+
Nette Tester requires PHP 7.1 and supports PHP up to 7.2. Collecting and processing
3333
code coverage information depends on Xdebug, or PHPDBG.
3434

3535

@@ -72,9 +72,9 @@ Now we run tests from command-line using the `tester` command:
7272
> tester
7373
_____ ___ ___ _____ ___ ___
7474
|_ _/ __)( __/_ _/ __)| _ )
75-
|_| \___ /___) |_| \___ |_|_\ v2.0.1
75+
|_| \___ /___) |_| \___ |_|_\ v2.1.0
7676
77-
PHP 5.6.0 | php -n | 8 threads
77+
PHP 7.2.3 | php -n | 8 threads
7878
.
7979
OK (1 tests, 0 skipped, 0.0 seconds)
8080
```

src/CodeCoverage/Collector.php

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* Copyright (c) 2009 David Grudl (https://davidgrudl.com)
66
*/
77

8+
declare(strict_types=1);
9+
810
namespace Tester\CodeCoverage;
911

1012

@@ -20,29 +22,24 @@ class Collector
2022
private static $collector;
2123

2224

23-
/**
24-
* @return bool
25-
*/
26-
public static function isStarted()
25+
public static function isStarted(): bool
2726
{
2827
return self::$file !== null;
2928
}
3029

3130

3231
/**
3332
* Starts gathering the information for code coverage.
34-
* @param string
35-
* @return void
3633
* @throws \LogicException
3734
*/
38-
public static function start($file)
35+
public static function start(string $file): void
3936
{
4037
if (self::isStarted()) {
4138
throw new \LogicException('Code coverage collector has been already started.');
4239
}
4340
self::$file = fopen($file, 'c+');
4441

45-
if (defined('PHPDBG_VERSION') && PHP_VERSION_ID >= 70000) {
42+
if (defined('PHPDBG_VERSION')) {
4643
phpdbg_start_oplog();
4744
self::$collector = 'collectPhpDbg';
4845

@@ -51,8 +48,7 @@ public static function start($file)
5148
self::$collector = 'collectXdebug';
5249

5350
} else {
54-
$alternative = PHP_VERSION_ID >= 70000 ? ' or phpdbg SAPI' : '';
55-
throw new \LogicException("Code coverage functionality requires Xdebug extension$alternative.");
51+
throw new \LogicException('Code coverage functionality requires Xdebug extension or phpdbg SAPI.');
5652
}
5753

5854
register_shutdown_function(function () {
@@ -64,7 +60,7 @@ public static function start($file)
6460
/**
6561
* Flushes all gathered information. Effective only with PHPDBG collector.
6662
*/
67-
public static function flush()
63+
public static function flush(): void
6864
{
6965
if (self::isStarted() && self::$collector === 'collectPhpDbg') {
7066
self::save();
@@ -74,16 +70,15 @@ public static function flush()
7470

7571
/**
7672
* Saves information about code coverage. Can be called repeatedly to free memory.
77-
* @return void
7873
* @throws \LogicException
7974
*/
80-
public static function save()
75+
public static function save(): void
8176
{
8277
if (!self::isStarted()) {
8378
throw new \LogicException('Code coverage collector has not been started.');
8479
}
8580

86-
list($positive, $negative) = call_user_func([__CLASS__, self::$collector]);
81+
[$positive, $negative] = [__CLASS__, self::$collector]();
8782

8883
flock(self::$file, LOCK_EX);
8984
fseek(self::$file, 0);
@@ -100,9 +95,8 @@ public static function save()
10095

10196
/**
10297
* Collects information about code coverage.
103-
* @return array
10498
*/
105-
private static function collectXdebug()
99+
private static function collectXdebug(): array
106100
{
107101
$positive = $negative = [];
108102

@@ -126,9 +120,8 @@ private static function collectXdebug()
126120

127121
/**
128122
* Collects information about code coverage.
129-
* @return array
130123
*/
131-
private static function collectPhpDbg()
124+
private static function collectPhpDbg(): array
132125
{
133126
$positive = phpdbg_end_oplog();
134127
$negative = phpdbg_get_executable();

src/CodeCoverage/Generators/AbstractGenerator.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* Copyright (c) 2009 David Grudl (https://davidgrudl.com)
66
*/
77

8+
declare(strict_types=1);
9+
810
namespace Tester\CodeCoverage\Generators;
911

1012

@@ -13,7 +15,7 @@
1315
*/
1416
abstract class AbstractGenerator
1517
{
16-
const
18+
protected const
1719
CODE_DEAD = -2,
1820
CODE_UNTESTED = -1,
1921
CODE_TESTED = 1;
@@ -35,10 +37,10 @@ abstract class AbstractGenerator
3537

3638

3739
/**
38-
* @param string path to coverage.dat file
39-
* @param string path to covered source file or directory
40+
* @param string $file path to coverage.dat file
41+
* @param string $source path to covered source file or directory
4042
*/
41-
public function __construct($file, $source = null)
43+
public function __construct(string $file, string $source = null)
4244
{
4345
if (!is_file($file)) {
4446
throw new \Exception("File '$file' is missing.");
@@ -69,14 +71,14 @@ public function __construct($file, $source = null)
6971
}
7072

7173

72-
public function render($file = null)
74+
public function render(string $file = null): void
7375
{
7476
$handle = $file ? @fopen($file, 'w') : STDOUT; // @ is escalated to exception
7577
if (!$handle) {
7678
throw new \Exception("Unable to write to file '$file'.");
7779
}
7880

79-
ob_start(function ($buffer) use ($handle) { fwrite($handle, $buffer); }, 4096);
81+
ob_start(function (string $buffer) use ($handle) { fwrite($handle, $buffer); }, 4096);
8082
try {
8183
$this->renderSelf();
8284
} catch (\Exception $e) {
@@ -93,25 +95,19 @@ public function render($file = null)
9395
}
9496

9597

96-
/**
97-
* @return float
98-
*/
99-
public function getCoveredPercent()
98+
public function getCoveredPercent(): float
10099
{
101100
return $this->totalSum ? $this->coveredSum * 100 / $this->totalSum : 0;
102101
}
103102

104103

105-
/**
106-
* @return \Iterator
107-
*/
108-
protected function getSourceIterator()
104+
protected function getSourceIterator(): \Iterator
109105
{
110106
$iterator = is_dir($this->source)
111107
? new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->source))
112108
: new \ArrayIterator([new \SplFileInfo($this->source)]);
113109

114-
return new \CallbackFilterIterator($iterator, function (\SplFileInfo $file) {
110+
return new \CallbackFilterIterator($iterator, function (\SplFileInfo $file): bool {
115111
return $file->getBasename()[0] !== '.' // . or .. or .gitignore
116112
&& in_array($file->getExtension(), $this->acceptFiles, true);
117113
});

0 commit comments

Comments
 (0)