We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Questions? Forum: https://phalcon.io/forum or Discord: https://phalcon.io/discord
Describe the bug toArray uses the value directly instead using getters if exists. If a getter for a field exists, it should always be used.
To Reproduce See linked line in code
Steps to reproduce the behavior:
CREATE TABLE test_table ( id SERIAL, db_field VARCHAR(50) NULL ); INSERT INTO test_table VALUES (1, 'test value'); class TestModel extends \Phalcon\Mvc\Model { /** * @Primary * @Identity * @Column(type="integer", nullable=false, column="id") */ private ?int $id = null; /** * @Column(type="string", nullable=true, column="db_field") */ private ?string $dbField = null; public function initialize(): void { $this->setSource('test_table'); } public function getDbField(): string { return 'Some Prefix: ' . ($this->dbField ?? ''); } } $test = TestModel::findFirst(1); var_dump($test->toArray()); // array(2) { // ["id"]=> int(1) // ["dbField"]=> string(10) "test value" // }
Expected behavior toArray should call the getters.
// Expected output from script above echo $test->toArray(); // array(2) { // ["id"]=> int(1) // ["dbField"]=> string(23) "Some prefix: test value" // }
Details
The text was updated successfully, but these errors were encountered:
Resolved in #16469
Thank you @noone-silent
Sorry, something went wrong.
niden
No branches or pull requests
Questions? Forum: https://phalcon.io/forum or Discord: https://phalcon.io/discord
Describe the bug
toArray uses the value directly instead using getters if exists. If a getter for a field exists, it should always be used.
To Reproduce
See linked line in code
Steps to reproduce the behavior:
Expected behavior
toArray should call the getters.
Details
The text was updated successfully, but these errors were encountered: