Skip to content

Conversation

@dereuromark
Copy link
Member

  1. ORM/Association.php - Replaced $this->{'_' . $property} = $value with explicit property assignments
  2. ORM/EagerLoadable.php - Replaced dynamic property assignment with explicit assignments
  3. ORM/Table.php - Replaced $this->{'set' . $cfg}($config[$cfg]) with explicit setter method calls

Is this something we want to see?

@dereuromark dereuromark added this to the 6.0 milestone Aug 30, 2025
@LordSimal
Copy link
Contributor

The only other thing I can think of to clean this up, is to create a separate class like so

class AssociationOptions
{
    public function __construct(
        private ?bool   $_cascadeCallbacks = null,
        private ?string $_className = null,
        private ?array  $_conditions = null,
        private ?bool   $_dependent = null,
        private ?string $_finder = null,
        private ?string $_bindingKey = null,
        private ?string $_foreignKey = null,
        private ?string $_joinType = null,
        private ?object $_tableLocator = null,
        private ?object $_targetTable = null,
    ) {}
}

but this needs to be done for each adjusted class since the options are different - so not sure if this is actually cleaner.

But in general I am definitely in favour of removing these kind of dynamic property assignments since its easier to find stuff.

@ADmad
Copy link
Member

ADmad commented Aug 30, 2025

The only other thing I can think of to clean this up, is to create a separate class like so

Or we can kill this options argument and make people use the dedicated methods already available for them 😁

@LordSimal
Copy link
Contributor

Or we can kill this options argument and make people use the dedicated methods already available for them 😁

Oh yes, that would great. But it would require some rector/upgrade tool automation to make that upgrade it easier.

@markstory
Copy link
Member

Oh yes, that would great. But it would require some rector/upgrade tool automation to make that upgrade it easier.

We could introduce the new call style in 5.x via changes in bake, docs, and with rector rules. Deprecations could be emit when an options array is used as well.

Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

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

This seems like something we could safely do in 5.x, or am I missing something?

@ADmad
Copy link
Member

ADmad commented Sep 1, 2025

This seems like something we could safely do in 5.x, or am I missing something?

Yes, it could be done in a new minor with deprecations and updating of baked code.

@othercorey
Copy link
Member

This looks ok as-is for cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants