Skip to content
This repository was archived by the owner on Dec 29, 2020. It is now read-only.

Commit 2f369b0

Browse files
committed
Enhance the user experience.
1 parent ec05bec commit 2f369b0

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

bin/phpdoc-to-typehint

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@
1010
* file that was distributed with this source code.
1111
*/
1212

13-
declare(strict_types=1);
13+
if (PHP_VERSION_ID < 70000) {
14+
file_put_contents('php://stderr', sprintf(
15+
"The PHPDoc to Type Hint converter requires PHP 7.0 version or higher and your system has\n".
16+
"PHP %s version installed.\n\n".
17+
"To solve this issue, upgrade your PHP installation.\n\n",
18+
PHP_VERSION
19+
));
20+
exit(1);
21+
}
1422

1523
function includeIfExists($file)
1624
{
@@ -28,5 +36,5 @@ if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader
2836
exit(1);
2937
}
3038

31-
$application = new \Dunglas\PhpDocToTypeHint\Application();
39+
$application = new \Dunglas\PhpDocToTypeHint\Application('PHPDoc to Type Hint converter', '0.1.0-DEV');
3240
$application->run();

src/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
declare(strict_types=1);
12+
declare (strict_types = 1);
1313

1414
namespace Dunglas\PhpDocToTypeHint;
1515

src/ConvertCommand.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
declare(strict_types=1);
12+
declare (strict_types = 1);
1313

1414
namespace Dunglas\PhpDocToTypeHint;
1515

1616
use phpDocumentor\Reflection\Php\ProjectFactory;
1717
use Symfony\Component\Console\Command\Command;
18+
use Symfony\Component\Console\Helper\ProgressBar;
1819
use Symfony\Component\Console\Input\InputArgument;
1920
use Symfony\Component\Console\Input\InputInterface;
2021
use Symfony\Component\Console\Input\InputOption;
@@ -61,8 +62,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
6162
$project = ProjectFactory::createInstance()->create('current', $files);
6263
$converter = new Converter();
6364

65+
$output->writeln('<comment>Running the PHPDoc to Type Hint converter. Brought to you by Kévin Dunglas and Les-Tilleuls.coop.</comment>');
66+
67+
$progress = new ProgressBar($output, count($files));
68+
6469
foreach ($project->getFiles() as $file) {
6570
file_put_contents($file->getPath(), $converter->convert($project, $file));
71+
$progress->advance();
6672
}
73+
74+
$progress->finish();
75+
$output->writeln('');
76+
77+
$output->writeln('<info>Conversion done.</info>');
6778
}
6879
}

0 commit comments

Comments
 (0)