City-of-Bloomington / master_address

Web application for handling city addressing
https://bloomington.in.gov/master_address
GNU Affero General Public License v3.0
0 stars 1 forks source link

Address::update warning count called on something not countable #133

Closed inghamn closed 4 years ago

inghamn commented 4 years ago

Older PHP versions would let you get away with this. Now, you can only call count() on something that's countable. In the case of the Adress UpdateController, we're checking for errors. We should just check for the presence of errors, rather than trying to count them (which could be null).

inghamn commented 4 years ago
if (!count($response->errors)) {
    header('Location: ')...;
}

This particular call is used throughout the controllers. The strict type checking on the responses are catching that the errors are null (and cannot be counted).

We should clean up the response definitions to make clear that the errors may be null. We should update the check for errors in the controllers to a plain truthy check.

if (!$response->errors) {
    header('Location: ')...;
}