Skip to content

Commit 353a216

Browse files
committed
Update PHP to 7.4 and remove Nette\Reflection
1 parent 6f2bcbf commit 353a216

File tree

6 files changed

+22
-35
lines changed

6 files changed

+22
-35
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
vendor
22
composer.lock
33
.idea
4+
.docker
45
tests/tmp/*
6+
docker-compose.yml
57

68
!.gitignore
79
!.gitkeep

Diff for: .travis.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ cache:
77
- $HOME/.composer/cache
88

99
php:
10-
- 7.1
10+
- 7.4
1111

1212
matrix:
1313
fast_finish: true
1414
include:
15-
- php: 7.1
15+
- php: 7.4
1616
env: PHPSTAN=1
17-
- php: 7.1
17+
- php: 7.4
1818
env: CODING_STANDARD=1
19-
- php: 7.1
19+
- php: 7.4
2020
env: COVERAGE="--coverage coverage.xml --coverage-src src" TESTER_RUNTIME="phpdbg"
2121

2222
install:
@@ -27,7 +27,7 @@ install:
2727
script:
2828
- vendor/bin/tester $COVERAGE -s -p ${TESTER_RUNTIME:-php} tests
2929
- php /tmp/php-parallel-lint/parallel-lint.php -e php,phpt --exclude vendor .
30-
- if [ "$PHPSTAN" = "1" ]; then php vendor/bin/phpstan.phar analyse --ansi --no-progress -l7 -c phpstan.neon src tests; fi
30+
- if [ "$PHPSTAN" = "1" ]; then php vendor/bin/phpstan.phar analyse --ansi --no-progress -l8 -c phpstan.neon src tests; fi
3131
- if [ "$CODING_STANDARD" = "1" ]; then php vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 -sp src tests; fi
3232

3333
after_script:

Diff for: composer.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
"sort-packages": true
1717
},
1818
"require": {
19-
"php": ">=7.1",
19+
"php": ">=7.4",
2020
"nette/application": "^3.0",
21-
"nette/reflection": "^2.4",
2221
"nette/utils": "^3.0"
2322
},
2423
"require-dev": {
25-
"grand-media/coding-standard": "^2.0",
24+
"grand-media/coding-standard": "^3.0",
2625
"nette/tester": "^2.0",
2726
"phpstan/phpstan": "^0.12"
2827
},

Diff for: src/UI/ComponentHelper.php

+8-13
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
use Nette\Application\Helpers;
66
use Nette\Application\UI\Component;
77
use Nette\Application\UI\Presenter;
8-
use Nette\Reflection\AnnotationsParser;
9-
use Nette\Utils\Reflection;
108
use Nette\Utils\Strings;
119

1210
final class ComponentHelper
@@ -24,14 +22,10 @@ public static function loadParameters(Component $component, array $params): arra
2422
$reflection = $component::getReflection();
2523

2624
foreach ($reflection->getPersistentParams() as $name => $meta) {
27-
if (isset($params[$name])) {
28-
$annotations = AnnotationsParser::getAll($reflection->getProperty($name));
29-
if (isset($annotations['var'])) {
30-
$className = Reflection::expandClassName(\end($annotations['var']), $reflection);
31-
$fromString = [$className, 'fromString'];
32-
if (\is_string($params[$name]) && \is_callable($fromString)) {
33-
$params[$name] = $fromString($params[$name]);
34-
}
25+
if (isset($params[$name]) && \class_exists($meta['type'])) {
26+
$fromString = [$meta['type'], 'fromString'];
27+
if (\is_string($params[$name]) && \is_callable($fromString)) {
28+
$params[$name] = $fromString($params[$name]);
3529
}
3630
}
3731
}
@@ -43,8 +37,9 @@ public static function loadParameters(Component $component, array $params): arra
4337
$methods[] = Presenter::formatRenderMethod($component->view);
4438
}
4539

46-
$signal = $component->getPresenter()->getSignal();
47-
if ($signal && $signal[0] === $component->getUniqueId()) {
40+
$presenter = $component->getPresenter();
41+
$signal = $presenter !== null ? $presenter->getSignal() : null;
42+
if (\is_array($signal) && $signal[0] === $component->getUniqueId()) {
4843
$methods[] = Component::formatSignalMethod($signal[1]);
4944
}
5045

@@ -79,7 +74,7 @@ public static function findTemplateFile(
7974
$templatesDir = self::joinFilePath(\dirname((string) $reflection->getFileName()), $directory);
8075

8176
if ($component instanceof Presenter) {
82-
[, $name] = Helpers::splitName($component->getName());
77+
[, $name] = Helpers::splitName((string) $component->getName());
8378

8479
$presenterTemplatesDir = self::joinFilePath($templatesDir, $name);
8580
if (\file_exists($presenterTemplatesDir)) {

Diff for: tests/Application/UI/Mocks/Parameter.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
final class Parameter
66
{
77

8-
/**
9-
* @var string
10-
*/
11-
private $value;
8+
private string $value;
129

1310
private function __construct()
1411
{

Diff for: tests/Application/UI/Mocks/Presenter.php

+4-10
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,11 @@
55
final class Presenter extends \Nette\Application\UI\Presenter
66
{
77

8-
/**
9-
* @var \GrandMediaTests\Application\UI\Mocks\Parameter
10-
* @persistent
11-
*/
12-
public $bar;
8+
/** @persistent */
9+
public Parameter $bar;
1310

14-
/**
15-
* @var \GrandMediaTests\Application\UI\Mocks\Parameter
16-
* @persistent
17-
*/
18-
public $baz;
11+
/** @persistent */
12+
public Parameter $baz;
1913

2014
public function actionDefault(Parameter $one, Parameter $two): void
2115
{

0 commit comments

Comments
 (0)