MediaWiki REL1_37
GhostFieldAccessTrait.php
Go to the documentation of this file.
1<?php
22
36trait GhostFieldAccessTrait {
37
45 private function getGhostFieldValue( string $name ) {
46 if ( isset( $this->$name ) ) {
47 return $this->$name;
48 }
49
50 $data = (array)$this;
51
52 // Protected variables have a '*' prepended to the variable name.
53 // These prepended values have null bytes on either side.
54 $protectedName = "\x00*\x00{$name}";
55 if ( isset( $data[$protectedName] ) ) {
56 return $data[$protectedName];
57 }
58
59 // Private variables have the class name prepended to the variable name.
60 // These prepended values have null bytes on either side.
61 $thisClass = get_class( $this );
62 $privateName = "\x00{$thisClass}\x00{$name}";
63 if ( isset( $data[$privateName] ) ) {
64 return $data[$privateName];
65 }
66
67 return null;
68 }
69}