for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* @author Mike van Riel <[email protected]>
* @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Transformer\Router\UrlGenerator\Standard;
use phpDocumentor\Descriptor;
use phpDocumentor\Transformer\Router\UrlGenerator\UrlGeneratorInterface as UrlGenerator;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class FileDescriptor implements UrlGenerator
{
private $urlGenerator;
private $converter;
public function __construct(
UrlGeneratorInterface $urlGenerator,
QualifiedNameToUrlConverter $converter
) {
$this->urlGenerator = $urlGenerator;
$this->converter = $converter;
}
* Generates a URL from the given node or returns false if unable.
* @param string|Descriptor\FileDescriptor $node
* @return string|false
public function __invoke($node)
return $this->urlGenerator->generate(
'file',
[
'name' => $this->converter->fromFile($node->getPath())
$node
string
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:
function someFunction(A $objectMaybe = null) { if ($objectMaybe instanceof A) { $objectMaybe->doSomething(); } }
]
);
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: