Skip to content

Importing Namespaces

Carson Full edited this page Feb 21, 2015 · 1 revision

Importing Namespaces

For type-hinting parameters and creating objects, use only the imported class name.
For the PHPDoc, use the fully qualified namespace (FQN). Note the leading slash.

use Silex\Application;
/**
 * @param $app \Silex\Application
 */
public function  __construct(Application $app) { }

If the namespace is really long though, the imported class name can be used.

use Symfony\Component\Console\Output\OutputInterface;
/**
 * @param $output OutputInterface
 */
public function  __construct(OutputInterface $output) { }

If the class name is ambiguous without part of the namespace, that piece should be included.

use Bolt\Controllers;
/**
 * @param $controller Controllers\Extend
 */
public function  __construct(Controllers\Extend $controller) { }
Clone this wiki locally