orm icon indicating copy to clipboard operation
orm copied to clipboard

PHP 8.4 support

Open beberlei opened this issue 1 year ago • 1 comments

This issue tracks all the necessary work for supporting PHP 8.4 in Doctrine.

  • [x] Add 8.4 to CI workflow https://github.com/doctrine/orm/pull/11631
  • [x] Prevent use of property hooks in ORM 2, 3.* for now. https://github.com/doctrine/orm/pull/11628
  • [ ] Add tests with property hooks
  • [ ] Reasonably sure that reflection abstraction breaks with property hook edge cases [ReflectionPublicProperty](https://github.com/doctrine/persistence/tree/3.3.x/src/Persistence/Reflection due to Internal vs external respresentation storage. (we need to use setRawValue/getRawValue).
  • [ ] isVirtual properties cannot be mapped to the dabase, ClassMetadata needs to throw exception on this.
  • [x] Common Proxy Generator emits a depreecation for 8.4 https://github.com/doctrine/common/pull/1016
  • [x] Lazy Objects support #11853

beberlei avatar Oct 08 '24 09:10 beberlei

Is there somewhere we should be paying attention to see when support for property hooks will be added?

zwalden avatar Jan 02 '25 23:01 zwalden

Why did you explicitly disallowed property hooks in v3.3.3. It seem to worked fine with it before. Throwing an exception breaks my code now. Is there a chance to convert this to a warning?

Kinqdos avatar May 05 '25 06:05 Kinqdos

Sorry, it was never supposed to be allowed until 3.4.0

greg0ire avatar May 05 '25 07:05 greg0ire

@Kinqdos try changing doctrine/orm version in composer to 3.4.x-dev#bffe56746660f62898455875ada1da86ecf16665 as 3.4.0, it's a commit from my PR https://github.com/doctrine/orm/pull/11814 that I'm already using on some projects and it's working fine with property hooks, last rebase with 3.4.x was 2025-03-25, and I think 3.4 will be released soon anyway (and I hope also with that PR).

If it's not working, try latest 3.4.x dev branch if what you are working on allows it, doctrine is pretty stable and well tested even in unreleased versions.

rixafy avatar May 05 '25 07:05 rixafy

Has anyone noticed interesting behavior with the proxy generated __sleep functions when using public property hooks for non-doctrine fields on a entity. In particular it looks like "virtual property hooks" are not fully compatible with serialize / unserialize as it has no backing and cannot be saved as so.

cjavad avatar Jun 12 '25 21:06 cjavad

I've upgraded to 3.4 stable, but Doctrine is complaining about a hook that isn't even a mapped property. Why?

"Doctrine ORM does not support property hook on App\Entity\Default\CreditMovement::direction without using native lazy objects. Check https://github.com/doctrine/orm/issues/11624 for details of versions that support property hooks.

public PaymentFlow $direction {
    get => $this->amount < 0 ? PaymentFlow::Outgoing : PaymentFlow::Incoming;
}

gremo avatar Jun 18 '25 22:06 gremo

I've upgraded to 3.4 stable, but Doctrine is complaining about a hook that isn't even a mapped property. Why?

"Doctrine ORM does not support property hook on App\Entity\Default\CreditMovement::direction without using native lazy objects. Check https://github.com/doctrine/orm/issues/11624 for details of versions that support property hooks.

public PaymentFlow $direction {
    get => $this->amount < 0 ? PaymentFlow::Outgoing : PaymentFlow::Incoming;
}

Have you enabled native lazy objects? It will not even work for unmapped properties with the old code, that is correct

beberlei avatar Jun 19 '25 19:06 beberlei

@beberlei I may have confused enable_lazy_ghost_objects with enable_native_lazy_objects option. Going to test now, thanks!

EDIT: thank you, my bad ❤

gremo avatar Jun 19 '25 19:06 gremo