-
Notifications
You must be signed in to change notification settings - Fork 2k
refactor: Update types for BaseModel
, Model
and dependencies
#9711
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
base: 4.7
Are you sure you want to change the base?
Conversation
42136ab
to
11a3252
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Some methods have a
$testing
parameter, which set totrue
, will not execute the query and just return the SQL. -
No array - as we do not support composite keys in the model right now. Support for
0
and'0'
is problematic, and I would rather not allow it, as it will cause problems when combined with$db->insertID()
, which uses0
to indicate a failure.
* Used by asArray() and asObject() to provide | ||
* The temporary format of the result. | ||
* | ||
* Used by `$this->asArray()` and `$this->asObject()` to provide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you adding $this
everywhere? It makes the comments longer and doesn't add value (at least from my perspective). Do backticks actually change the syntax in phpDocumentor? If yes, please use them consistently everywhere - if not, please remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, phpDocumentor supports Markdown. Therefore, we can mark some code as bold... I added a clarification to explicitly indicate a method rather than a function. This may seem redundant, but it's not a problem to reduce it. We're considering a PR together to address this.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The message can stay, for reference.
* | ||
* @throws InvalidArgumentException | ||
*/ | ||
protected function hasRationalPrimaryKey($id): bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The primary key in our model refers more to the column name, so this may be misleading.
I have no idea how we can name it... isUsableValueId()
? 🤷♂️
The goal for these checks is purely to satisfy PHPStan or validate the allowed data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially, I remove phpstan errors. The next step was formed by itself - we can validate the ID value.
I would set the relationship to PK. For now, all checks are used for it. But it can be renamed to hasRationalId()
if it is used for table joins, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "rational" part of the method doesn't really speak to me, to be honest.
Well... let's forget about validating the primary key for now - I'm not convinced we need to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the check or what, back to if ($id)?
rational - based on logic. If there is a problem with the translation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using if ($id)
would likely bring us back to square one, with PHPStan raising an error.
Yes, I know what “rational” means, but I don't think it's a good fit here.
I'm leaning towards leaving the code as it is (without introducing an additional method), but unifying the values in in_array
. Happy to hear others' opinions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samsonasik @paulbalandan i need help.
👋 Hi, @neznaika0! |
Description
Updated PHPDoc, clarified arrays, duplicate comments have been removed from the Model and did some work with dots.
I generated the API using phpDocumentor. I didn't notice any serious problems.
Some questions:
$id
forBaseModel::doFind()
doFindColumn() findColumn()
- not sure about the type accuracyBaseModel::getIdValue()
does not return an array. Right? I have removed PHPDoc and array checking. Is it possible to use 0, '0' for ID? Otherwise, I would have added the checks toBaseModel::shouldUpdate()
.Checklist: