Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ClassType, Method: added validate(), prevents classes and methods fro…
…m declared both final and abstract [BC break] (#36)
- Loading branch information
Showing
9 changed files
with
95 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Nette\PhpGenerator\ClassType; | ||
use Tester\Assert; | ||
|
||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
// class cannot be final and abstract | ||
Assert::exception(function () { | ||
$class = new ClassType; | ||
$class->setFinal(true)->setAbstract(true); | ||
$class->validate(); | ||
}, Nette\InvalidStateException::class, 'Class cannot be abstract and final.'); | ||
|
||
Assert::exception(function () { | ||
$class = new ClassType; | ||
$class->setAbstract(true)->setFinal(true); | ||
$class->validate(); | ||
}, Nette\InvalidStateException::class, 'Class cannot be abstract and final.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Nette\PhpGenerator\Method; | ||
use Tester\Assert; | ||
|
||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
// method cannot be final and abstract | ||
Assert::exception(function () { | ||
$method = new Method('foo'); | ||
$method->setFinal(true)->setAbstract(true); | ||
$method->validate(); | ||
}, Nette\InvalidStateException::class, 'Method cannot be abstract and final or private.'); | ||
|
||
Assert::exception(function () { | ||
$method = new Method('foo'); | ||
$method->setAbstract(true)->setFinal(true); | ||
$method->validate(); | ||
}, Nette\InvalidStateException::class, 'Method cannot be abstract and final or private.'); | ||
|
||
Assert::exception(function () { | ||
$method = new Method('foo'); | ||
$method->setAbstract(true)->setVisibility('private'); | ||
$method->validate(); | ||
}, Nette\InvalidStateException::class, 'Method cannot be abstract and final or private.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters