On Thu, 2020-06-18 at 23:17 -0400, Jesse Rushlow wrote:
> * Disclaimer - I have not thoroughly reviewed the bug report or PR
> mentioned.
> 
> From a PHP developers perspective, if I was calling a method that
> returned true. I would automatically assume that the method is
> capable of returning the inverse of that as well.

The fact that it doesn't today, might change tomorrow. If it now
returns true this can be changed with less BC issues later. Also
returning true allows chaining with `&&`, which void wont't.

Also to the specific case: The specific case is about this:

  $test = new \SplStack();
  var_dump( $test->push(1));

Assume we add a SplLimitedStack with a ore-defined size. There push
might return false if the stack is full. By having "all" push() methods
following the same pattern, generic code can work on either the same
way. Thus looking at a single method isn't good for a design, but one
should look at a class of types. (and then it might be a decision that
push always returns void and errors should be reported via exception)

Just to point out that there is a bit more than "oh, this always
returns true"


Also another side note: We have echo and print. print purposely always
returns true for being usable in expression chains.

johannes

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to