zendframework / ZendService_Google_Gcm

Implementation for ZF2 of a GCM 3rd party server (http://developer.android.com/guide/google/gcm/)
BSD 3-Clause "New" or "Revised" License
29 stars 49 forks source link

Changed in_array to array_key_exists #5

Closed phindmarsh closed 10 years ago

phindmarsh commented 10 years ago

String interpolation only works with double quoted strings and the exception messages have variables included, but are single quoted. This caused exception messages like $key must be a non-empty string.

in_array in the addData method should be array_key_exists, since the purpose of the method is to ensure existing $this->data keys are not overwritten. in_array checks if a value is present in an array, not a key.

Also, using in_array without strict checking can cause some unpredictable results (see docs). In this case, I think it is better to use the strict flag in the addRegistrationId method.

Maks3w commented 10 years ago

Hi

First: If you try to fix different things do it in different PRs. Second: String quotes was ok. The intent is tell you the param you must fix and not the value. Third: For the rest of fixes please add unit testing.

Thanks

phindmarsh commented 10 years ago

Ok, I've removed the other changes.

Now it's just a change from in_array to array_key_exists plus the associated tests (testDuplicateDataKeyThrowsException).