36trait GhostFieldAccessTrait {
46 private function getGhostFieldValue(
string $name,
string ...$aliases ) {
47 if ( isset( $this->$name ) ) {
55 $protectedName =
"\x00*\x00{$name}";
56 if ( isset( $data[$protectedName] ) ) {
57 return $data[$protectedName];
62 $thisClass = get_class( $this );
63 $privateName =
"\x00{$thisClass}\x00{$name}";
64 if ( isset( $data[$privateName] ) ) {
65 return $data[$privateName];
69 foreach ( $aliases as $thisClass ) {
70 $privateName =
"\x00{$thisClass}\x00{$name}";
71 if ( isset( $data[$privateName] ) ) {
72 return $data[$privateName];
88 private function restoreAliasedGhostField(
string $name,
string ...$aliases ): void {
90 foreach ( $aliases as $thisClass ) {
91 $privateName =
"\x00{$thisClass}\x00{$name}";
92 if ( isset( $data[$privateName] ) ) {
93 $this->$name = $data[$privateName];
94 unset( $data[$privateName] );