-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
docs: use modern named arguments syntax #10933
Conversation
Good idea. I can find more occurrences of this:
Can you please fix those as well? |
Of course, I'll look into it later |
@greg0ire done searched through the rest of documentation, no further instances however: there is this one, looks a bit like definition of default value: orm/docs/en/reference/dql-doctrine-query-language.rst Lines 1460 to 1461 in eafc0c6
but method definition does not specify the default value: orm/lib/Doctrine/ORM/Query.php Line 544 in d81afdb
how would you like to proceed? |
Yeah but would you then change the |
Please squash your commits together, you shouldn't do one commit per file. |
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.
I'm not sure about this change in the docs. Introducing this would need us to check the docs everytime when we change an internal variable name of an argument when it's a method with just one argument.
The variable $seconds
was just there for context. Should the seconds value be used directly?
@@ -1392,7 +1392,7 @@ Result Cache API: | |||
$result = $query->getResult(); // saved in given result cache id. | |||
|
|||
// or call useResultCache() with all parameters: | |||
$query->useResultCache(true, $seconds = 3600, 'my_query_result'); | |||
$query->useResultCache(true, seconds: 3600, 'my_query_result'); |
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.
This would be lifetime too.
$query->useResultCache(true, seconds: 3600, 'my_query_result'); | |
$query->useResultCache(true, lifetime: 3600, 'my_query_result'); |
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.
This method is deprecated since 2.7
should the documentation still promote its use?
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.
I've asked as I'd like to remove this reference, or should we fix it now and remove it in the future?
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, we should document the non-deprecated method here.
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.
I've asked because method userResultCache
is deprecated, and this section is written in a language that kind of 'promotes' it's use. I'd suggest to replace these lines with suggested replacement enableResultCache
, but that's for another PR
orm/lib/Doctrine/ORM/AbstractQuery.php
Lines 709 to 726 in 9f555ea
/** | |
* Set whether or not to cache the results of this query and if so, for | |
* how long and which ID to use for the cache entry. | |
* | |
* @deprecated 2.7 Use {@see enableResultCache} and {@see disableResultCache} instead. | |
* | |
* @param bool $useCache Whether or not to cache the results of this query. | |
* @param int $lifetime How long the cache entry is valid, in seconds. | |
* @param string $resultCacheId ID to use for the cache entry. | |
* | |
* @return $this | |
*/ | |
public function useResultCache($useCache, $lifetime = null, $resultCacheId = null) | |
{ | |
return $useCache | |
? $this->enableResultCache($lifetime, $resultCacheId) | |
: $this->disableResultCache(); | |
} |
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, please send a PR. 🙂
How often are we going to do that? Because of named arguments, this is arguably a breaking change now. |
use official named arguments syntax in example instead of pre php 8 codestyle for 'named' arguments
I suppose not that often, but it's still a bad practice to use this when we only have one argument or when all arguments are already covered. Question is if we keep named arguments for context or just use a variable again. |
Why is it a bad practice to use named arguments when there is only one argument? I mean in some situations, it might make things clearer. It's not always obvious what an argument is. For instance, if you pass 60, it can be handy to know we are talking seconds and not minutes. |
That's why I ask if this should be kept for context. My change request still included the named arguments. |
Thanks @kaznovac ! |
use official named arguments syntax in example instead of pre php 8 codestyle for 'named' arguments