| 1 | <?php  | 
            ||
| 5 | trait ObjectAliases  | 
            ||
| 6 | { | 
            ||
| 7 | /**  | 
            ||
| 8 | * Get all object aliases as a dictionary.  | 
            ||
| 9 | *  | 
            ||
| 10 | * Eg. ['aliasName' => 'propertyNameOnObject']  | 
            ||
| 11 | *  | 
            ||
| 12 | * @return array  | 
            ||
| 13 | */  | 
            ||
| 14 | abstract protected function objectAliases();  | 
            ||
| 15 | |||
| 16 | /**  | 
            ||
| 17 | * Get the aliased object instance.  | 
            ||
| 18 | *  | 
            ||
| 19 | * @return object  | 
            ||
| 20 | */  | 
            ||
| 21 | abstract protected function getAliasedObject();  | 
            ||
| 22 | |||
| 23 | /**  | 
            ||
| 24 | * Get a property from the aliased object by the model's key.  | 
            ||
| 25 | *  | 
            ||
| 26 | * @param $key  | 
            ||
| 27 | *  | 
            ||
| 28 | * @return mixed|null  | 
            ||
| 29 | */  | 
            ||
| 30 | protected function aliasGet($key)  | 
            ||
| 38 | |||
| 39 | /**  | 
            ||
| 40 | * Set a property on the aliased object.  | 
            ||
| 41 | *  | 
            ||
| 42 | * @param string $key The alias name on the model  | 
            ||
| 43 | * @param mixed $value The value to set on the aliased object  | 
            ||
| 44 | *  | 
            ||
| 45 | * @return bool True if the alias was resolved and set; otherwise false  | 
            ||
| 46 | */  | 
            ||
| 47 | protected function aliasSet($key, $value)  | 
            ||
| 58 | |||
| 59 | /**  | 
            ||
| 60 | * Expands an alias into its respective object property name.  | 
            ||
| 61 | *  | 
            ||
| 62 | * @param string $key Alias key  | 
            ||
| 63 | *  | 
            ||
| 64 | * @return string|false The expanded alias, or false no alias exists for the key.  | 
            ||
| 65 | */  | 
            ||
| 66 | protected function expandAlias($key)  | 
            ||
| 70 | }  | 
            ||
| 71 | 
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: