Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespacing, or better class prefixing. #204

Closed
bertramakers opened this issue Mar 3, 2015 · 5 comments
Closed

Namespacing, or better class prefixing. #204

bertramakers opened this issue Mar 3, 2015 · 5 comments

Comments

@bertramakers
Copy link

Me and the people I'm working with are using Phing to check our coding standards, run our tests, etc. We were looking into using this project in our tests to use Selenium for functional testing, but sadly both Phing and php-webdriver have a NullPointerException class in the global namespace which is causing the following error:

PHP Fatal error:  Cannot redeclare class NullPointerException in /Users/bert/Sites/selenium-webdriver/vendor/facebook/webdriver/lib/WebDriverExceptions.php on line 149

Luckily, Phing is getting namespacing in its 3.0 release, but it's still some time before that will be released. (https://www.phing.info/trac/roadmap)

Now, even though Phing is getting namespaces, I still feel like php-webdriver should use namespaces as well, or AT LEAST properly prefix all classes in the global namespace. Granted, most classes are already prefixed with "WebDriver", but there are still classes like "NullPointerException", "UnrecognizedExceptionException", "URLChecker", ... that are not prefixed.

A quick fix would be to prefix the non-prefixed classes, but proper namespacing would of course be preferred.

@bertramakers
Copy link
Author

Another beautiful example of a class name that could cause conflicts is "ExpectedException". :)

I'll try to rename all Exception class so they end in "WebDriverException" (like their base class does) and do a pull request, but using namespaces would of course be a better long-term solution.

Sadly, I don't have that much time on my hands to refactor this whole project myself to use namespaces.

@gabrielpreston
Copy link
Contributor

Unfortunately, Facebook does not and will not use namespaces. This has come up several times in the past (search through the closed issues).

@bertramakers
Copy link
Author

Yes, I just saw #181 (because it was a pull request and not an issue I did not see it sooner).

I forked the php-webdriver and renamed all Exception classes to end in WebDriverException. This should fix this particular conflict, and is better practice if Facebook doesn't want to use namespaces. See #205. (I did not find a way to do a PR in this issue itself.)

Classes like "NullPointerException", "ExpectedException", "TimeOutException" etc. are just way too common to make it possible to use php-webdriver in other projects.

@ghost
Copy link

ghost commented Apr 22, 2015

+1, this is really really annoying. I am maintaining a namespaced fork of this as janoszen/webdriver if you are interested.

@gfosco gfosco mentioned this issue May 13, 2015
@gfosco
Copy link
Contributor

gfosco commented May 13, 2015

Closing, please see #212.

@gfosco gfosco closed this as completed May 13, 2015
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

No branches or pull requests

3 participants