Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
migration_tips
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 3
56
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 configure
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 1
30
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13namespace phpbb\console\command\dev;
14
15use Symfony\Component\Console\Command\Command as symfony_command;
16use Symfony\Component\Console\Input\InputInterface;
17use Symfony\Component\Console\Output\OutputInterface;
18
19class migration_tips extends \phpbb\console\command\command
20{
21    /** @var \phpbb\extension\manager */
22    protected $extension_manager;
23
24    public function __construct(\phpbb\user $user, \phpbb\extension\manager $extension_manager)
25    {
26        $this->extension_manager = $extension_manager;
27        parent::__construct($user);
28    }
29
30    /**
31     * {@inheritdoc}
32     */
33    protected function configure()
34    {
35        $this
36            ->setName('dev:migration-tips')
37            ->setDescription($this->user->lang('CLI_DESCRIPTION_FIND_MIGRATIONS'))
38        ;
39    }
40
41    /**
42     * Executes the command dev:migration-tips.
43     *
44     * Finds migrations that are not depended upon
45     *
46     * @param InputInterface  $input  An InputInterface instance
47     * @param OutputInterface $output An OutputInterface instance
48     *
49     * @return int
50     */
51    protected function execute(InputInterface $input, OutputInterface $output)
52    {
53        $migrations = $this->extension_manager->get_finder()
54            ->set_extensions(array())
55            ->core_path('phpbb/db/migration/data/')
56            ->get_classes();
57        $tips = $migrations;
58
59        foreach ($migrations as $migration_class)
60        {
61            foreach ($migration_class::depends_on() as $dependency)
62            {
63                $tips_key = array_search($dependency, $tips);
64                if ($tips_key !== false)
65                {
66                    unset($tips[$tips_key]);
67                }
68            }
69        }
70
71        $output->writeln("\t\t[");
72        foreach ($tips as $migration)
73        {
74            $output->writeln("\t\t\t'{$migration}',");
75        }
76        $output->writeln("\t\t];");
77
78        return symfony_command::SUCCESS;
79    }
80}