-
-
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.
Factory & Extractor: added support for property hooks & asymmetric vi…
…sibility
- Loading branch information
Showing
7 changed files
with
621 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* @phpVersion 8.4 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Nette\PhpGenerator\ClassType; | ||
use Nette\PhpGenerator\InterfaceType; | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
require __DIR__ . '/fixtures/classes.84.php'; | ||
|
||
$res[] = ClassType::from(Abc\PropertyHookSignatures::class); | ||
$res[] = ClassType::from(Abc\AbstractHookSignatures::class); | ||
$res[] = InterfaceType::from(Abc\InterfaceHookSignatures::class); | ||
$res[] = ClassType::from(Abc\AsymmetricVisibilitySignatures::class); | ||
$res[] = ClassType::from(Abc\CombinedSignatures::class); | ||
$res[] = ClassType::from(Abc\ConstructorAllSignatures::class); | ||
|
||
sameFile(__DIR__ . '/expected/ClassType.from.84.expect', implode("\n", $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,163 @@ | ||
class PropertyHookSignatures | ||
{ | ||
public string $basic { | ||
get { | ||
} | ||
} | ||
|
||
public string $fullGet { | ||
get { | ||
} | ||
} | ||
|
||
protected string $refGet { | ||
&get { | ||
} | ||
} | ||
|
||
protected string $finalGet { | ||
final get { | ||
} | ||
} | ||
|
||
public string $basicSet { | ||
set { | ||
} | ||
} | ||
|
||
public string $fullSet { | ||
set { | ||
} | ||
} | ||
|
||
public string $setWithParam { | ||
set(string $foo) { | ||
} | ||
} | ||
|
||
public string $setWithParam2 { | ||
set(string|int $value) { | ||
} | ||
} | ||
|
||
public string $finalSet { | ||
final set { | ||
} | ||
} | ||
|
||
public string $combined { | ||
set { | ||
} | ||
get { | ||
} | ||
} | ||
|
||
final public string $combinedFinal { | ||
/** comment set */ | ||
#[Set] | ||
set { | ||
} | ||
/** comment get */ | ||
#[Get] | ||
get { | ||
} | ||
} | ||
|
||
public string $virtualProp { | ||
set { | ||
} | ||
&get { | ||
} | ||
} | ||
} | ||
|
||
abstract class AbstractHookSignatures | ||
{ | ||
abstract public string $abstractGet { get; } | ||
abstract protected string $abstractSet { set; } | ||
abstract public string $abstractBoth { set; get; } | ||
|
||
abstract public string $mixedGet { | ||
set { | ||
} | ||
get; | ||
} | ||
|
||
abstract public string $mixedSet { | ||
set; | ||
get { | ||
} | ||
} | ||
} | ||
|
||
interface InterfaceHookSignatures | ||
{ | ||
public string $get { get; } | ||
|
||
public string $set { #[Set] | ||
set; } | ||
public string $both { set; get; } | ||
public string $refGet { &get; } | ||
} | ||
|
||
class AsymmetricVisibilitySignatures | ||
{ | ||
private(set) string $first; | ||
protected(set) string $second; | ||
protected private(set) string $third; | ||
private(set) string $fourth; | ||
protected(set) string $fifth; | ||
public readonly string $implicit; | ||
private(set) readonly string $readFirst; | ||
private(set) readonly string $readSecond; | ||
protected readonly string $readThird; | ||
public(set) readonly string $readFourth; | ||
private(set) string $firstFinal; | ||
final protected(set) string $secondFinal; | ||
protected private(set) string $thirdFinal; | ||
private(set) string $fourthFinal; | ||
final protected(set) string $fifthFinal; | ||
} | ||
|
||
class CombinedSignatures | ||
{ | ||
protected(set) string $prop2 { | ||
final set { | ||
} | ||
get { | ||
} | ||
} | ||
|
||
protected private(set) string $prop3 { | ||
set { | ||
} | ||
final get { | ||
} | ||
} | ||
} | ||
|
||
class ConstructorAllSignatures | ||
{ | ||
public function __construct( | ||
private(set) string $prop1, | ||
protected(set) string $prop2, | ||
protected private(set) string $prop3, | ||
private(set) string $prop4, | ||
protected(set) string $prop5, | ||
private(set) readonly string $readProp1, | ||
private(set) readonly string $readProp2, | ||
protected readonly string $readProp3, | ||
public(set) readonly string $readProp4, | ||
public string $hookProp1 { | ||
get { | ||
} | ||
}, | ||
protected(set) string $mixedProp1 { | ||
set { | ||
} | ||
get { | ||
} | ||
}, | ||
) { | ||
} | ||
} |
Oops, something went wrong.