for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Factory\Console\Make;
use Factory\Composer;
use Factory\Console\BaseCommand;
use Factory\Generators\TraitGenerator;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
class TraitCommand extends BaseCommand
{
/**
* @var TraitGenerator
*/
private $generator;
* @var \Factory\Composer
private $composer;
public function __construct(Composer $composer, TraitGenerator $generator)
parent::__construct();
$this->generator = $generator;
$this->composer = $composer;
}
public function configure()
$this->setName('make:trait');
$this->setDescription('Create a trait.');
$this->addArgument('name', InputArgument::REQUIRED, 'The name of the trait to make.');
$this->addOption('force', null, InputOption::VALUE_NONE, 'The class should overwrite an existing one.');
public function fire()
$data = [
'name' => $this->argument('name'),
];
$result = $this->generator->setData($data)->setForce($this->option('force'))->make();
$this->option('force')
string|array
boolean
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
if ($result) {
$this->info('Trait: ' . $this->composer->getClassPath($this->argument('name')) . ' created');
} else {
$this->error('Something went wrong!');
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: