Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Consider removing final from client classes

Open
#8,588 12 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Quiet
Tech stack
php
Domain
api

Research direction

Start by reading the discussion in this issue and the referenced google-cloud-php pull request 8492 and gapic-generator-php pull request 774. Compare the proposed PHPDoc @final and interface approaches, then confirm the maintainers' decision and the client-library scope before defining what completion means.

Written by the indexing model from the issue text.

Description

cc @bshaffer, as asked I move the discussion to an issue.

As already discusses in

The current fact that client like TranslationServiceClient are final have the current drawback of

  • not being able to be extended
  • therefor not being able to be mocked for tests

While I do understand that google does not want such service to be extended (and I don't see a real need personally), on the contrary it's annoying to me to not being able to mock such external-client service in tests.
The current proposed solution is to use https://github.com/dg/bypass-finals in order to remove the final keyword at runtime.

I encounter the following (at least two) issue with this bypass library:

The two possible solutions I have in mind would be:

  • Removing final hard keyword and use the soft one with phpdoc @final.
  • Or introducing an interface for each existing client, listing every public method of the client.

While the second one seems to be the right one, I understand google might not want to introduce 100 new interfaces with tons of methods and prefer the first one as a quickwin.

Quoting:

I don't want to be stubborn on this, however. If there's more support from our developers that bypass-finals is not sufficient, and using final is too much of a pain, I'm happy to remove it from the client libraries!

So if you encounter any issue with those final classes, please share a word !

Dominant language
PHP
Stars
1.2k
Forks
464
Avg merge
2d 2h
Merged PRs (30d)
103

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from googleapis/google-cloud-php

All issues in googleapis/google-cloud-php

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.