Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes related to stichoza/google-translate-php package #77

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Stichoza
Copy link

Changes proposed

  • Bump version from ^5.0.1 to ^5.2.0.
    No backwards incompatible changes except ext-dom was added to requirements, which is bundled with PHP.
  • Remove redundant check of $base_locale.
    The setSource() method already supports passing null as a parameter. So we can just use setSource($base_locale) even if the value is null (otherwise it will be string as defined in parameter type).
  • Wider exception class
    The translate() might throw multiple different exceptions, most of them extend ErrorException, but some of them are extending UnexpectedValueException. Using Exception in catch block to cover all possible situations.
  • Null coalescing operator
    The translate() method of my package might return null. Returning null will cause uncaught TypeError. Added null coalescing operator to handle this situation.

Other

  • Returning false from method with return type string
    One thing that I didn't change is the return false in the catch block. Method has string as return type (as defined in ApiTranslatorContract). Returning false 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.

@Stichoza Stichoza changed the title Patch 1 Changes related to stichoza/google-translate-php package Aug 14, 2024
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.

1 participant