Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

php - 无法使用X作为Y,因为该名称已经被使用,即使它没有被使用(Cannot use X as Y because the name is already in use, even though it's not)

I'm using PHP 5.4, and have a PSR-0 class structure similar to the following.

(我使用的是PHP 5.4,并且具有类似于以下内容的PSR-0类结构。)

A\Library\Session.php :

(A \ Library \ Session.php :)

namespace ALibrary;

class Session { ... }

My\Application\Session.php :

(My \ Application \ Session.php :)

namespace MyApplication;

class Session { ... }

My\Application\Facebook.php :

(My \ Application \ Facebook.php :)

namespace MyApplication;
use ALibrarySession;

class Facebook { ... }

When I try to run the application, I get the following error:

(当我尝试运行该应用程序时,出现以下错误:)

Cannot use A\Library\Session as Session because the name is already in use in My\Application\Facebook.php

(无法将A \ Library \ Session用作Session,因为该名称已在My \ Application \ Facebook.php中使用)

Even though it's not, at least not in this file.

(即使不是,至少在此文件中也没有。)

The Facebook.php file declares only the Facebook class, and imports exactly one Session class, the A\Library one.

(Facebook.php文件仅声明Facebook类,并且仅导入一个Session类,即A\Library 。)

The only problem I can see is that another Session class exists in the same namespace as the Facebook class, but as it was never imported in the Facebook.php file, I thought it did not matter at all.

(我能看到的唯一问题是,另一个Session类与Facebook类存在于同一命名空间中,但是由于从未将其导入Facebook.php文件中,因此我认为这根本没有关系。)

Am I wrong (in that case please point to the relevant documentation), or is this a bug?

(我错了吗(在这种情况下,请指向相关文档),或者这是一个错误吗?)

  ask by Benjamin translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is a bug confirmed in PHP that may affect the behavior you see.

(PHP中确认存在一个错误,该错误可能会影响您看到的行为。)

It is supposed to fatal error, but with opcache enabled, it may still execute flawlessly.

(它应该致命,但是启用opcache后,它仍然可以完美执行。)

https://bugs.php.net/bug.php?id=66773

(https://bugs.php.net/bug.php?id=66773)

If it still concerns you, please vote for the bug.

(如果仍然与您有关,请为该错误投票。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...