Skip to content

Commit 7f821c2

Browse files
committed
🔨 improve on the __get() magic method
Signed-off-by: otengkwame <[email protected]>
1 parent 4ede584 commit 7f821c2

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

CodeIgniter/Framework/core/Input.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,11 +1341,20 @@ public function method($upper = false)
13411341
*/
13421342
public function __get($name)
13431343
{
1344-
if ($name === 'raw_input_stream') {
1345-
isset($this->_raw_input_stream) or $this->_raw_input_stream = file_get_contents('php://input');
1344+
1345+
if ($this->has($name)) {
1346+
return $this->index($name, true);
1347+
} elseif (
1348+
$name === 'raw_input_stream'
1349+
|| $name === 'rawInputStream'
1350+
|| $name === 'getContent'
1351+
) {
1352+
isset($this->_raw_input_stream) || $this->_raw_input_stream = file_get_contents('php://input');
13461353
return $this->_raw_input_stream;
1347-
} elseif ($name === 'ip_address') {
1348-
return $this->ip_address;
1349-
}
1354+
} elseif ($name === 'ip_address' || $name === 'ipAddress') {
1355+
return $this->ipAddress();
1356+
} else {
1357+
return null;
1358+
}
13501359
}
13511360
}

0 commit comments

Comments
 (0)