<?php
class Example
{
public $properties;
public function functionA(int $number): string
{
return 'bar';
}
return $this->properties[$number]['from'] ?? 'bar';
}
public function functionB(int $number): string
{
return $this->properties[$number]['from'] ?? 'bar';
}
}
$example = new Example();
/* Scenario with no value set */
$a = $example->functionA(1);
$b = $example->functionB(1);
/* Scenario with value set */
$example->properties = [
1 => [
'from' => 'Foo'
]
];
$a = $example->functionA(1);
$b = $example->functionB(1);
PD9waHAKCmNsYXNzIEV4YW1wbGUKewoJcHVibGljICRwcm9wZXJ0aWVzOwoJCiAgICBwdWJsaWMgZnVuY3Rpb24gZnVuY3Rpb25BKGludCAkbnVtYmVyKTogc3RyaW5nCiAgICB7CiAgICAgICAgaWYgKGlzX251bGwoJHRoaXMtPnByb3BlcnRpZXMpKSB7CiAgICAgICAgICAgIHJldHVybiAnYmFyJzsKICAgICAgICB9CgogICAgICAgIHJldHVybiAkdGhpcy0+cHJvcGVydGllc1skbnVtYmVyXVsnZnJvbSddID8/ICdiYXInOwogICAgfQoJCiAgICBwdWJsaWMgZnVuY3Rpb24gZnVuY3Rpb25CKGludCAkbnVtYmVyKTogc3RyaW5nCiAgICB7CiAgICAgICAgcmV0dXJuICR0aGlzLT5wcm9wZXJ0aWVzWyRudW1iZXJdWydmcm9tJ10gPz8gJ2Jhcic7CiAgICB9Cn0KCiRleGFtcGxlID0gbmV3IEV4YW1wbGUoKTsKCi8qIFNjZW5hcmlvIHdpdGggbm8gdmFsdWUgc2V0ICovCiRhID0gJGV4YW1wbGUtPmZ1bmN0aW9uQSgxKTsKJGIgPSAkZXhhbXBsZS0+ZnVuY3Rpb25CKDEpOwoKdmFyX2R1bXAoJGEsICRiLCAkYSA9PT0gJGIpOwoKLyogU2NlbmFyaW8gd2l0aCB2YWx1ZSBzZXQgKi8KJGV4YW1wbGUtPnByb3BlcnRpZXMgPSBbCgkxID0+IFsKCQknZnJvbScgPT4gJ0ZvbycKCV0KXTsKCiRhID0gJGV4YW1wbGUtPmZ1bmN0aW9uQSgxKTsKJGIgPSAkZXhhbXBsZS0+ZnVuY3Rpb25CKDEpOwoKdmFyX2R1bXAoJGEsICRiLCAkYSA9PT0gJGIpOwoK