Skip to content

Commit b04ebbc

Browse files
committed
php 8 support
1 parent a361009 commit b04ebbc

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codedungeon/phpunit-result-printer",
3-
"version": "0.30.1",
3+
"version": "0.31.0",
44
"description": "PHPUnit Pretty Result Printer",
55
"keywords": [
66
"phpunit",
@@ -35,7 +35,7 @@
3535
}
3636
},
3737
"scripts": {
38-
"post-package-install": [
38+
"post-install-cmd": [
3939
"php ./vendor/codedungeon/phpunit-result-printer/src/init.php"
4040
],
4141
"coverage-report": "open ./coverage/index.html",
@@ -50,4 +50,4 @@
5050
"test-watch": "vendor/bin/phpunit-watcher watch --testsuite Unit < /dev/tty",
5151
"watch-tickets": "vendor/bin/phpunit-watcher watch --testsuite Tickets < /dev/tty"
5252
}
53-
}
53+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "phpunit-pretty-result-printer",
3-
"version": "0.30.1",
3+
"version": "0.31.0",
44
"description": "Extend the default PHPUnit Result Printer with a modern, pretty printer!",
55
"main": "index.js",
66
"directories": {
@@ -28,4 +28,4 @@
2828
"@codedungeon/messenger": "0.7.0",
2929
"prettier": "2.1.2"
3030
}
31-
}
31+
}

src/PrinterInit.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,24 @@ public function init(string $use_colors = 'never', array $options = []): int
2626
if (!file_exists($phpunit_xml_file)) {
2727
$phpunit_xml_file = './phpunit.xml.dist';
2828
}
29-
echo self::CYAN."\n==> Configuring phpunit-pretty-result-printer\n".self::RESET;
30-
echo "\n ".self::LWHITE.'[• ]'.self::GREEN." Gathering installation details\n".self::RESET;
29+
echo self::CYAN . "\n==> Configuring phpunit-pretty-result-printer\n" . self::RESET;
30+
echo "\n " . self::LWHITE . '[• ]' . self::GREEN . " Gathering installation details\n" . self::RESET;
3131
$result = $this->add_printer_class_to_phpunit_xml($phpunit_xml_file);
3232
if ($useCollision) {
3333
if (is_dir('vendor/nunomaduro/collision')) {
3434
$result = $this->add_collision_to_phpunit_xml($phpunit_xml_file);
3535
if ($result === 0) {
36-
echo self::GREEN." ✔ Collision listener activated\n".self::RESET;
36+
echo self::GREEN . " ✔ Collision listener activated\n" . self::RESET;
3737
} else {
38-
echo self::MAGENTA." ⇢ Collision already installed\n".self::RESET;
38+
echo self::MAGENTA . " ⇢ Collision already installed\n" . self::RESET;
3939
}
4040
} else {
41-
echo self::RED." ✖ Collision package not installed\n".self::RESET;
41+
echo self::RED . " ✖ Collision package not installed\n" . self::RESET;
4242
}
4343
}
4444
$this->copy_default_settings('phpunit-printer.yml');
45-
echo self::CYAN."\n==> Configuration Complete\n".self::RESET;
45+
echo self::CYAN . "\n==> Configuration Complete\n" . self::RESET;
46+
echo "\n";
4647

4748
return $result;
4849
}
@@ -54,19 +55,19 @@ private function add_printer_class_to_phpunit_xml(string $file = './phpunit.xml'
5455
$data = file_get_contents($PHPUNIT_FILE);
5556
$result = (int) strpos($data, 'printerClass=');
5657
if ($result > 0) {
57-
echo self::LWHITE.' [•• ]'.self::LYELLOW.' Printer class already configured in '.self::CYAN."{$PHPUNIT_FILE} \n".self::RESET;
58+
echo self::LWHITE . ' [•• ]' . self::LYELLOW . ' Printer class already configured in ' . self::CYAN . "{$PHPUNIT_FILE} \n" . self::RESET;
5859

5960
return 0;
6061
} else {
6162
$xml = simplexml_load_file($PHPUNIT_FILE);
6263
$xml->addAttribute('printerClass', 'Codedungeon\PHPUnitPrettyResultPrinter\Printer');
6364
file_put_contents($PHPUNIT_FILE, $xml->asXML());
64-
echo self::LWHITE.' [•• ]'.self::GREEN.' Printer class successfully added to '.self::CYAN.$PHPUNIT_FILE.self::GREEN." file\n".self::RESET;
65+
echo self::LWHITE . ' [•• ]' . self::GREEN . ' Printer class successfully added to ' . self::CYAN . $PHPUNIT_FILE . self::GREEN . " file\n" . self::RESET;
6566

6667
return 1;
6768
}
6869
} else {
69-
echo self::RED.' [•• ] Unable to locate valid '.self::YELLOW.$PHPUNIT_FILE.self::RED.' file, you will need to set '.self::CYAN.'printerClass '.self::RED."manually\n".self::RESET;
70+
echo self::RED . ' [•• ] Unable to locate valid ' . self::YELLOW . $PHPUNIT_FILE . self::RED . ' file, you will need to set ' . self::CYAN . 'printerClass ' . self::RED . "manually\n" . self::RESET;
7071

7172
return -43;
7273
}
@@ -98,18 +99,18 @@ private function add_collision_to_phpunit_xml(string $file = './phpunit.xml'): i
9899
private function copy_default_settings(string $file = 'phpunit-printer.yml')
99100
{
100101
$CONFIG_FILE = $file;
101-
$packageDefaultSettingFile = dirname(__FILE__, 2).DIRECTORY_SEPARATOR.'src/'.$CONFIG_FILE;
102+
$packageDefaultSettingFile = dirname(__FILE__, 2) . DIRECTORY_SEPARATOR . 'src/' . $CONFIG_FILE;
102103

103104
$copySettingFile = $CONFIG_FILE;
104105
if (file_exists($packageDefaultSettingFile)) {
105106
if (!file_exists($copySettingFile)) {
106107
copy($packageDefaultSettingFile, $copySettingFile);
107-
echo self::LWHITE.' [•••]'.self::GREEN.' Configuration '.self::CYAN.'./'.$CONFIG_FILE.self::GREEN." copied to project root\n".self::RESET;
108+
echo self::LWHITE . ' [•••]' . self::GREEN . ' Configuration ' . self::CYAN . './' . $CONFIG_FILE . self::GREEN . " copied to project root\n" . self::RESET;
108109
} else {
109-
echo self::LWHITE.' [•••]'.self::LYELLOW.' Configuration '.self::CYAN.'./'.$CONFIG_FILE.self::LYELLOW." already exists\n".self::RESET;
110+
echo self::LWHITE . ' [•••]' . self::LYELLOW . ' Configuration ' . self::CYAN . './' . $CONFIG_FILE . self::LYELLOW . " already exists\n" . self::RESET;
110111
}
111112
} else {
112-
echo self::LWHITE.' [••E]'.self::RED." An error occurred preparing configuration file\n".self::RESET;
113+
echo self::LWHITE . ' [••E]' . self::RED . " An error occurred preparing configuration file\n" . self::RESET;
113114
}
114115
}
115116
}

0 commit comments

Comments
 (0)