wp-oop/transient-cache

Exceptions Not PSR-Compliant

szepeviktor opened this issue · 6 comments

Hello @XedinUnknown!

What a release!

 ------ -------------------------------------------------------------------------------------------------------------
  Line   CachePool.php
 ------ -------------------------------------------------------------------------------------------------------------
  112    Method WpOop\TransientCache\CachePool::set() should return bool but return statement is missing.
  126    Method WpOop\TransientCache\CachePool::delete() should return bool but return statement is missing.
  136    Method WpOop\TransientCache\CachePool::clear() should return bool but return statement is missing.
  175    Method WpOop\TransientCache\CachePool::setMultiple() should return bool but return statement is missing.
  189    Method WpOop\TransientCache\CachePool::deleteMultiple() should return bool but return statement is missing.
  304    Parameter #2 $x of method wpdb::get_col() expects int, string given.
 ------ -------------------------------------------------------------------------------------------------------------

Could you return a bool?

Discovered by @phpstan

Surprizingly legit. This is quite screwed up though IMHO on the side of the PSR. A method should do what it is supposed to do, or throw. Returning false to indicate failure does not give consumers much to go on.

But this is a legit violation of the standard. I'll look into it. What would you say if there is a PSR-compliant wrapper around the existing implementation, which returns the right stuff? This could help preserve the verbosity of the errors, instead of limiting the result to just "success" or "failure".

What would you say if there is a PSR-compliant wrapper around the existing implementation, which returns the right stuff?

I think guys behind PSR-16 well discussed it.

You could find it somewhere, maybe here https://github.com/php-fig/fig-standards

I know where to find FIG stuff, being a member of a workgroup. Perhaps they discussed it well, but everybody makes mistakes, and that's why there are newer versions of things coming out all the time. FIG doesn't upgrade their standards, but it releases new ones that supersede old ones.

Okay.
Let's follow PSR-16 until "PSR-26" comes out :)

@szepeviktor, please take a look at the PR.

Thank you.