Skip to content

Commit 1925322

Browse files
committed
[utils] StaticClass: constructor is private [Closes nette/di#292]
- ReflectionClass::isInstance() returns false - it is marked as an error in the IDE nette/utils@dd7502e
1 parent 19252c9 commit 1925322

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

utils/src/StaticClass.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
trait StaticClass
1717
{
1818
/**
19-
* @return never
20-
* @throws \Error
19+
* Class is static and cannot be instantiated.
2120
*/
22-
final public function __construct()
21+
final private function __construct()
2322
{
24-
throw new \Error('Class ' . static::class . ' is static and cannot be instantiated.');
2523
}
2624

2725

utils/tests/Utils/StaticClass.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class TestClass
2323
Assert::exception(
2424
fn() => new TestClass,
2525
Error::class,
26-
'Class TestClass is static and cannot be instantiated.',
26+
'Call to private TestClass::__construct() from global scope',
2727
);
2828

2929
Assert::exception(

0 commit comments

Comments
 (0)