for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace BlueConsole;
class Animation
{
/**
* @var \DateInterval
*/
protected $interval;
public function __construct(int $steps = 6, string $cursor = '*')
$counter = 0;
$forward = true;
$before = 0;
$after = $steps - \strlen($cursor);
echo "\n";
while (true) {
echo '[';
for ($i = 1; $i <= $before; $i++) {
echo ' ';
}
echo $cursor;
for ($i = 0; $i <= $after; $i++) {
echo ']';
echo "\r";
$counter++;
if ($forward) {
$before++;
$after--;
} else {
$before--;
$after++;
if ($counter === ($steps - (\strlen($cursor) -1))) {
$forward = !$forward;
$forward
true
sleep(1);
public function setWaitTime(\DateInterval $dateInterval)
// $interval = new \DateInterval('PT10S');
$dateInterval->invert = true;
$invert
integer
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.
$answer = 42; $correct = false; $correct = (bool) $answer;
//dump($interval);
$d1 = new \DateTime();
$d2 = new \DateTime();
$d2->add($dateInterval);
$iv = $d2->diff($d1);
dump($iv->s);
if ($iv->s === 0) {
echo "end\n";
exit(0);
exit
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.
public function setMessage(string $message)
$message
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function setMessage(/** @scrutinizer ignore-unused */ string $message)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
public function run($process)
$process
public function run(/** @scrutinizer ignore-unused */ $process)
//display message with animation
//execute external process
//wait and display animation
//process ended -> display message and go fodder
protected function displayAnimation()
$steps
$cursor
protected function executeProcess()