Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 407ea59

Browse files
committed
removed PHP 8.0 stuff
1 parent 2d80458 commit 407ea59

File tree

8 files changed

+9
-34
lines changed

8 files changed

+9
-34
lines changed

‎src/PhpGenerator/Dumper.php‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use Nette;
1313
use function addcslashes, array_keys, array_shift, count, dechex, implode, in_array, is_array, is_int, is_object, is_resource, is_string, ltrim, method_exists, ord, preg_match, preg_replace, preg_replace_callback, preg_split, range, serialize, str_contains, str_pad, str_repeat, str_replace, strlen, strrpos, strtoupper, substr, trim, unserialize, var_export;
14-
use const PHP_VERSION_ID, PREG_SPLIT_DELIM_CAPTURE, STR_PAD_LEFT;
14+
use const PREG_SPLIT_DELIM_CAPTURE, STR_PAD_LEFT;
1515

1616

1717
/**
@@ -160,9 +160,7 @@ private function dumpObject(object $var, array $parents, int $level, int $column
160160
} elseif ($var instanceof \Closure) {
161161
$inner = Nette\Utils\Callback::unwrap($var);
162162
if (Nette\Utils\Callback::isStatic($inner)) {
163-
return PHP_VERSION_ID < 80100
164-
? '\Closure::fromCallable(' . $this->dump($inner) . ')'
165-
: implode('::', (array) $inner) . '(...)';
163+
return implode('::', (array) $inner) . '(...)';
166164
}
167165

168166
throw new Nette\InvalidStateException('Cannot dump object of type Closure.');

‎src/PhpGenerator/Factory.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function fromClassReflection(
3838
}
3939

4040
$enumIface = null;
41-
if (PHP_VERSION_ID >= 80100 && $from->isEnum()) {
41+
if ($from->isEnum()) {
4242
$class = new EnumType($from->getShortName(), new PhpNamespace($from->getNamespaceName()));
4343
$from = new \ReflectionEnum($from->getName());
4444
$enumIface = $from->isBacked() ? \BackedEnum::class : \UnitEnum::class;
@@ -214,7 +214,7 @@ public function fromParameterReflection(\ReflectionParameter $from): Parameter
214214
$property = $from->getDeclaringClass()->getProperty($from->name);
215215
$param = (new PromotedParameter($from->name))
216216
->setVisibility($this->getVisibility($property))
217-
->setReadOnly(PHP_VERSION_ID >= 80100 && $property->isReadonly())
217+
->setReadOnly($property->isReadonly())
218218
->setFinal(PHP_VERSION_ID >= 80500 && $property->isFinal() && !$property->isPrivateSet());
219219
$this->addHooks($property, $param);
220220
} else {
@@ -248,7 +248,7 @@ public function fromConstantReflection(\ReflectionClassConstant $from): Constant
248248
$const = new Constant($from->name);
249249
$const->setValue($from->getValue());
250250
$const->setVisibility($this->getVisibility($from));
251-
$const->setFinal(PHP_VERSION_ID >= 80100 && $from->isFinal());
251+
$const->setFinal($from->isFinal());
252252
$const->setComment(Helpers::unformatDocComment((string) $from->getDocComment()));
253253
$const->setAttributes($this->getAttributes($from));
254254
return $const;
@@ -274,7 +274,7 @@ public function fromPropertyReflection(\ReflectionProperty $from): Property
274274
$prop->setVisibility($this->getVisibility($from));
275275
$prop->setType((string) $from->getType());
276276
$prop->setInitialized($from->hasType() && array_key_exists($prop->getName(), $defaults));
277-
$prop->setReadOnly(PHP_VERSION_ID >= 80100 && $from->isReadOnly());
277+
$prop->setReadOnly($from->isReadOnly());
278278
$prop->setComment(Helpers::unformatDocComment((string) $from->getDocComment()));
279279
$prop->setAttributes($this->getAttributes($from));
280280

‎tests/PhpGenerator/ClassType.from.81.phpt‎

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

3-
/**
4-
* @phpVersion 8.1
5-
*/
6-
73
declare(strict_types=1);
84

95
use Nette\PhpGenerator\ClassType;

‎tests/PhpGenerator/Dumper.dump().enum.phpt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
/**
44
* Test: Nette\PhpGenerator\Dumper::dump() enum
5-
* @phpVersion 8.1
65
*/
76

87
declare(strict_types=1);

‎tests/PhpGenerator/Dumper.dump().phpt‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ class Test2 extends Test
116116
}
117117

118118
Assert::same(
119-
PHP_VERSION_ID < 80100
120-
? "\\Nette\\PhpGenerator\\Dumper::createObject(\\Test2::class, [\n\t\"\\x00Test2\\x00c\" => 4,\n\t'a' => 1,\n\t\"\\x00*\\x00b\" => 2,\n])"
121-
: "\\Nette\\PhpGenerator\\Dumper::createObject(\\Test2::class, [\n\t'a' => 1,\n\t\"\\x00*\\x00b\" => 2,\n\t\"\\x00Test2\\x00c\" => 4,\n])",
119+
"\\Nette\\PhpGenerator\\Dumper::createObject(\\Test2::class, [\n\t'a' => 1,\n\t\"\\x00*\\x00b\" => 2,\n\t\"\\x00Test2\\x00c\" => 4,\n])",
122120
$dumper->dump(new Test2),
123121
);
124122
Assert::equal(new Test2, eval('return ' . $dumper->dump(new Test2) . ';'));
@@ -134,16 +132,12 @@ Assert::exception(function () {
134132

135133
// closures
136134
Assert::same(
137-
PHP_VERSION_ID < 80100
138-
? "\\Closure::fromCallable('strlen')"
139-
: 'strlen(...)',
135+
'strlen(...)',
140136
$dumper->dump(Closure::fromCallable('strlen')),
141137
);
142138

143139
Assert::same(
144-
PHP_VERSION_ID < 80100
145-
? "\\Closure::fromCallable(['Nette\\PhpGenerator\\ClassLike', 'from'])"
146-
: 'Nette\PhpGenerator\ClassLike::from(...)',
140+
'Nette\PhpGenerator\ClassLike::from(...)',
147141
$dumper->dump(Closure::fromCallable([Nette\PhpGenerator\ClassLike::class, 'from'])),
148142
);
149143

‎tests/PhpGenerator/EnumType.from.phpt‎

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

3-
/**
4-
* @phpVersion 8.1
5-
*/
6-
73
declare(strict_types=1);
84

95
use Nette\PhpGenerator\EnumType;

‎tests/PhpGenerator/GlobalFunction.from.81.phpt‎

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

3-
/**
4-
* @phpVersion 8.1
5-
*/
6-
73
declare(strict_types=1);
84

95
use Nette\PhpGenerator\GlobalFunction;

‎tests/PhpGenerator/Method.from.81.phpt‎

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

3-
/**
4-
* @phpVersion 8.1
5-
*/
6-
73
declare(strict_types=1);
84

95
use Nette\PhpGenerator\Method;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /