/** * Returns the expiration time of a not-yet-expired cache item. * * If this cache item is a Cache Miss, this method MAY return the time at * which the item expired or the current time if that is not available. * * @return \DateTime|boolean * The timestamp at which this cache item will expire or false if it does not * expire. */ public function getExpiration(); This poses a problem, as it violates these return value guidelines: http://www.garfieldtech.com/blog/empty-return-values Specifically: "FALSE
is a boolean. It is a value, specifically the opposite of< span class="Apple-converted-space">TRUE
. It is not the absence of a value of some other type. If a function can returnFALSE
, then the only other thing it should be able to return isTRUE
(orNULL
, in weird cases). If you can return a non-boolean, then you must never return a boolean." And: "In short: Write good contracts. Obey your contracts. You get one, and only one, return type. Don't make me do extra work because yo u wrote a dumb contract." However, returning false there is a dumb contract, because it means you always need to type check the return value, which is stupid. (I haven't checked git blame, but I probably wrote the line in question. So, yeah... :-) ) Here's the problem space: - If getExpiration() is called on a cache hit, and the item has a known expiration time, that is the value that should be returned and never anything else. - If getExpiration() is called on a cache miss, an implementing library MAY still know when the item expired, or it may not. If it does, return that. If not, return now(). That way, a check for if ($item is expired or is soon to expire) will still work as expected, and (say) a pre-regeneration script can still behave as expected. - If getExpiration() is called on a cache hit, and the item has no expiration time (ie, cache in the future)... then what? Returning false is wrong, because it's a type mismatch, but what do we do instead? I don't believe DateTime has an equivalent of PHP_MAX_INT, as it uses 64 bit time so its highest possible value is somewhere around when the Earth get engulfed by the sun. The best option we could come up with, which none of us are particularly fond of, is to establish something like "now() +5 years" as the canonical definition of "forever". It's technically not eternal, but far enough in the future that it may as well be. We've heard that Laravel uses a similar definition of forever currently. (Taylor, can you verify?) How do people feel about that? Is that an acceptable way to define "no expiration" (1 year from now, 5 years, something very large), or is there some better way that is still type-safe? I believe this is a Review-period-safe tweak, and if Beau disagrees he hasn't said so. :-) --Larry Garfield
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/55CE08CB.6040901%40garfieldtech.com.
For more options, visit https://groups.google.com/d/optout.
I think we should make getExpiration a DateTime|null that simply returns the value of the expiration, and make a new isExpired method that will manage the discrepancies.
I'd like to express concern with using the equivalent of DateTime(now()) to express an expired cache item. It occurs to me that many end users will do the equivalent of:
if ($expiration->getTimestamp() < $now) {
...
}
It was added to Stash when someone requested it for use inside of a session handling framework. That is literally the only time it has ever been requested in stash, and I added it in because it was trivial. Stash returns false for items without an expiration.
Keep in mind I barely care about this function’s existence, so if you’re looking for someone to justify it I am not that person. I am merely trying to finish up a conversation so we can continue with the review. From my understanding there are these options-
* Return null,
* Return false,
* Return a far future date,
* Remove getExpiration.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/c5680acd-cea1-44f7-9163-4129b6003d1f%40googlegroups.com.
It was added to Stash when someone requested it for use inside of a session handling framework. That is literally the only time it has ever been requested in stash, and I added it in because it was trivial. Stash returns false for items without an expiration.
Keep in mind I barely care about this function’s existence, so if you’re looking for someone to justify it I am not that person. I am merely trying to finish up a conversation so we can continue with the review. From my understanding there are these options-
* Return null,
* Return false,
* Return a far future date,
So better to remove it then ending up returning by design wrong values just because we want to cleanup return types.
If you all really want to rush this now,
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/983b5327-57be-4795-8d66-d74a2a8c481a%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/1c080a50-c3f0-4bbc-b7f9-2da324b56c4c%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/55D2CA2C.2000009%40beccati.com.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/67ffd103-7540-48e2-a444-ff1ced731ea3%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/67ffd103-7540-48e2-a444-ff1ced731ea3%40googlegroups.com.
Is this change large enough to warrant resetting the Review period?
So better to remove it then ending up returning by design wrong values just because we want to cleanup return types.I disagree with your assessment that we’d be returning the “wrong” value by design. If there is no expiration then null is a complete valid response.
If you all really want to rush this now,Seriously? If you think four years is rushing then I'd really hate to see what you'd consider a more relaxed approach.