Skip to content

[BUG]: Conflict with typing parameters of the models #16736

@mpadinhabrandao

Description

@mpadinhabrandao

Motivation
In company where I work we decide start improve own php code, the best pratices say that we should type the function argumentes and the class properties. This step help use to make our code more efficient and reduce de errors and in the future when all code are typed we can use all power from the tools with AI like the copilot

The bug

We have two models CarModel and Manufacturer with properties typed, I do the builder to list the CarModels and self Manufacturer.
if CarModel doesn't have a Manufacturer all columns are in query results are null, when Phalcon recive the results it try associating null to all class properties. It's here where the error appends, some properties from my Manufacture Class not accept null.

To Reproduce

To reproduce the error clone this repo https://github.com/mpadinhabrandao/phalcon-error-example and run php example

Expected behavior
The object should assumes the default value in class.
So, if Phalcon not set de null the PHP are going to assume the default value.

I think that this solution not impact code because if yet don't type de models all propertires assume the null value, and if type classes already lead with this problem

Details

  • Phalcon version: 5.9.1
  • PHP Version: 8.1.28
  • Operating System: Debian GNU/Linux 12 (Docker)
  • Installation type: Compiling from source
  • Zephir version (if any):
  • Server: Nginx, but not necessary

Metadata

Metadata

Assignees

No one assigned

    Labels

    5.0The issues we want to solve in the 5.0 releasebugA bug reportstatus: mediumMedium

    Type

    No fields configured for Bug.

    Projects

    Status
    Released

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions