问题
\Braintree_Configuration::environment('sandbox');
This is showing up as "Undefined class Braintree Configuration"
And inside of the package Braintree
it doesn't recognize methods even though they are there in the same class.
回答1:
I originally saw your question when looking to fix a problem with composer/phpstorm/braintree not knowing where the Braintree classes were.
If you had given a little more context to your question like I did to mine over here then it would of been a little clear to understand what the problem was.
The Problem
Although your problem lies with PhpStorm, the cause has nothing to do with composer nor PhpStorm. But rather with Braintree not explaining that they calling the class_alias
function at the end of every class to make their documentation easier to read/use at a glance.
You can see this here with the example you gave:
https://github.com/braintree/braintree_php/blob/master/lib/Braintree/Configuration.php
class_alias('Braintree\Configuration', 'Braintree_Configuration');
The Fix
- The fix that you can do easily is to replace all our alias' with the correct namespace/class. That would be in your file, replacing
Braintree_Configuration
withBraintree\Configuration
. - Or you can wait or PhpStorm to support this (which as LazyOne explained in my question), will be going into the next release of PhpStorm at the end of this month (November 2016). You can view the bug tracker for this bug here.
- Download an EAP (PhpStorm's Early Access Program) release to get access to this fix straight away.
Either way you go about fixing this will resolve your issue. Big thanks to LazyOne to explaining this to me for my problem.
来源:https://stackoverflow.com/questions/37093480/phpstorm-9-0-ide-doesnt-recognize-package-classes