33namespace JMose \CommandSchedulerBundle \Command ;
44
55use Cron \CronExpression ;
6+ use JMose \CommandSchedulerBundle \Entity \ScheduledCommand ;
67use Symfony \Bridge \Doctrine \ManagerRegistry ;
78use Symfony \Component \Console \Command \Command ;
8- use Symfony \Component \Console \Input \StringInput ;
99use Symfony \Component \Console \Input \InputInterface ;
1010use Symfony \Component \Console \Input \InputOption ;
11+ use Symfony \Component \Console \Input \StringInput ;
1112use Symfony \Component \Console \Output \NullOutput ;
1213use Symfony \Component \Console \Output \OutputInterface ;
1314use Symfony \Component \Console \Output \StreamOutput ;
14- use JMose \CommandSchedulerBundle \Entity \ScheduledCommand ;
1515
1616/**
17- * Class ExecuteCommand : This class is the entry point to execute all scheduled command
17+ * Class ExecuteCommand : This class is the entry point to execute all scheduled command.
1818 *
1919 * @author Julien Guyon <julienguyon@hotmail.com>
20- * @package JMose\CommandSchedulerBundle\Command
2120 */
2221class ExecuteCommand extends Command
2322{
24-
2523 /**
2624 * @var \Doctrine\ORM\EntityManager
2725 */
@@ -33,17 +31,18 @@ class ExecuteCommand extends Command
3331 private $ logPath ;
3432
3533 /**
36- * @var boolean
34+ * @var bool
3735 */
3836 private $ dumpMode ;
3937
4038 /**
41- * @var integer
39+ * @var int
4240 */
4341 private $ commandsVerbosity ;
4442
4543 /**
4644 * ExecuteCommand constructor.
45+ *
4746 * @param ManagerRegistry $managerRegistry
4847 * @param $managerName
4948 * @param $logPath
@@ -62,7 +61,7 @@ public function __construct(ManagerRegistry $managerRegistry, $managerName, $log
6261 }
6362
6463 /**
65- * @inheritdoc
64+ * { @inheritdoc}
6665 */
6766 protected function configure ()
6867 {
@@ -75,9 +74,9 @@ protected function configure()
7574 }
7675
7776 /**
78- * Initialize parameters and services used in execute function
77+ * Initialize parameters and services used in execute function.
7978 *
80- * @param InputInterface $input
79+ * @param InputInterface $input
8180 * @param OutputInterface $output
8281 */
8382 protected function initialize (InputInterface $ input , OutputInterface $ output )
@@ -93,16 +92,17 @@ protected function initialize(InputInterface $input, OutputInterface $output)
9392 }
9493
9594 /**
96- * @param InputInterface $input
95+ * @param InputInterface $input
9796 * @param OutputInterface $output
97+ *
9898 * @return int
9999 */
100100 protected function execute (InputInterface $ input , OutputInterface $ output )
101101 {
102102 $ output ->writeln ('<info>Start : ' .($ this ->dumpMode ? 'Dump ' : 'Execute ' ).' all scheduled command</info> ' );
103103
104104 // Before continue, we check that the output file is valid and writable (except for gaufrette)
105- if (false !== $ this ->logPath && strpos ($ this ->logPath , 'gaufrette: ' ) !== 0 && false === is_writable (
105+ if (false !== $ this ->logPath && 0 !== strpos ($ this ->logPath , 'gaufrette: ' ) && false === is_writable (
106106 $ this ->logPath
107107 )
108108 ) {
@@ -118,7 +118,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
118118
119119 $ noneExecution = true ;
120120 foreach ($ commands as $ command ) {
121-
122121 $ this ->em ->refresh ($ this ->em ->find (ScheduledCommand::class, $ command ));
123122 if ($ command ->isDisabled () || $ command ->isLocked ()) {
124123 continue ;
@@ -161,8 +160,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
161160
162161 /**
163162 * @param ScheduledCommand $scheduledCommand
164- * @param OutputInterface $output
165- * @param InputInterface $input
163+ * @param OutputInterface $output
164+ * @param InputInterface $input
166165 */
167166 private function executeCommand (ScheduledCommand $ scheduledCommand , OutputInterface $ output , InputInterface $ input )
168167 {
@@ -174,7 +173,7 @@ private function executeCommand(ScheduledCommand $scheduledCommand, OutputInterf
174173 ->getRepository (ScheduledCommand::class)
175174 ->getNotLockedCommand ($ scheduledCommand );
176175 //$notLockedCommand will be locked for avoiding parallel calls: http://dev.mysql.com/doc/refman/5.7/en/innodb-locking-reads.html
177- if ($ notLockedCommand === null ) {
176+ if (null === $ notLockedCommand ) {
178177 throw new \Exception ();
179178 }
180179
0 commit comments