These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | /** |
||
5 | * This file is part of phpDocumentor. |
||
6 | * |
||
7 | * For the full copyright and license information, please view the LICENSE |
||
8 | * file that was distributed with this source code. |
||
9 | * |
||
10 | * @author Mike van Riel <[email protected]> |
||
11 | * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
||
12 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
||
13 | * @link http://phpdoc.org |
||
14 | */ |
||
15 | |||
16 | namespace phpDocumentor\Partials; |
||
17 | |||
18 | use Parsedown; |
||
19 | use phpDocumentor\Descriptor\Collection; |
||
20 | use phpDocumentor\Partials\Exception\MissingNameForPartialException; |
||
21 | use Pimple\Container; |
||
22 | use Pimple\ServiceProviderInterface; |
||
23 | |||
24 | /** |
||
25 | * This provider is responsible for registering the partials component with the given Application. |
||
26 | */ |
||
27 | class ServiceProvider implements ServiceProviderInterface |
||
28 | { |
||
29 | /** |
||
30 | * Registers services on the given app. |
||
31 | * |
||
32 | * @throws MissingNameForPartialException if a partial has no name provided. |
||
33 | */ |
||
34 | public function register(Container $app): void |
||
35 | { |
||
36 | $app['markdown'] = function () { |
||
37 | return Parsedown::instance(); |
||
38 | }; |
||
39 | |||
40 | $partialsCollection = new Collection(); |
||
41 | $app['partials'] = $partialsCollection; |
||
42 | |||
43 | /** @var Partial[] $partials */ |
||
44 | $partials = []; //$config->getPartials(); |
||
0 ignored issues
–
show
|
|||
45 | if ($partials) { |
||
46 | foreach ($partials as $partial) { |
||
47 | if (! $partial->getName()) { |
||
48 | throw new MissingNameForPartialException('The name of the partial to load is missing'); |
||
49 | } |
||
50 | |||
51 | $partial->setParser($app['markdown']); |
||
52 | if (!$partial->getContent() && $partial->getLink()) { |
||
53 | if (! is_readable($partial->getLink())) { |
||
54 | $app['monolog']->error( |
||
55 | sprintf('Partial "%s" not readable or found.', $partial->getLink()) |
||
56 | ); |
||
57 | continue; |
||
58 | } |
||
59 | } |
||
60 | |||
61 | $partialsCollection->set($partial->getName(), $partial); |
||
62 | } |
||
63 | } |
||
64 | } |
||
65 | } |
||
66 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.