Skip to content
This repository has been archived by the owner on Mar 28, 2021. It is now read-only.

Fatal error: Cannot use League\Uri\Interfaces\Uri as Uri because the name is already in use #3

Closed
SDKiller opened this issue Nov 22, 2017 · 14 comments

Comments

@SDKiller
Copy link

Issue summary

Not sure where to post this issue here or to the uri-schemes.

Fatal error on the very project startup - I guess when autoloading happens:

Fatal error: Cannot use League\Uri\Interfaces\Uri as Uri because the name is already in use in ...\ven
dor\league\uri-manipulations\src\functions.php on line 17

System informations

(In case of a bug report Please complete the table below)

Information Description
League\Uri\Schemes version
PHP/HHVM version 7.0
OS Platform Windows 7

Standalone code, or other way to reproduce the problem

After I updated the whole package "league/uri" via composer.

Currently installed:

  - Installing league/uri-interfaces (1.0.0)
  - Installing league/uri-hostname-parser (1.0.1)
  - Installing league/uri-components (1.4.0)
  - Installing league/uri-manipulations (1.2.0)
  - Installing league/uri-parser (1.2.0)
  - Installing league/uri-schemes (1.1.0)
  - Installing league/uri (dev-master 8cd50f9)

I believe this error comes from:

https://github.com/thephpleague/uri-schemes/blob/master/src/Schemes/deprecated.php#L57

class_alias(LeagueUri\Uri::class, Uri::class);
if (!class_exists(Uri::class)) {
    /**
     * @deprecated use instead {@link LeagueUri\Ws}
     */
    class Uri
    {
    }
}

At least, after I commented these strings fatal error on autoload has gone.

@SDKiller
Copy link
Author

SDKiller commented Nov 22, 2017

To reproduce:

  1. create separate project with composer
  2. add only league/uri to require section
  3. create simple index.php:
<?php

require 'vendor/autoload.php';

echo 'Done';

exit();
  1. run it:
> php index.php

Fatal error: Cannot use League\Uri\Interfaces\Uri as Uri because the name is already in use in ...\vendor\league\uri-manipulations\src\functions.php on line 17

@nyamsprod
Copy link
Member

@SDKiller thanks for the report I'll patch this ASAP. But I believe the report is done in the wrong package. This is a uri-scheme issue :)

@nyamsprod
Copy link
Member

@SDKiller I've follow you reproducing steps but I failed to get this error :'( I've used

composer require league/uri:dev-master

@SDKiller
Copy link
Author

SDKiller commented Nov 23, 2017

Yes, it's rather strange.

I just reproduced it again on Windows 7 with php 7.0.4

But I failed to reproduce it on Ubuntu 17.04 with php 7.1.7

@nyamsprod
Copy link
Member

I have Ubuntu 16.04 with PHP 7.0.22 and no issue so it is either an issue with this version of PHP or with the Windows version of PHP or else :'(

@nyamsprod
Copy link
Member

maybe it is related to this PHP bug which was fixed in PHP 7.0.13 ... https://bugs.php.net/bug.php?id=66773

@nyamsprod
Copy link
Member

If so I can only update PHP minimal requirements

@SDKiller
Copy link
Author

maybe it is related to this PHP bug which was fixed in PHP 7.0.13

I'll try to upgrade my windows php installation to check this and let you know.

@nyamsprod
Copy link
Member

FWIW ... I've install Ubuntu on Windows 10 with PHP7.0.22 and no errro their too. So I believe it is a PHP bug I'll update the PHP requirements then on the 5.2 release

@SDKiller
Copy link
Author

maybe it is related to this PHP bug which was fixed in PHP 7.0.13

Could not test on 7.0.13

Windows 7, php 7.0.21 - issue is not reproducible.

@nyamsprod
Copy link
Member

so I'll just update the PHP requirements then for league/uri and league/uri-schemes

@stepofweb
Copy link

I get the same error.

Fatal error: Cannot use League\Uri\Interfaces\Uri as Uri because the name is already in use in .../vendor/league/uri-manipulations/src/functions.php on line 17

The error is gone If I edit league/uri-schemes/src/Schemes/deprecated.php and remove line 57 - 65 (like SDKiller already said).

PHP Version: 7.0.27 on osX

@nyamsprod
Copy link
Member

@stepofweb and @SDKiller I'll update the package to fix this issue hopefully this week or next week. Thanks for the report.

@nyamsprod nyamsprod reopened this Mar 13, 2018
nyamsprod added a commit that referenced this issue Mar 14, 2018
- resolve issue #3
- adding PHPStan
- update league\uri-components requirement
- update package settings (travis,scrutinizr)
nyamsprod added a commit that referenced this issue Mar 14, 2018
- resolve issue #3
- adding PHPStan
- update league\uri-components requirement
- update package settings (travis,scrutinizr)
@nyamsprod
Copy link
Member

the bug is patched on master and will be release in version 1.5.0

nyamsprod added a commit that referenced this issue Mar 14, 2018
- resolve issue #3
- adding PHPStan
- update league\uri-components requirement
- update package settings (travis,scrutinizr)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants