Changes related to stichoza/google-translate-php
package
#77
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes proposed
^5.0.1
to^5.2.0
.No backwards incompatible changes except
ext-dom
was added to requirements, which is bundled with PHP.$base_locale
.The
setSource()
method already supports passing null as a parameter. So we can just usesetSource($base_locale)
even if the value isnull
(otherwise it will be string as defined in parameter type).The
translate()
might throw multiple different exceptions, most of them extendErrorException
, but some of them are extendingUnexpectedValueException
. UsingException
in catch block to cover all possible situations.The
translate()
method of my package might returnnull
. Returningnull
will cause uncaughtTypeError
. Added null coalescing operator to handle this situation.Other
false
from method with return typestring
One thing that I didn't change is the
return false
in the catch block. Method hasstring
as return type (as defined inApiTranslatorContract
). Returningfalse
will not cause any errors like in case of null, but it will be converted to an empty string. I'm not sure if it's intended that way so I didn't touch it.