Skip to content

Conversation

@jparise
Copy link
Member

@jparise jparise commented Jul 27, 2025

Most of the composite methods return a boolean result indicating whether or not all of the child handlers successfully performed the operation. If any of the children fails, the composite result is false.

We were previously using a mix of coding styles:

  1. $success = $success && func()
  2. $success &= func()
  3. if (!func()) { $success = false; }

(1) works fine but results in more (re)writes to $success than are needed.

(2) is logically equivalent but promotes the value to an integer, which results in the composite function returning an integer instead of a boolean. (#40)

(3) is nice because it leaves the $success flag alone until there's a reason to change it to a failure.

This change updates all of the code to consistently use (3).

Fixed #40

Most of the composite methods return a boolean result indicating whether
or not all of the child handlers successfully performed the operation.
If any of the children fails, the composite result is false.

We were previously using a mix of coding styles:

1. $success = $success && func()
2. $success &= func()
3. if (!func()) { $success = false; }

(1) works fine but results in more (re)writes to $success than are
needed.

(2) is logically equivalent but promotes the value to an integer, which
results in the composite function returning an integer instead of a
boolean. (#40)

(3) is nice because it leaves the $success flag alone until there's a
reason to change it to a failure.

This change updates all of the code to consistently use (3).
@jparise jparise merged commit 7ce5f3f into master Jul 27, 2025
6 checks passed
@jparise jparise deleted the composite-bools branch July 27, 2025 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An exception occurs when the Log function is used in composite.php

2 participants