Hi,

I've been having problems with how return values and success bools are 
getting mixed throughout the code, first here are some examples:

1. The default bootstrap.php suggests, that Configure::config() and 
Configure::load() have no return values, but throw exceptions.
The truth is, load() returns a bool, config() returns void, and both don't 
throw any exceptions.

2. Functions like Configure::write() or Configure::clear() have a bool 
return value, thus suggesting me that I have to check it and apply error 
handling.
However, they can't possibly ever fail and should both return void.

3. As already mentioned in https://github.com/cakephp/cakephp/issues/3284, 
using one variable for both return value and success checking leads to 
trouble.
Another example 
here: 
https://github.com/cakephp/cakephp/blob/3.0/src/Cache/Engine/ApcEngine.php#L85
The phpdoc says "false if the data doesn't exist" which is wrong. Correct 
would be using a referenced $success variable, 
see http://www.php.net/manual/de/function.apc-fetch.php.
The success value would have to propagate down through the base classes in 
the same way: mixed Cache::read($key, &$success)

4. Another possibilty would be using exceptions, but this is a choice of 
design.

To sum it up: Nice would be having some consistency, so it's always clear 
by looking at the function declaration what really happens. I was also 
surprised finding the handling of "display_errors" setting in 
Configure::write(), without being mentioned in phpdoc. This implied, that 
Configure::load() *had* to use Configure::write() in order to set 
display_errors in order to work 
(see 
https://github.com/pschiel/cakephp/commit/d7f5cc08de1c15cea1ec0ac762ed4cbe389e7248
 
)


What are your thoughts?

Regards,
Patrick

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to