Skip to content

Commit 3b648e7

Browse files
committed
StaticClass: constructor is private [Closes nette/di#292]
- ReflectionClass::isInstance() returns false - it is marked as an error in the IDE
1 parent a4175c6 commit 3b648e7

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

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

tests/Utils/StaticClass.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class TestClass
2222

2323
Assert::exception(function () {
2424
new TestClass;
25-
}, Error::class, 'Class TestClass is static and cannot be instantiated.');
25+
}, Error::class, 'Call to private TestClass::__construct() %a%');
2626

2727
Assert::exception(function () {
2828
TestClass::methodA();

0 commit comments

Comments
 (0)