for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
abstract class RunCommandLineMethodOnModule extends Object
{
/**
* root dir for module
* e.g. /var/www/modules/mymodule
* no final slash
*
* @var string
*/
protected $rootDirForModule = '';
protected $commands = [];
public function setRootDirForModule($rootDirForModule)
$this->$rootDirForModule = $rootDirForModule;
}
* @param string
public function setCommand(array $commands)
$this->commands = $commands;
$commands
array
string
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
return $this;
public function addCommands(string $command)
$this->commands[] = $command;
public function __construct($rootDirForModule = '')
$this->rootDirForModule = $rootDirForModule;
public function run()
if (! $this->rootDirForModule) {
user_error('no root dir for module has been set');
if (! count($this->commands)) {
$this->commands
Countable|array
$var
count()
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
if (! count(/** @scrutinizer ignore-type */ $this->commands)) {
user_error('command not set');
$this->runCommand();
* runs a command from the root dir or the module
protected function runCommand()
foreach($this->commands as $command) {
GeneralMethods::output_to_screen('Running ' . $command);
return exec(
' cd '.$this->rootDirForModule.';
'.$command.'
'
);
public static function CheckCommandExists($cmd)
return !empty(shell_exec("which $cmd"));
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..