ramsey / uuid

:snowflake: A PHP library for generating universally unique identifiers (UUIDs).

Home Page:https://uuid.ramsey.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ramsey\Uuid\Nonstandard namespace conflicts with itself in standalone builds

tucson-tom opened this issue · comments

This library is used by Google Cloud APIs (BigQuery in particular). When this library is imported as part of a standalone build, the Nonstandard namespace conflicts with itself.

Description

Ramsey\Uuid\Nonstandard creates a Uuid class that conflicts with Ramsey\Uuid\Uuid when use Ramsey\Uuid\Uuid is encountered later in the same namespace by PHP because "Uuid" is already defined as a class. PHP has no idea which class to use and so it throws up a Fatal error.

Steps to reproduce

  1. Run PHP Decomposer to generate a standalone build of Google Cloud BigQuery.
  2. Get this lovely and very confusing error message when linting the output: PHP Fatal error: Cannot use Ramsey\Uuid\Uuid as Uuid because the name is already in use in C:\php-decomposer\projects\google-cloud-apis\final\google-cloud-apis_decomposed.php on line 47783.

Expected behavior

Non-conflicting namespace and class names.

Suggested fix

In vendor\ramsey\uuid\src\Nonstandard\UuidV6.php, change:

use Ramsey\Uuid\Uuid;

class UuidV6 extends Uuid implements UuidInterface

To:

use Ramsey\Uuid\Uuid as BaseUuid;

class UuidV6 extends BaseUuid implements UuidInterface

Hello,
I made a PR to fix your problem by applying your changes, see #495.
\cc @ramsey

The fix for this is released in version 4.7.4. Thank you for your patience.

Thank you, @Ph0tonic, for the patch! 🎉