From 882c1a8126a469efdad19c5d7181efd347208ea2 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Fri, 11 Jun 2021 01:41:37 +0800 Subject: [PATCH 1/2] Enable `heredoc_indentation` fixer --- tests/system/API/ResponseTraitTest.php | 44 +-- tests/system/Database/Builder/DeleteTest.php | 12 +- tests/system/Database/Builder/UpdateTest.php | 36 +- tests/system/Format/XMLFormatterTest.php | 108 +++--- tests/system/Helpers/FormHelperTest.php | 320 +++++++++--------- tests/system/Helpers/HTMLHelperTest.php | 236 ++++++------- tests/system/View/ParserFilterTest.php | 10 +- tests/system/View/ParserTest.php | 20 +- utils/PhpCsFixer/CodeIgniter4.php | 1 + ...moveErrorSuppressInTryCatchStmtsRector.php | 16 +- .../RemoveVarTagFromClassConstantRector.php | 22 +- ...nderscoreToCamelCaseVariableNameRector.php | 32 +- 12 files changed, 429 insertions(+), 428 deletions(-) diff --git a/tests/system/API/ResponseTraitTest.php b/tests/system/API/ResponseTraitTest.php index fd2ff44a27ac..79d8235ea8a3 100644 --- a/tests/system/API/ResponseTraitTest.php +++ b/tests/system/API/ResponseTraitTest.php @@ -103,10 +103,10 @@ public function testNoFormatterJSON() $this->assertEquals(201, $this->response->getStatusCode()); $expected = <<assertEquals($expected, $this->response->getBody()); } @@ -125,10 +125,10 @@ public function testAssociativeArrayPayload() $controller = $this->makeController(); $payload = ['answer' => 42]; $expected = <<respond($payload); $this->assertEquals($expected, $this->response->getBody()); } @@ -143,12 +143,12 @@ public function testArrayPayload() 3, ]; $expected = <<respond($payload); $this->assertEquals($expected, $this->response->getBody()); } @@ -161,11 +161,11 @@ public function testPHPtoArrayPayload() $payload->name = 'Tom'; $payload->id = 1; $expected = <<respond((array) $payload); $this->assertEquals($expected, $this->response->getBody()); } @@ -480,10 +480,10 @@ public function testXMLFormatter() $controller->respondCreated(['id' => 3], 'A Custom Reason'); $expected = << -3 + + 3 -EOH; + EOH; $this->assertEquals($expected, $this->response->getBody()); } diff --git a/tests/system/Database/Builder/DeleteTest.php b/tests/system/Database/Builder/DeleteTest.php index c802eacb1a61..52ca78cc2f4d 100644 --- a/tests/system/Database/Builder/DeleteTest.php +++ b/tests/system/Database/Builder/DeleteTest.php @@ -42,9 +42,9 @@ public function testGetCompiledDelete() $sql = $builder->getCompiledDelete(); $expectedSQL = <<<'EOL' - DELETE FROM "jobs" - WHERE "id" = 1 - EOL; + DELETE FROM "jobs" + WHERE "id" = 1 + EOL; $this->assertSame($expectedSQL, $sql); } @@ -55,9 +55,9 @@ public function testGetCompiledDeleteWithLimit() $sql = $builder->where('id', 1)->limit(10)->getCompiledDelete(); $expectedSQL = <<<'EOL' - DELETE FROM "jobs" - WHERE "id" = 1 LIMIT 10 - EOL; + DELETE FROM "jobs" + WHERE "id" = 1 LIMIT 10 + EOL; $this->assertSame($expectedSQL, $sql); } } diff --git a/tests/system/Database/Builder/UpdateTest.php b/tests/system/Database/Builder/UpdateTest.php index 282dab29ba90..ea2fdf8412c2 100644 --- a/tests/system/Database/Builder/UpdateTest.php +++ b/tests/system/Database/Builder/UpdateTest.php @@ -120,28 +120,28 @@ public function testUpdateBatch() $space = ' '; $expected = <<assertSame($expected, $query->getOriginalQuery()); $expected = <<assertSame($expected, $query->getQuery() ); } diff --git a/tests/system/Format/XMLFormatterTest.php b/tests/system/Format/XMLFormatterTest.php index a3ca254270a4..fe30d56b7fc7 100644 --- a/tests/system/Format/XMLFormatterTest.php +++ b/tests/system/Format/XMLFormatterTest.php @@ -22,10 +22,10 @@ public function testBasicXML() ]; $expected = << -bar + + bar -EOH; + EOH; $this->assertEquals($expected, $this->xmlFormatter->format($data)); } @@ -37,10 +37,10 @@ public function testFormatXMLWithMultilevelArray() ]; $expected = << -bar + + bar -EOH; + EOH; $this->assertEquals($expected, $this->xmlFormatter->format($data)); } @@ -52,10 +52,10 @@ public function testFormatXMLWithMultilevelArrayAndNumericKey() ]; $expected = << -foo + + foo -EOH; + EOH; $this->assertEquals($expected, $this->xmlFormatter->format($data)); } @@ -64,10 +64,10 @@ public function testStringFormatting() { $data = ['Something']; $expected = << -Something + + Something -EOH; + EOH; $this->assertEquals($expected, $this->xmlFormatter->format($data)); } @@ -79,10 +79,10 @@ public function testValidatingXmlTags() '096630FR' => 'bar', ]; $expected = << -foobar + + foobar -EOH; + EOH; $this->assertEquals($expected, $this->xmlFormatter->format($data)); } @@ -96,10 +96,10 @@ public function testValidatingXmlTags() public function testValidatingInvalidTags(string $expected, array $input) { $expectedXML = << -<{$expected}>bar + + <{$expected}>bar -EOH; + EOH; $this->assertEquals($expectedXML, $this->xmlFormatter->format($input)); } @@ -172,42 +172,42 @@ public function testDeepNestedArrayToXml() // do not change to tabs!! $expectedXML = << - - - - Foo - foo@bar.com - - - - - - - - - - true - 2020-08-31 - 127.0.0.1 - - - - - - 1.0 - utf-8 - - - miscellaneous - - - miscellaneous data - - - - -EOF; + + + + + Foo + foo@bar.com + + + + + + + + + + true + 2020-08-31 + 127.0.0.1 + + + + + + 1.0 + utf-8 + + + miscellaneous + + + miscellaneous data + + + + + EOF; $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; diff --git a/tests/system/Helpers/FormHelperTest.php b/tests/system/Helpers/FormHelperTest.php index d882a7836eb3..1990d1bfc2f6 100644 --- a/tests/system/Helpers/FormHelperTest.php +++ b/tests/system/Helpers/FormHelperTest.php @@ -33,15 +33,15 @@ public function testFormOpenBasic() $Value = csrf_hash(); $Name = csrf_token(); $expected = << - +
+ -EOH; + EOH; } else { $expected = << + -EOH; + EOH; } $attributes = [ @@ -63,9 +63,9 @@ public function testFormOpenHasLocale() Services::injectMock('request', $request); $expected = << + -EOH; + EOH; $attributes = [ 'name' => 'form', @@ -91,15 +91,15 @@ public function testFormOpenWithoutAction() $Value = csrf_hash(); $Name = csrf_token(); $expected = << - + + -EOH; + EOH; } else { $expected = << + -EOH; + EOH; } $attributes = [ 'name' => 'form', @@ -125,15 +125,15 @@ public function testFormOpenWithoutMethod() $Value = csrf_hash(); $Name = csrf_token(); $expected = << - + + -EOH; + EOH; } else { $expected = << + -EOH; + EOH; } $attributes = [ @@ -159,18 +159,18 @@ public function testFormOpenWithHidden() $Value = csrf_hash(); $Name = csrf_token(); $expected = << - - + + + -EOH; + EOH; } else { $expected = << + - + -EOH; + EOH; } $attributes = [ @@ -200,15 +200,15 @@ public function testFormOpenMultipart() $Value = csrf_hash(); $Name = csrf_token(); $expected = << - + + -EOH; + EOH; } else { $expected = << + -EOH; + EOH; } $attributes = [ 'name' => 'form', @@ -227,8 +227,8 @@ public function testFormHidden() { $expected = <<\n -EOH; + \n + EOH; $this->assertEquals($expected, form_hidden('username', 'johndoe')); } @@ -240,9 +240,9 @@ public function testFormHiddenArrayInput() ]; $expected = << + -EOH; + EOH; $this->assertEquals($expected, form_hidden($data, null)); } @@ -254,9 +254,9 @@ public function testFormHiddenArrayValues() ]; $expected = << + -EOH; + EOH; $this->assertEquals($expected, form_hidden('name', $data)); } @@ -264,8 +264,8 @@ public function testFormHiddenArrayValues() public function testFormInput() { $expected = <<\n -EOH; + \n + EOH; $data = [ 'name' => 'username', 'id' => 'username', @@ -280,8 +280,8 @@ public function testFormInput() public function testFormInputWithExtra() { $expected = <<\n -EOH; + \n + EOH; $data = [ 'id' => 'identity', 'name' => 'identity', @@ -297,8 +297,8 @@ public function testFormInputWithExtra() public function testFormPassword() { $expected = <<\n -EOH; + \n + EOH; $this->assertEquals($expected, form_password('password')); } @@ -306,8 +306,8 @@ public function testFormPassword() public function testFormUpload() { $expected = <<\n -EOH; + \n + EOH; $this->assertEquals($expected, form_upload('attachment')); } @@ -315,8 +315,8 @@ public function testFormUpload() public function testFormTextarea() { $expected = <<Notes\n -EOH; + \n + EOH; $this->assertEquals($expected, form_textarea('notes', 'Notes')); } @@ -328,9 +328,9 @@ public function testFormTextareaWithValueAttribute() 'value' => 'bar', ]; $expected = <<bar + -EOH; + EOH; $this->assertEquals($expected, form_textarea($data)); } @@ -342,8 +342,8 @@ public function testFormTextareaExtraRowsColsArray() 'rows' => '5', ]; $expected = <<Notes\n -EOH; + \n + EOH; $this->assertEquals($expected, form_textarea('notes', 'Notes', $extra)); } @@ -352,8 +352,8 @@ public function testFormTextareaExtraRowsColsString() { $extra = 'cols="30" rows="5"'; $expected = <<Notes\n -EOH; + \n + EOH; $this->assertEquals($expected, form_textarea('notes', 'Notes', $extra)); } @@ -361,13 +361,13 @@ public function testFormTextareaExtraRowsColsString() public function testFormDropdown() { $expected = << - - - - -\n -EOH; + \n + EOH; $options = [ 'small' => 'Small Shirt', 'med' => 'Medium Shirt', @@ -376,13 +376,13 @@ public function testFormDropdown() ]; $this->assertEquals($expected, form_dropdown('shirts', $options, 'large')); $expected = << - - - - -\n -EOH; + \n + EOH; $shirtsOnSale = [ 'small', 'large', @@ -399,17 +399,17 @@ public function testFormDropdown() ], ]; $expected = << - - - - - - - - -\n -EOH; + \n + EOH; $this->assertEquals($expected, form_dropdown('cars', $options, ['volvo', 'audi'])); } @@ -426,17 +426,17 @@ public function testFormDropdownUnselected() ], ]; $expected = << - - - - - - - - -\n -EOH; + \n + EOH; $this->assertEquals($expected, form_dropdown('cars', $options)); } @@ -453,17 +453,17 @@ public function testFormDropdownInferred() ], ]; $expected = << - - - - - - - - -\n -EOH; + \n + EOH; $_POST['cars'] = 'audi'; $this->assertEquals($expected, form_dropdown('cars', $options)); unset($_POST['cars']); @@ -473,11 +473,11 @@ public function testFormDropdownInferred() public function testFormDropdownWithSelectedAttribute() { $expected = << - - + -EOH; + EOH; $data = [ 'name' => 'foo', 'selected' => 'bar', @@ -492,11 +492,11 @@ public function testFormDropdownWithSelectedAttribute() public function testFormDropdownWithOptionsAttribute() { $expected = << - - + -EOH; + EOH; $data = [ 'name' => 'foo', 'options' => [ @@ -510,10 +510,10 @@ public function testFormDropdownWithOptionsAttribute() public function testFormDropdownWithEmptyArrayOptionValue() { $expected = << - + -EOH; + EOH; $options = [ 'bar' => [], ]; @@ -524,13 +524,13 @@ public function testFormDropdownWithEmptyArrayOptionValue() public function testFormMultiselect() { $expected = << - - - - -\n -EOH; + \n + EOH; $options = [ 'small' => 'Small Shirt', 'med' => 'Medium Shirt', @@ -544,13 +544,13 @@ public function testFormMultiselect() public function testFormMultiselectArrayData() { $expected = << - - - - -\n -EOH; + \n + EOH; $options = [ 'small' => 'Small Shirt', 'med' => 'Medium Shirt', @@ -574,9 +574,9 @@ public function testFormMultiselectArrayData() public function testFormFieldset() { $expected = << -Address Information\n -EOH; +
+ Address Information\n + EOH; $this->assertEquals($expected, form_fieldset('Address Information')); } @@ -584,9 +584,9 @@ public function testFormFieldset() public function testFormFieldsetWithNoLegent() { $expected = << +
-EOH; + EOH; $this->assertEquals($expected, form_fieldset()); } @@ -597,10 +597,10 @@ public function testFormFieldsetWithAttributes() 'name' => 'bar', ]; $expected = << -Foo +
+ Foo -EOH; + EOH; $this->assertEquals($expected, form_fieldset('Foo', $attributes)); } @@ -608,8 +608,8 @@ public function testFormFieldsetWithAttributes() public function testFormFieldsetClose() { $expected = << -EOH; +
+ EOH; $this->assertEquals($expected, form_fieldset_close('')); } @@ -617,8 +617,8 @@ public function testFormFieldsetClose() public function testFormCheckbox() { $expected = <<\n -EOH; + \n + EOH; $this->assertEquals($expected, form_checkbox('newsletter', 'accept', true)); } @@ -631,9 +631,9 @@ public function testFormCheckboxArrayData() 'checked' => true, ]; $expected = << + -EOH; + EOH; $this->assertEquals($expected, form_checkbox($data)); } @@ -646,9 +646,9 @@ public function testFormCheckboxArrayDataWithCheckedFalse() 'checked' => false, ]; $expected = << + -EOH; + EOH; $this->assertEquals($expected, form_checkbox($data)); } @@ -656,8 +656,8 @@ public function testFormCheckboxArrayDataWithCheckedFalse() public function testFormRadio() { $expected = <<\n -EOH; + \n + EOH; $this->assertEquals($expected, form_radio('newsletter', 'accept', true)); } @@ -665,8 +665,8 @@ public function testFormRadio() public function testFormSubmit() { $expected = <<\n -EOH; + \n + EOH; $this->assertEquals($expected, form_submit('mysubmit', 'Submit Post!')); } @@ -674,8 +674,8 @@ public function testFormSubmit() public function testFormLabel() { $expected = <<What is your Name -EOH; + + EOH; $this->assertEquals($expected, form_label('What is your Name', 'username')); } @@ -686,8 +686,8 @@ public function testFormLabelWithAttributes() 'id' => 'label1', ]; $expected = <<bar -EOH; + + EOH; $this->assertEquals($expected, form_label('bar', 'foo', $attributes)); } @@ -695,8 +695,8 @@ public function testFormLabelWithAttributes() public function testFormReset() { $expected = <<\n -EOH; + \n + EOH; $this->assertEquals($expected, form_reset('myreset', 'Reset')); } @@ -704,8 +704,8 @@ public function testFormReset() public function testFormButton() { $expected = <<content\n -EOH; + \n + EOH; $this->assertEquals($expected, form_button('name', 'content')); } @@ -717,9 +717,9 @@ public function testFormButtonWithDataArray() 'content' => 'bar', ]; $expected = <<bar + -EOH; + EOH; $this->assertEquals($expected, form_button($data)); } @@ -727,8 +727,8 @@ public function testFormButtonWithDataArray() public function testFormClose() { $expected = << -EOH; + + EOH; $this->assertEquals($expected, form_close('')); } @@ -740,13 +740,13 @@ public function testFormDatalist() 'bar1', ]; $expected = << + - + -EOH; + EOH; $this->assertEquals($expected, form_datalist('foo', 'bar', $options)); } diff --git a/tests/system/Helpers/HTMLHelperTest.php b/tests/system/Helpers/HTMLHelperTest.php index 2355007e4090..ac50e28a5ca7 100755 --- a/tests/system/Helpers/HTMLHelperTest.php +++ b/tests/system/Helpers/HTMLHelperTest.php @@ -38,12 +38,12 @@ protected function setUp(): void public function testBasicUL() { $expected = << -
  • foo
  • -
  • bar
  • - +
      +
    • foo
    • +
    • bar
    • +
    -EOH; + EOH; $expected = ltrim($expected); $list = [ @@ -57,12 +57,12 @@ public function testBasicUL() public function testULWithClass() { $expected = << -
  • foo
  • -
  • bar
  • - +
      +
    • foo
    • +
    • bar
    • +
    -EOH; + EOH; $expected = ltrim($expected); $list = [ @@ -76,18 +76,18 @@ public function testULWithClass() public function testMultiLevelUL() { $expected = << -
  • foo
  • -
  • bar
  • -
  • 2 -
      -
    • foo
    • -
    • bar
    • -
    -
  • - - -EOH; +
      +
    • foo
    • +
    • bar
    • +
    • 2 +
        +
      • foo
      • +
      • bar
      • +
      +
    • +
    + + EOH; $expected = ltrim($expected); $list = [ @@ -107,12 +107,12 @@ public function testMultiLevelUL() public function testBasicOL() { $expected = << -
  • foo
  • -
  • bar
  • - +
      +
    1. foo
    2. +
    3. bar
    4. +
    -EOH; + EOH; $expected = ltrim($expected); $list = [ @@ -126,12 +126,12 @@ public function testBasicOL() public function testOLWithClass() { $expected = << -
  • foo
  • -
  • bar
  • - +
      +
    1. foo
    2. +
    3. bar
    4. +
    -EOH; + EOH; $expected = ltrim($expected); $list = [ @@ -145,18 +145,18 @@ public function testOLWithClass() public function testMultiLevelOL() { $expected = << -
  • foo
  • -
  • bar
  • -
  • 2 -
      -
    1. foo
    2. -
    3. bar
    4. -
    -
  • - - -EOH; +
      +
    1. foo
    2. +
    3. bar
    4. +
    5. 2 +
        +
      1. foo
      2. +
      3. bar
      4. +
      +
    6. +
    + + EOH; $expected = ltrim($expected); $list = [ @@ -300,11 +300,11 @@ public function testDocTypeInvalid() public function testVideo() { $expected = << - Your browser does not support the video tag. - + -EOH; + EOH; $target = 'http://www.codeigniter.com/test.mp4'; $message = 'Your browser does not support the video tag.'; @@ -315,13 +315,13 @@ public function testVideo() public function testVideoWithTracks() { $expected = << - - - Your browser does not support the video tag. - + -EOH; + EOH; $target = 'test.mp4'; $message = 'Your browser does not support the video tag.'; @@ -332,13 +332,13 @@ public function testVideoWithTracks() public function testVideoWithTracksAndIndex() { $expected = << - - - Your browser does not support the video tag. - + -EOH; + EOH; $target = 'test.mp4'; $message = 'Your browser does not support the video tag.'; @@ -349,17 +349,17 @@ public function testVideoWithTracksAndIndex() public function testVideoMultipleSources() { $expected = << - - - - - - - Your browser does not support the video tag. - - -EOH; + + + EOH; $sources = [ source('movie.mp4', 'video/mp4', 'class="test"'), @@ -378,15 +378,15 @@ public function testVideoMultipleSources() public function testAudio() { $expected = << - - - - - Your browser does not support the audio tag. - + -EOH; + EOH; $sources = [ source('sound.ogg', 'audio/ogg'), @@ -401,11 +401,11 @@ public function testAudio() public function testAudioSimple() { $expected = << - Your browser does not support the audio tag. - + -EOH; + EOH; $source = 'sound.mpeg'; $message = 'Your browser does not support the audio tag.'; @@ -417,11 +417,11 @@ public function testAudioSimple() public function testAudioWithSource() { $expected = << - Your browser does not support the audio tag. - + -EOH; + EOH; $source = 'http://codeigniter.com/sound.mpeg'; $message = 'Your browser does not support the audio tag.'; @@ -433,11 +433,11 @@ public function testAudioWithSource() public function testAudioWithIndex() { $expected = << - Your browser does not support the audio tag. - + -EOH; + EOH; $source = 'sound.mpeg'; $message = 'Your browser does not support the audio tag.'; @@ -449,13 +449,13 @@ public function testAudioWithIndex() public function testAudioWithTracks() { $expected = << - - - Your browser does not support the audio tag. - + -EOH; + EOH; $source = 'sound.mpeg'; $message = 'Your browser does not support the audio tag.'; @@ -469,22 +469,22 @@ public function testAudioWithTracks() public function testMediaNameOnly() { $expected = << - + + -EOH; + EOH; $this->assertEquals($expected, _media('av')); } public function testMediaWithSources() { $expected = << - - - + + + + -EOH; + EOH; $sources = [ source('sound.ogg', 'audio/ogg'), source('sound.mpeg', 'audio/mpeg'), @@ -503,9 +503,9 @@ public function testSource() public function testEmbed() { $expected = << + -EOH; + EOH; $type = 'video/quicktime'; $embed = embed('movie.mov', $type, 'class="test"'); @@ -515,9 +515,9 @@ public function testEmbed() public function testEmbedIndexed() { $expected = << + -EOH; + EOH; $type = 'video/quicktime'; $embed = embed('movie.mov', $type, 'class="test"', true); @@ -527,9 +527,9 @@ public function testEmbedIndexed() public function testObject() { $expected = << + -EOH; + EOH; $type = 'application/x-shockwave-flash'; $object = object('movie.swf', $type, 'class="test"'); @@ -540,12 +540,12 @@ public function testObject() public function testObjectWithParams() { $expected = << - - - + + + + -EOH; + EOH; $type = 'application/x-shockwave-flash'; $parms = [ @@ -559,9 +559,9 @@ public function testObjectWithParams() public function testObjectIndexed() { $expected = << + -EOH; + EOH; $type = 'application/x-shockwave-flash'; $object = object('movie.swf', $type, 'class="test"', [], true); diff --git a/tests/system/View/ParserFilterTest.php b/tests/system/View/ParserFilterTest.php index c8a5a387ac41..382a3ca27ee7 100644 --- a/tests/system/View/ParserFilterTest.php +++ b/tests/system/View/ParserFilterTest.php @@ -181,11 +181,11 @@ public function testHighlightCode() $template = '{ value1|highlight_code }'; $expected = << -Sincerely  - - -EOF; + + Sincerely  + + + EOF; $this->assertEquals($expected, $parser->renderString($template)); } diff --git a/tests/system/View/ParserTest.php b/tests/system/View/ParserTest.php index 1c2bf37a521b..299dfd6e5174 100644 --- a/tests/system/View/ParserTest.php +++ b/tests/system/View/ParserTest.php @@ -929,20 +929,20 @@ public function testParseLoopWithHashInPrecession(): void ]; $template = <<<'EOF' -

    #{heading}

    - {entries} -
    #{title}
    -

    {body}

    - {/entries} - EOF; +

    #{heading}

    + {entries} +
    #{title}
    +

    {body}

    + {/entries} + EOF; $expected = <<<'EOF' -

    #My Title

    +

    #My Title

    -
    #Subtitle
    -

    Lorem ipsum

    +
    #Subtitle
    +

    Lorem ipsum

    - EOF; + EOF; $this->parser->setData($data); $this->assertSame($expected, $this->parser->renderString($template)); diff --git a/utils/PhpCsFixer/CodeIgniter4.php b/utils/PhpCsFixer/CodeIgniter4.php index 2d27b32f987b..138aa1197f9c 100644 --- a/utils/PhpCsFixer/CodeIgniter4.php +++ b/utils/PhpCsFixer/CodeIgniter4.php @@ -75,6 +75,7 @@ public function __construct() 'single_line' => true, ], 'function_to_constant' => true, + 'heredoc_indentation' => ['indentation' => 'start_plus_one'], 'indentation_type' => true, 'line_ending' => true, 'list_syntax' => ['syntax' => 'short'], diff --git a/utils/Rector/RemoveErrorSuppressInTryCatchStmtsRector.php b/utils/Rector/RemoveErrorSuppressInTryCatchStmtsRector.php index 3f200868c7c1..7c8d97b8122a 100644 --- a/utils/Rector/RemoveErrorSuppressInTryCatchStmtsRector.php +++ b/utils/Rector/RemoveErrorSuppressInTryCatchStmtsRector.php @@ -18,15 +18,15 @@ public function getRuleDefinition(): RuleDefinition return new RuleDefinition('Remove error suppression operator `@` inside try...catch blocks', [ new CodeSample( <<<'CODE_SAMPLE' - try { - @rmdir($dirname); - } catch (Exception $e) {} - CODE_SAMPLE, + try { + @rmdir($dirname); + } catch (Exception $e) {} + CODE_SAMPLE, <<<'CODE_SAMPLE' - try { - rmdir($dirname); - } catch (Exception $e) {} - CODE_SAMPLE + try { + rmdir($dirname); + } catch (Exception $e) {} + CODE_SAMPLE ), ]); } diff --git a/utils/Rector/RemoveVarTagFromClassConstantRector.php b/utils/Rector/RemoveVarTagFromClassConstantRector.php index c579ca10abb6..93c0f9ea5155 100644 --- a/utils/Rector/RemoveVarTagFromClassConstantRector.php +++ b/utils/Rector/RemoveVarTagFromClassConstantRector.php @@ -18,18 +18,18 @@ public function getRuleDefinition(): RuleDefinition return new RuleDefinition('Remove @var tag from class constant', [ new CodeSample( <<<'CODE_SAMPLE' - class Foo - { - /** @var string */ - const X = 'test'; - } - CODE_SAMPLE, + class Foo + { + /** @var string */ + const X = 'test'; + } + CODE_SAMPLE, <<<'CODE_SAMPLE' - class Foo - { - const X = 'test'; - } - CODE_SAMPLE + class Foo + { + const X = 'test'; + } + CODE_SAMPLE ), ]); } diff --git a/utils/Rector/UnderscoreToCamelCaseVariableNameRector.php b/utils/Rector/UnderscoreToCamelCaseVariableNameRector.php index a78f934ddda6..479fa8acea59 100644 --- a/utils/Rector/UnderscoreToCamelCaseVariableNameRector.php +++ b/utils/Rector/UnderscoreToCamelCaseVariableNameRector.php @@ -51,24 +51,24 @@ public function getRuleDefinition(): RuleDefinition return new RuleDefinition('Change under_score names to camelCase', [ new CodeSample( <<<'CODE_SAMPLE' -final class SomeClass -{ - public function run($a_b) - { - $some_value = $a_b; - } -} -CODE_SAMPLE + final class SomeClass + { + public function run($a_b) + { + $some_value = $a_b; + } + } + CODE_SAMPLE , <<<'CODE_SAMPLE' -final class SomeClass -{ - public function run($aB) - { - $someValue = $aB; - } -} -CODE_SAMPLE + final class SomeClass + { + public function run($aB) + { + $someValue = $aB; + } + } + CODE_SAMPLE ), ]); } From 099fda54c030c7a90f223a5dd0d28a7993114106 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Fri, 11 Jun 2021 01:45:18 +0800 Subject: [PATCH 2/2] Convert Heredoc to Nowdoc syntax where possible --- tests/system/API/ResponseTraitTest.php | 10 +++--- tests/system/Format/XMLFormatterTest.php | 12 +++---- tests/system/Helpers/FormHelperTest.php | 44 ++++++++++++------------ tests/system/Helpers/HTMLHelperTest.php | 44 ++++++++++++------------ tests/system/View/ParserFilterTest.php | 2 +- utils/PhpCsFixer/CodeIgniter4.php | 1 + 6 files changed, 57 insertions(+), 56 deletions(-) diff --git a/tests/system/API/ResponseTraitTest.php b/tests/system/API/ResponseTraitTest.php index 79d8235ea8a3..8701922e734c 100644 --- a/tests/system/API/ResponseTraitTest.php +++ b/tests/system/API/ResponseTraitTest.php @@ -102,7 +102,7 @@ public function testNoFormatterJSON() $this->assertEquals('A Custom Reason', $this->response->getReason()); $this->assertEquals(201, $this->response->getStatusCode()); - $expected = <<formatter = null; $controller = $this->makeController(); $payload = ['answer' => 42]; - $expected = <<name = 'Tom'; $payload->id = 1; - $expected = <<assertEquals('CodeIgniter\Format\XMLFormatter', get_class($this->formatter)); $controller->respondCreated(['id' => 3], 'A Custom Reason'); - $expected = << 3 diff --git a/tests/system/Format/XMLFormatterTest.php b/tests/system/Format/XMLFormatterTest.php index fe30d56b7fc7..7cedeb9acdf0 100644 --- a/tests/system/Format/XMLFormatterTest.php +++ b/tests/system/Format/XMLFormatterTest.php @@ -21,7 +21,7 @@ public function testBasicXML() 'foo' => 'bar', ]; - $expected = << bar @@ -36,7 +36,7 @@ public function testFormatXMLWithMultilevelArray() 'foo' => ['bar'], ]; - $expected = << bar @@ -51,7 +51,7 @@ public function testFormatXMLWithMultilevelArrayAndNumericKey() ['foo'], ]; - $expected = << foo @@ -63,7 +63,7 @@ public function testFormatXMLWithMultilevelArrayAndNumericKey() public function testStringFormatting() { $data = ['Something']; - $expected = << Something @@ -78,7 +78,7 @@ public function testValidatingXmlTags() 'BBB096630BD' => 'foo', '096630FR' => 'bar', ]; - $expected = << foobar @@ -171,7 +171,7 @@ public function testDeepNestedArrayToXml() ]; // do not change to tabs!! - $expectedXML = << diff --git a/tests/system/Helpers/FormHelperTest.php b/tests/system/Helpers/FormHelperTest.php index 1990d1bfc2f6..4bf1224b0b7e 100644 --- a/tests/system/Helpers/FormHelperTest.php +++ b/tests/system/Helpers/FormHelperTest.php @@ -38,7 +38,7 @@ public function testFormOpenBasic() EOH; } else { - $expected = << EOH; @@ -62,7 +62,7 @@ public function testFormOpenHasLocale() $request->uri = new URI('http://example.com/'); Services::injectMock('request', $request); - $expected = << EOH; @@ -96,7 +96,7 @@ public function testFormOpenWithoutAction() EOH; } else { - $expected = << EOH; @@ -130,7 +130,7 @@ public function testFormOpenWithoutMethod() EOH; } else { - $expected = << EOH; @@ -165,7 +165,7 @@ public function testFormOpenWithHidden() EOH; } else { - $expected = << @@ -205,7 +205,7 @@ public function testFormOpenMultipart() EOH; } else { - $expected = << EOH; @@ -238,7 +238,7 @@ public function testFormHiddenArrayInput() $data = [ 'foo' => 'bar', ]; - $expected = << @@ -252,7 +252,7 @@ public function testFormHiddenArrayValues() $data = [ 'foo' => 'bar', ]; - $expected = << @@ -327,7 +327,7 @@ public function testFormTextareaWithValueAttribute() 'name' => 'foo', 'value' => 'bar', ]; - $expected = <<bar EOH; @@ -472,7 +472,7 @@ public function testFormDropdownInferred() // ------------------------------------------------------------------------ public function testFormDropdownWithSelectedAttribute() { - $expected = << @@ -491,7 +491,7 @@ public function testFormDropdownWithSelectedAttribute() // ------------------------------------------------------------------------ public function testFormDropdownWithOptionsAttribute() { - $expected = << @@ -509,7 +509,7 @@ public function testFormDropdownWithOptionsAttribute() // ------------------------------------------------------------------------ public function testFormDropdownWithEmptyArrayOptionValue() { - $expected = << @@ -583,7 +583,7 @@ public function testFormFieldset() // ------------------------------------------------------------------------ public function testFormFieldsetWithNoLegent() { - $expected = << EOH; @@ -596,7 +596,7 @@ public function testFormFieldsetWithAttributes() $attributes = [ 'name' => 'bar', ]; - $expected = << Foo @@ -607,7 +607,7 @@ public function testFormFieldsetWithAttributes() // ------------------------------------------------------------------------ public function testFormFieldsetClose() { - $expected = << EOH; $this->assertEquals($expected, form_fieldset_close('')); @@ -630,7 +630,7 @@ public function testFormCheckboxArrayData() 'value' => 'bar', 'checked' => true, ]; - $expected = << EOH; @@ -645,7 +645,7 @@ public function testFormCheckboxArrayDataWithCheckedFalse() 'value' => 'bar', 'checked' => false, ]; - $expected = << EOH; @@ -673,7 +673,7 @@ public function testFormSubmit() // ------------------------------------------------------------------------ public function testFormLabel() { - $expected = <<What is your Name EOH; $this->assertEquals($expected, form_label('What is your Name', 'username')); @@ -685,7 +685,7 @@ public function testFormLabelWithAttributes() $attributes = [ 'id' => 'label1', ]; - $expected = <<bar EOH; $this->assertEquals($expected, form_label('bar', 'foo', $attributes)); @@ -716,7 +716,7 @@ public function testFormButtonWithDataArray() 'name' => 'foo', 'content' => 'bar', ]; - $expected = <<bar EOH; @@ -726,7 +726,7 @@ public function testFormButtonWithDataArray() // ------------------------------------------------------------------------ public function testFormClose() { - $expected = << EOH; $this->assertEquals($expected, form_close('')); @@ -739,7 +739,7 @@ public function testFormDatalist() 'foo1', 'bar1', ]; - $expected = <<