File tree Expand file tree Collapse file tree 7 files changed +31
-20
lines changed Expand file tree Collapse file tree 7 files changed +31
-20
lines changed Original file line number Diff line number Diff line change 11language : php
22php :
3+ - 5.5
34 - 5.6
45 - 7.0
56 - hhvm
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ Here is a minimal example of a `composer.json` file that just defines a dependen
1212
1313 {
1414 "require": {
15- "michal-kocarek/teamcity-messages": "^1.0 "
15+ "michal-kocarek/teamcity-messages": "^1.1 "
1616 }
1717 }
1818
Original file line number Diff line number Diff line change 11{
22 "name" : " michal-kocarek/teamcity-messages" ,
33 "description" : " Write TeamCity service messages from PHP." ,
4- "version" : " 1.0 .0" ,
4+ "version" : " 1.1 .0" ,
55 "keywords" : [
66 " teamcity"
77 ],
1414 }
1515 ],
1616 "require" : {
17- "php" : " >=5.6 "
17+ "php" : " >=5.5 "
1818 },
1919 "require-dev" : {
20- "phpunit/phpunit" : " ^5.2 .9" ,
20+ "phpunit/phpunit" : " ^4.8 .9" ,
2121 "satooshi/php-coveralls" : " ^1.0.1"
2222 },
2323 "autoload" : {
Original file line number Diff line number Diff line change 99
1010class Util
1111{
12- const ESCAPE_CHARACTER_MAP = [
13- '\'' => '| \'' ,
14- "\n" => '|n ' ,
15- "\r" => '|r ' ,
16- '| ' => '|| ' ,
17- '[ ' => '|[ ' ,
18- '] ' => '|] ' ,
19- ];
20-
2112 const TIMESTAMP_FORMAT = 'Y-m-d\TH:i:s.uO ' ;
2213
2314 /**
@@ -97,11 +88,26 @@ public static function formatTimestamp(DateTimeInterface $date = null)
9788 */
9889 private static function escape ($ value )
9990 {
100- return preg_replace_callback ('/([ \'\n\r|[\]])| \\\\u(\d{4})/ ' , function ($ matches ) {
91+ $ escapeCharacterMap = [
92+ '\'' => '| \'' ,
93+ "\n" => '|n ' ,
94+ "\r" => '|r ' ,
95+ '| ' => '|| ' ,
96+ '[ ' => '|[ ' ,
97+ '] ' => '|] ' ,
98+ ];
99+
100+ return preg_replace_callback (/**
101+ * @param $matches
102+ * @return mixed|string
103+ */
104+ '/([ \'\n\r|[\]])| \\\\u(\d{4})/ ' , function ($ matches ) use ($ escapeCharacterMap ) {
101105 if ($ matches [1 ]) {
102- return self :: ESCAPE_CHARACTER_MAP [$ matches [1 ]];
106+ return $ escapeCharacterMap [$ matches [1 ]];
103107 } elseif ($ matches [2 ]) {
104108 return '|0x ' .$ matches [2 ];
109+ } else {
110+ throw new LogicException ('Unexpected match combination. ' );
105111 }
106112 }, $ value );
107113 }
Original file line number Diff line number Diff line change 11<?php
22
3- namespace Bileto \TeamcityMessages \Tests ;
3+ namespace MichalKocarek \TeamcityMessages \Tests ;
44
55use Exception ;
66use LogicException ;
Original file line number Diff line number Diff line change 1010class CallbackWriterTest extends PHPUnit_Framework_TestCase
1111{
1212 /**
13+ * Method accepts messages as an argument.
1314 * @dataProvider dataProviderWrite
14- * @param array $messages
1515 */
16- public function testWrite (...$ messages )
16+ public function testWrite (/* ...$messages */ )
1717 {
18+ $ messages = func_get_args ();
19+
1820 $ result = '' ;
1921 $ writer = new CallbackWriter (function ($ message ) use (&$ result ) {
2022 $ result .= $ message ;
Original file line number Diff line number Diff line change 1010class StdoutWriterTest extends PHPUnit_Framework_TestCase
1111{
1212 /**
13+ * Method accepts messages as an argument.
1314 * @dataProvider dataProviderWrite
14- * @param array $messages
1515 */
16- public function testWrite (...$ messages )
16+ public function testWrite (/* ...$messages */ )
1717 {
18+ $ messages = func_get_args ();
19+
1820 $ writer = new StdoutWriter ();
1921
2022 ob_start ();
You can’t perform that action at this time.
0 commit comments