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

TASK: Add type hints and minimal cleanup in configuration builder #2956

Draft
wants to merge 5 commits into
base: 9.0
Choose a base branch
from

Conversation

kitsunet
Copy link
Member

This is a minimal cleanup to the object management classes. Adding type hints, using more modern language constructs, and introducing constants for the cryptic array keys in the ObjectManager configuration.

Checklist

  • [ x] Code follows the PSR-2 coding style
  • [ x] Tests have been created, run and adjusted as needed
  • [x ] The PR is created against the lowest maintained branch
  • Reviewer - PR Title is brief but complete and starts with FEATURE|TASK|BUGFIX
  • Reviewer - The first section explains the change briefly for change-logs
  • Reviewer - Breaking Changes are marked wit !!! and have upgrade-instructions

@kitsunet
Copy link
Member Author

Mmm, how to deal with psalm here, it IS obviously correct that the calls could run into a null value, that hasn't changed though, I just clarified that with a type hint. Do I fake the type hint to be not null, seems like a bad idea as well... Neither do I want to null check the respective calls.

@kitsunet
Copy link
Member Author

Added some psalm change, the rest seems unrelated...

@kitsunet
Copy link
Member Author

I haven't really compared but I will just close this in lieu of @mhsdesign stan changes which proably cover a bunch of these.

@kitsunet kitsunet closed this Jan 25, 2024
@mhsdesign
Copy link
Member

Hu well nice nice, i didnt know about this one ;) Will put some love into it to rebase it onto 9.0 ;)

@mhsdesign mhsdesign reopened this Jan 25, 2024
@mhsdesign mhsdesign force-pushed the task/type-hinting-objectmanagement branch from 9fb734c to eabb3ff Compare January 25, 2024 12:53
@mhsdesign mhsdesign changed the base branch from 8.3 to 9.0 January 25, 2024 12:53
@github-actions github-actions bot added 9.0 and removed 8.3 labels Jan 25, 2024
@mhsdesign
Copy link
Member

Okay i had a little fun rebasing this ^^

Actually the most conflicts arose due to roberts proxy building refactoring 😅 like were your adjusted files have been removed: #3064 But in all those cases i accepted the 9.0 part.

It still looks like that there are lots of valuable cleanups in the object manager in here which i was able to preserve ;)

Copy link
Member

@mhsdesign mhsdesign left a comment

Choose a reason for hiding this comment

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

Left some mini questions, and also i have adjusted the imported global code like use TypeError to be consistent with our codebase.

@@ -166,7 +171,7 @@ public function buildObjectConfigurations(array $availableClassAndInterfaceNames
}

$objectConfigurations[$objectName] = $newObjectConfiguration;
if ($objectConfigurations[$objectName]->getPackageKey() === null) {
if ($objectConfigurations[$objectName]->getPackageKey() === '') {
Copy link
Member

Choose a reason for hiding this comment

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

the check was initially introduced via 14a3e92

you adjusted the getPackageKey to always return strings and an empty string instead of null. Im not sure if thats a good thing or not, as we may have more code in the codebase using the nullable pattern ... also null feels more anticipated than "".

Comment on lines -538 to -544
if (!is_array($classMethodNames)) {
if (!class_exists($className)) {
throw new UnknownClassException(sprintf('The class "%s" defined in the object configuration for object "%s", defined in package: %s, does not exist.', $className, $objectConfiguration->getObjectName(), $objectConfiguration->getPackageKey()), 1352371371);
} else {
throw new UnknownClassException(sprintf('Could not autowire properties of class "%s" because names of methods contained in that class could not be retrieved using get_class_methods().', $className), 1352386418);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

why has this been removed?

@mhsdesign mhsdesign force-pushed the task/type-hinting-objectmanagement branch from eabb3ff to ee873c8 Compare January 25, 2024 13:19
default:
throw new InvalidObjectConfigurationException('Invalid autowiring declaration', 1283866757);
}
return match ($value) {
Copy link
Member

Choose a reason for hiding this comment

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

you might have uncovered something that is better hidden: #3307

will revert this method so its a cleanup and not a bugfix :O

@mhsdesign
Copy link
Member

For some reason i cannot get flow to boot. The changes in the configuration building seem to have killed it.

I stopped now after an hour but i would still suggest to take the usefull parts #3308

Feel free to continue here or not :D

@mhsdesign mhsdesign marked this pull request as draft February 5, 2024 20:19
@mhsdesign mhsdesign changed the title TASK: Add type hints and minimal cleanup in object management TASK: Add type hints and minimal cleanup in configuration builder Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants