| 1 |
<?php |
| 2 |
|
| 3 |
// AUTOMATICALLY GENERATED. DO NOT EDIT. |
| 4 |
// Use `composer build` to regenerate. |
| 5 |
|
| 6 |
namespace Wikimedia\IDLeDOM\Helper; |
| 7 |
|
| 8 |
use Wikimedia\IDLeDOM\MediaList; |
| 9 |
|
| 10 |
trait CSSStyleSheetInit { |
| 11 |
|
| 12 |
// Underscore is used to avoid conflicts with DOM-reserved names |
| 13 |
// phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
| 14 |
// phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName |
| 15 |
|
| 16 |
/** |
| 17 |
* Handle an attempt to get a non-existing property on this |
| 18 |
* object. The default implementation raises an exception |
| 19 |
* but the implementor can choose a different behavior: |
| 20 |
* return null (like JavaScript), dynamically create the |
| 21 |
* property, etc. |
| 22 |
* @param string $prop the name of the property requested |
| 23 |
* @return mixed |
| 24 |
*/ |
| 25 |
protected function _getMissingProp( string $prop ) { |
| 26 |
$trace = debug_backtrace(); |
| 27 |
while ( |
| 28 |
count( $trace ) > 0 && |
| 29 |
$trace[0]['function'] !== "__get" |
| 30 |
) { |
| 31 |
array_shift( $trace ); |
| 32 |
} |
| 33 |
trigger_error( |
| 34 |
'Undefined property' . |
| 35 |
' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $prop . |
| 36 |
' in ' . ( $trace[0]['file'] ?? '' ) . |
| 37 |
' on line ' . ( $trace[0]['line'] ?? '' ), |
| 38 |
E_USER_NOTICE |
| 39 |
); |
| 40 |
return null; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Handle an attempt to set a non-existing property on this |
| 45 |
* object. The default implementation raises an exception |
| 46 |
* but the implementor can choose a different behavior: |
| 47 |
* ignore the operation (like JavaScript), dynamically create |
| 48 |
* the property, etc. |
| 49 |
* @param string $prop the name of the property requested |
| 50 |
* @param mixed $value the value to set |
| 51 |
*/ |
| 52 |
protected function _setMissingProp( string $prop, $value ): void { |
| 53 |
$trace = debug_backtrace(); |
| 54 |
while ( |
| 55 |
count( $trace ) > 0 && |
| 56 |
$trace[0]['function'] !== "__set" |
| 57 |
) { |
| 58 |
array_shift( $trace ); |
| 59 |
} |
| 60 |
trigger_error( |
| 61 |
'Undefined property' . |
| 62 |
' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $prop . |
| 63 |
' in ' . ( $trace[0]['file'] ?? '' ) . |
| 64 |
' on line ' . ( $trace[0]['line'] ?? '' ), |
| 65 |
E_USER_NOTICE |
| 66 |
); |
| 67 |
} |
| 68 |
|
| 69 |
// phpcs:enable |
| 70 |
|
| 71 |
/** |
| 72 |
* @param string $name |
| 73 |
* @return mixed |
| 74 |
*/ |
| 75 |
public function __get( string $name ) { |
| 76 |
'@phan-var \Wikimedia\IDLeDOM\CSSStyleSheetInit $this'; |
| 77 |
// @var \Wikimedia\IDLeDOM\CSSStyleSheetInit $this |
| 78 |
switch ( $name ) { |
| 79 |
case "baseURL": |
| 80 |
return $this->getBaseURL(); |
| 81 |
case "media": |
| 82 |
return $this->getMedia(); |
| 83 |
case "disabled": |
| 84 |
return $this->getDisabled(); |
| 85 |
default: |
| 86 |
break; |
| 87 |
} |
| 88 |
'@phan-var \Wikimedia\IDLeDOM\Helper\CSSStyleSheetInit $this'; |
| 89 |
// @var \Wikimedia\IDLeDOM\Helper\CSSStyleSheetInit $this |
| 90 |
return $this->_getMissingProp( $name ); |
| 91 |
} |
| 92 |
|
| 93 |
/** |
| 94 |
* @param string $name |
| 95 |
* @return bool |
| 96 |
*/ |
| 97 |
public function __isset( string $name ): bool { |
| 98 |
'@phan-var \Wikimedia\IDLeDOM\CSSStyleSheetInit $this'; |
| 99 |
// @var \Wikimedia\IDLeDOM\CSSStyleSheetInit $this |
| 100 |
switch ( $name ) { |
| 101 |
case "baseURL": |
| 102 |
return true; |
| 103 |
case "media": |
| 104 |
return true; |
| 105 |
case "disabled": |
| 106 |
return true; |
| 107 |
default: |
| 108 |
break; |
| 109 |
} |
| 110 |
return false; |
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* @param mixed $offset |
| 115 |
* @return bool |
| 116 |
*/ |
| 117 |
public function offsetExists( $offset ): bool { |
| 118 |
switch ( $offset ) { |
| 119 |
case "baseURL": |
| 120 |
case "media": |
| 121 |
case "disabled": |
| 122 |
return true; |
| 123 |
default: |
| 124 |
break; |
| 125 |
} |
| 126 |
return false; |
| 127 |
} |
| 128 |
|
| 129 |
/** |
| 130 |
* @param mixed $offset |
| 131 |
* @return mixed |
| 132 |
*/ |
| 133 |
#[\ReturnTypeWillChange] |
| 134 |
public function offsetGet( $offset ) { |
| 135 |
return $this->$offset; |
| 136 |
} |
| 137 |
|
| 138 |
/** |
| 139 |
* @param mixed $offset |
| 140 |
* @param mixed $value |
| 141 |
*/ |
| 142 |
public function offsetSet( $offset, $value ): void { |
| 143 |
$this->$offset = $value; |
| 144 |
} |
| 145 |
|
| 146 |
/** |
| 147 |
* @param mixed $offset |
| 148 |
*/ |
| 149 |
public function offsetUnset( $offset ): void { |
| 150 |
unset( $this->$offset ); |
| 151 |
} |
| 152 |
|
| 153 |
/** |
| 154 |
* Create a CSSStyleSheetInit from an associative array. |
| 155 |
* |
| 156 |
* @param array|\Wikimedia\IDLeDOM\CSSStyleSheetInit $a |
| 157 |
* @return \Wikimedia\IDLeDOM\CSSStyleSheetInit |
| 158 |
*/ |
| 159 |
public static function cast( $a ) { |
| 160 |
if ( $a instanceof \Wikimedia\IDLeDOM\CSSStyleSheetInit ) { |
| 161 |
return $a; |
| 162 |
} |
| 163 |
return new class( $a ) extends \Wikimedia\IDLeDOM\CSSStyleSheetInit { |
| 164 |
use CSSStyleSheetInit; |
| 165 |
|
| 166 |
/** @var array */ |
| 167 |
private $a; |
| 168 |
|
| 169 |
/** |
| 170 |
* @param array $a |
| 171 |
*/ |
| 172 |
public function __construct( $a ) { |
| 173 |
$this->a = $a; |
| 174 |
} |
| 175 |
|
| 176 |
/** |
| 177 |
* @return string |
| 178 |
*/ |
| 179 |
public function getBaseURL(): string { |
| 180 |
return $this->a["baseURL"] ?? null; |
| 181 |
} |
| 182 |
|
| 183 |
/** |
| 184 |
* @return MediaList|string |
| 185 |
*/ |
| 186 |
public function getMedia() { |
| 187 |
return $this->a["media"] ?? ''; |
| 188 |
} |
| 189 |
|
| 190 |
/** |
| 191 |
* @return bool |
| 192 |
*/ |
| 193 |
public function getDisabled(): bool { |
| 194 |
return $this->a["disabled"] ?? false; |
| 195 |
} |
| 196 |
|
| 197 |
}; |
| 198 |
} |
| 199 |
|
| 200 |
} |