Skip to content
New issue

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

1.x bc layer #512

Merged
merged 10 commits into from
Nov 7, 2023
Merged

1.x bc layer #512

merged 10 commits into from
Nov 7, 2023

Conversation

nikophil
Copy link
Member

@nikophil nikophil commented Nov 1, 2023

  • Bundle configuration
  • Object Instantiator split into Instantiator/Mapper
  • Zenstruck\Foundry\Factory
    • withAttributes() -> with()
    • __construct() removed
  • Zenstruck\Foundry\ModelFactory -> Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory
    • protected function getDefaults(): array -> protected function defaults(): array|callable
    • protected static function getClass(): string -> public static function class(): string
    • protected function initialize() -> protected function initialize(): static
    • addState() -> with()
  • Zenstruck\Foundry\Proxy -> Zenstruck\Foundry\Persistence\Proxy
    • no longer implements \Stringable
    • isPersisted() removed
    • object() -> _real()
    • save() -> _save()
    • remove() -> _delete()
    • refresh() -> _refresh()
    • forceSet() -> _set()
    • forceSetAll() removed
    • forceGet() -> _get()
    • repository() -> _repository()
    • enableAutoRefresh() -> _enableAutoRefresh()
    • disableAutoRefresh() -> _disableAutoRefresh()
    • withoutAutoRefresh() -> _withoutAutoRefresh()
    • assertPersisted() removed
    • assertNotPersisted() removed
    • final objects cannot be proxified
  • Zenstruck\Foundry\anonymous() -> Zenstruck\Foundry\factory() (factory() is currently deprecated in 1.x...)
  • Zenstruck\Foundry\create() -> Zenstruck\Foundry\Persistence\persist()
  • Zenstruck\Foundry\create_many() removed
  • Zenstruck\Foundry\instantiate() -> Zenstruck\Foundry\object()
  • Zenstruck\Foundry\instantiate_many() removed
  • Zenstruck\Foundry\repository() -> Zenstruck\Foundry\Persistence\repository()
  • Zenstruck\Foundry\Test\TestState -> Zenstruck\Foundry\Test\UnitTestConfig (better name?)
  • Zenstruck\Foundry\Factory::delayFlush() -> Zenstruck\Foundry\Persistence\flush_after()
  • Zenstruck\Foundry\Test\Factories
    • disablePersist() -> Zenstruck\Foundry\Persistence\disable_persisting()
    • enablePersist() -> Zenstruck\Foundry\Persistence\enable_persisting()
  • Zenstruck\Foundry\Instantiator to Zenstruck\Foundry\Object\Instantiator
    • new Instantiator() => Instantiator::withConstructor()
    • alwaysForceProperties() => alwaysForce() + parameters are spread
    • allowExtraAttributes() => allowExtra() + parameters are spread
    • Instantiator::withConstructor() will throw an exception if class's constructor is not public
  • Zenstruck\Foundry\RepositoryProxy to Zenstruck\Foundry\Persistence\RepositoryDecorator
  • Zenstruck\Foundry\RepositoryAssertions to Zenstruck\Foundry\Persistence\RepositoryAssertions

@nikophil nikophil force-pushed the 1.x-bc-layer branch 6 times, most recently from 31fe65b to 307b3de Compare November 4, 2023 17:15
Comment on lines +81 to +82
public function __toString(): string
{
$object = $this->_real();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first, I emitted a deprecation here, saying

Class "Proxy" will not extend \Stringable anymore in 2.0. You should not use Proxy::__toString() nor cast a proxy to string.'

But it can cause some troubles because doctrine sometimes casts the entity to a string when it throws exceptions

I think we should not emit a deprecation here, because whereas we have old or new proxy system, the cast ends up calling real object's __toString()

@nikophil nikophil force-pushed the 1.x-bc-layer branch 6 times, most recently from 1f042a6 to 9197b81 Compare November 6, 2023 17:52
@nikophil nikophil changed the base branch from 1.x to 1.x-bc November 7, 2023 17:52
@nikophil nikophil marked this pull request as ready for review November 7, 2023 17:52
@nikophil nikophil requested a review from kbond November 7, 2023 17:53
@kbond kbond merged commit 6c298be into zenstruck:1.x-bc Nov 7, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants