-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
324 additions
and
3 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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Nette\PhpGenerator\ClassType; | ||
use Tester\Assert; | ||
|
||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
require __DIR__ . '/fixtures/class-body.php'; | ||
|
||
|
||
Assert::exception(function () { | ||
ClassType::withBodiesFrom(PDO::class); | ||
}, Nette\InvalidStateException::class, 'Source code of PDO not found.'); | ||
|
||
|
||
Assert::exception(function () { | ||
ClassType::withBodiesFrom(new class { | ||
}); | ||
}, Nette\NotSupportedException::class, 'Anonymous classes are not supported.'); | ||
|
||
|
||
$res = ClassType::withBodiesFrom(Abc\Class7::class); | ||
sameFile(__DIR__ . '/expected/ClassType.from.bodies.expect', (string) $res); |
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,92 @@ | ||
abstract class Class7 | ||
{ | ||
abstract public function abstractFun(); | ||
|
||
|
||
public function emptyFun() | ||
{ | ||
} | ||
|
||
|
||
public function emptyFun2() | ||
{ | ||
} | ||
|
||
|
||
public function simple() | ||
{ | ||
return 1; | ||
} | ||
|
||
|
||
public function simple2() | ||
{ | ||
return 1; | ||
} | ||
|
||
|
||
public function long() | ||
{ | ||
if ($member instanceof Method) { | ||
$s = [1, 2, 3]; | ||
} | ||
/* | ||
$this->methods[$member->getName()] = $member; | ||
*/ | ||
throw new Nette\InvalidArgumentException('Argument must be Method|Property|Constant.'); | ||
} | ||
|
||
|
||
public function complex() | ||
{ | ||
echo 1; | ||
// single line comment | ||
|
||
// spaces - indent | ||
// spaces - indent | ||
|
||
/* multi | ||
line | ||
comment */ | ||
if ( | ||
$a | ||
&& $b + $c) | ||
{} | ||
|
||
/** multi | ||
line | ||
comment */ | ||
|
||
if ($member instanceof Method) { | ||
$s1 = ' | ||
a | ||
b | ||
c | ||
'; | ||
$s2 = " | ||
a | ||
{$b} | ||
$c | ||
"; | ||
|
||
$s3 = <<<DOC | ||
a | ||
{$b} | ||
$c | ||
DOC | ||
; | ||
$s3 = <<<'DOC' | ||
a | ||
b | ||
c | ||
DOC | ||
; | ||
?> | ||
a | ||
b | ||
c | ||
<?php | ||
} | ||
throw new Nette\InvalidArgumentException(); | ||
} | ||
} |
Oops, something went wrong.