Skip to content

Add namespace to Gemini class to prevent naming collision#153

Closed
aydinfatih with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-gemini-class-namespace
Closed

Add namespace to Gemini class to prevent naming collision#153
aydinfatih with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-gemini-class-namespace

Conversation

Copilot AI commented Nov 22, 2025

Copy link
Copy Markdown

The Gemini class in src/Gemini.php was declared in the global namespace, causing fatal errors in applications that use Gemini as a namespace for other classes.

Changes

  • src/Gemini.php: Added namespace Gemini; declaration
  • composer.json: Removed file autoloading (now uses PSR-4)
  • Test files: Updated imports to use Gemini\Gemini;
  • README.md: Updated all code examples

Breaking Change

Users must update their imports:

// Before
use Gemini;
$client = Gemini::client($apiKey);

// After
use Gemini\Gemini;
$client = Gemini::client($apiKey);

This change aligns the library with PSR-4 conventions and requires a major version bump.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Jean85/pretty-package-versions/zipball/4d7aa5dab42e2a76d99559706022885de0e18e1a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/filp/whoops/zipball/d2102955e48b9fd9ab24280a7ad12ed552752c4d
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/IfnlDz /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/guzzle/guzzle/zipball/b51ac707cfa420b7bfd4e4d5e510ba8008e822b4
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/guzzle/promises/zipball/481557b130ef3790cf82b713667b43030dc9c957
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/guzzle/psr7/zipball/21dc724a0583619cd1652f673303492272778051
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/laravel/pint/zipball/5016e263f95d97670d71b9a987bd8996ade6d8d9
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/nunomaduro/collision/zipball/f5c101b929c958e849a633283adff296ed5f38f5
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/nunomaduro/termwind/zipball/6fb2a640ff502caace8e05fd7be3b503a7e1c017
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/paratestphp/paratest/zipball/cf16fcbb9b8107a7df6b97e497fc91e819774d8b
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/d23b2d7498475354522c3818c42ef355dca3fcda
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/pestphp/pest-plugin/zipball/e05d2859e08c2567ee38ce8b005d044e72648c0b
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/pestphp/pest/zipball/f8c88bd14dc1772bfaf02169afb601ecdf2724cd
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/IfnlDz /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/IfnlDz /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-http/discovery/zipball/82fe4c73ef3363caed49ff8dd1539ba06044910d
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/IfnlDz /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phpstan/phpdoc-parser/zipball/1e0cd5370df5dd2e556a36b9c62f62e555870495
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phpstan/phpstan/zipball/e126cad1e30a99b137b8ed75a85a676450ebb227
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7e308268858ed6baedc8704a304727d20bc07c77
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/phpunit/zipball/aa0a8ce701ea7ee314b0dfaa8970dc94f3f8c870
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/console/zipball/c28ad91448f86c5f6d9d2c70f0cf68bf135f252a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/IfnlDz /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/finder/zipball/9f696d2f1e340484b4683f7853b273abff94421f
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/process/zipball/f24f8f316367b30810810d4eb30c543d7003ff3b
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/service-contracts/zipball/45112560a3ba2d715666a509a0bc9521d10b6c43
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/string/zipball/f96476035142921000338bad71e5247fbc138872
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/cf6fb197b676ba716837c886baca842e4db29005
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/theofidry/cpu-core-counter/zipball/db9508f7b1474469d9d3c53b86f817e344732678
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/IfnlDz /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/webmozarts/assert/zipball/9be6926d8b485f55b9229203f962b51ed377ba68
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/qGMHGr /usr/bin/composer install --no-interaction (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Potential Naming Collision:Geminiclass in global namespace can cause conflicts</issue_title>
<issue_description>I'm not used to English so I apologize if there are any inappropriate expressions.

There appears to be a potential naming conflict with the Gemini class defined in src/Gemini.php. This file is currently missing a namespace declaration.
As a result, the Gemini class is declared in the global namespace. This can lead to conflicts in applications where Gemini might be used as a namespace for other classes, potentially causing a fatal error: Cannot declare class Gemini, because the name is already in use.
While this might not be a bug in all environments, it deviates from the common PSR-4 namespacing convention and can make the library difficult to integrate into larger projects.
To illustrate the potential problem
Install the library via Composer.
In a project, create a file that uses the Gemini namespace for another purpose before vendor/autoload.php is fully processed for all classes.
An attempt to then use \Gemini\Gemini::client() can trigger a fatal error because the name Gemini is already claimed as a namespace.
Suggested Solution
The issue can be easily resolved by adding namespace Gemini; to the top of the src/Gemini.php file. This would align it with the other classes in the library, such as Gemini\Client and Gemini\Factory.
src/Gemini.php (current):
code
PHP
<?php
declare(strict_types=1);

use Gemini\Client;
use Gemini\Factory;

final class Gemini
{
// ...
}
src/Gemini.php (suggested change):
code
PHP
<?php
declare(strict_types=1);

namespace Gemini; // <-- Add this line

use Gemini\Client;
use Gemini\Factory;

final class Gemini
{
// ...
}
This change would make the library more robust and prevent potential integration issues in the future.
Thank you for your consideration and for maintaining this great library</issue_description>

Comments on the Issue (you are @copilot in this section)

@Plytas I agree that we should add a namespace, but that will require a major version as it is a breaking change.

I'm wondering, what other Gemini class you have that causes this issue?</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: aydinfatih <14280894+aydinfatih@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix potential naming collision for Gemini class Add namespace to Gemini class to prevent naming collision Nov 22, 2025
Copilot AI requested a review from aydinfatih November 22, 2025 15:33
@aydinfatih aydinfatih closed this Nov 22, 2025
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.

Potential Naming Collision:Geminiclass in global namespace can cause conflicts

2 participants