efabrica-team / rector-nette

Rector upgrades rules for Nette
http://getrector.org
MIT License
27 stars 7 forks source link

[Nette] Update to nette/neon 3.3.3 compatibility #59

Closed samsonasik closed 2 years ago

samsonasik commented 2 years ago

Fix to avoid error:

1) Rector\Nette\Tests\Rector\Neon\RenameMethodNeonRector\RenameMethodNeonRectorTest::test with data set #0 (Symplify\SmartFileSystem\SmartFileInfo Object (...))
Error: Call to undefined method Nette\Neon\Node\BlockArrayNode::getSubNodes()
samsonasik commented 2 years ago

It seems it cause test error:

There were 4 failures:

1) Rector\Nette\Tests\Rector\Neon\RenameMethodNeonRector\RenameMethodNeonRectorTest::test with data set #0 (Symplify\SmartFileSystem\SmartFileInfo Object (...))
tests/Rector/Neon/RenameMethodNeonRector/Fixture/service_as_class_with_tabs.neon
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
        -
                class: Rector\Nette\Tests\Rector\Neon\RenameMethodNeonRector\Source\SecondService('service-name')
                setup:
-                       - addConfig('second-key', 'second-value')
+                       - add('second-key', 'second-value')
samsonasik commented 2 years ago

Temporary pin to nette/neon 3.3.2 at https://github.com/rectorphp/rector-nette/pull/60 until found the solution for it.

samsonasik commented 2 years ago

So, on nette/neon 3.3.2, it got Rector\Nette\NeonParser\Node\Service_\SetupMethodCall for loop value:

Rector\Nette\NeonParser\Node\Service_\SetupMethodCall #10082
   className: 'Rector\Nette\Tests\Rector\Neon\RenameMethodNeonRector\Source\SecondService'
   methodNameLiteralNode: Nette\Neon\Node\LiteralNode #10106
   |  value: 'add'
   |  startPos: 22
   |  endPos: 22
   entityNode: Nette\Neon\Node\EntityNode #10112
   |  value: Nette\Neon\Node\LiteralNode #10106 see above
   |  attributes: array (2)
   |  |  0 => Nette\Neon\Node\ArrayItemNode #10108
   |  |  |  key: null
   |  |  |  value: Nette\Neon\Node\StringNode #10109
   |  |  |  |  value: 'second-key'
   |  |  |  |  startPos: 24
   |  |  |  |  endPos: 24
   |  |  |  startPos: 24
   |  |  |  endPos: 24
   |  |  1 => Nette\Neon\Node\ArrayItemNode #10110
   |  |  |  key: null
   |  |  |  value: Nette\Neon\Node\StringNode #10111
   |  |  |  |  value: 'second-value'
   |  |  |  |  startPos: 27
   |  |  |  |  endPos: 27
   |  |  |  startPos: 27
   |  |  |  endPos: 27
   |  startPos: 22
   |  endPos: 28
   startPos: null
   endPos: null

while in nette/neon 3.3.3, it got Nette\Neon\Node\ArrayItemNode

Nette\Neon\Node\ArrayItemNode #10089
   key: null
   value: Nette\Neon\Node\BlockArrayNode #10091
   |  indentation: '\t    '
   |  items: array (2)
   |  |  0 => Nette\Neon\Node\ArrayItemNode #10092
   |  |  |  key: Nette\Neon\Node\LiteralNode #10093
   |  |  |  |  value: 'class'
   |  |  |  |  startTokenPos: 7
   |  |  |  |  endTokenPos: 7
   |  |  |  |  startLine: 3
   |  |  |  |  endLine: 3
   |  |  |  value: Nette\Neon\Node\EntityNode #10099
   |  |  |  |  value: Nette\Neon\Node\LiteralNode #10095
   |  |  |  |  |  value: 'Rector\Nette\Tests\Rector\Neon\RenameMethodNeonRector\Source\SecondService'
   |  |  |  |  |  startTokenPos: 10
   |  |  |  |  |  endTokenPos: 10
   |  |  |  |  |  startLine: 3
   |  |  |  |  |  endLine: 3
   |  |  |  |  attributes: array (1)
   |  |  |  |  |  0 => Nette\Neon\Node\ArrayItemNode #10097
   |  |  |  |  |  |  key: null
   |  |  |  |  |  |  value: Nette\Neon\Node\StringNode #10098
   |  |  |  |  |  |  |  value: 'service-name'
   |  |  |  |  |  |  |  startTokenPos: 12
   |  |  |  |  |  |  |  endTokenPos: 12
   |  |  |  |  |  |  |  startLine: 3
   |  |  |  |  |  |  |  endLine: 3
   |  |  |  |  |  |  startTokenPos: 12
   |  |  |  |  |  |  endTokenPos: 12
   |  |  |  |  |  |  startLine: 3
   |  |  |  |  |  |  endLine: 3
   |  |  |  |  startTokenPos: 10
   |  |  |  |  endTokenPos: 13
   |  |  |  |  startLine: 3
   |  |  |  |  endLine: 3
   |  |  |  startTokenPos: 7
   |  |  |  endTokenPos: 13
   |  |  |  startLine: 3
   |  |  |  endLine: 3
   |  |  1 => Nette\Neon\Node\ArrayItemNode #10094
   |  |  |  key: Nette\Neon\Node\LiteralNode #10096
   |  |  |  |  value: 'setup'
   |  |  |  |  startTokenPos: 16
   |  |  |  |  endTokenPos: 16
   |  |  |  |  startLine: 4
   |  |  |  |  endLine: 4
   |  |  |  value: Nette\Neon\Node\BlockArrayNode #10101
   |  |  |  |  indentation: '\t    '
   |  |  |  |  items: array (1)
   |  |  |  |  |  0 => Nette\Neon\Node\ArrayItemNode #10102
   |  |  |  |  |  |  key: null
   |  |  |  |  |  |  value: Nette\Neon\Node\EntityNode #10112
   |  |  |  |  |  |  |  value: Nette\Neon\Node\LiteralNode #10106
   |  |  |  |  |  |  |  |  value: 'add'
   |  |  |  |  |  |  |  |  startTokenPos: 22
   |  |  |  |  |  |  |  |  endTokenPos: 22
   |  |  |  |  |  |  |  |  startLine: 5
   |  |  |  |  |  |  |  |  endLine: 5
   |  |  |  |  |  |  |  attributes: array (2)
   |  |  |  |  |  |  |  |  0 => Nette\Neon\Node\ArrayItemNode #10108
   |  |  |  |  |  |  |  |  |  key: null
   |  |  |  |  |  |  |  |  |  value: Nette\Neon\Node\StringNode #10109
   |  |  |  |  |  |  |  |  |  |  value: 'second-key'
   |  |  |  |  |  |  |  |  |  |  startTokenPos: 24
   |  |  |  |  |  |  |  |  |  |  endTokenPos: 24
   |  |  |  |  |  |  |  |  |  |  startLine: 5
   |  |  |  |  |  |  |  |  |  |  endLine: 5
   |  |  |  |  |  |  |  |  |  startTokenPos: 24
   |  |  |  |  |  |  |  |  |  endTokenPos: 24
   |  |  |  |  |  |  |  |  |  startLine: 5
   |  |  |  |  |  |  |  |  |  endLine: 5
   |  |  |  |  |  |  |  |  1 => Nette\Neon\Node\ArrayItemNode #10110
   |  |  |  |  |  |  |  |  |  key: null
   |  |  |  |  |  |  |  |  |  value: Nette\Neon\Node\StringNode #10111
   |  |  |  |  |  |  |  |  |  |  value: 'second-value'
   |  |  |  |  |  |  |  |  |  |  startTokenPos: 27
   |  |  |  |  |  |  |  |  |  |  endTokenPos: 27
   |  |  |  |  |  |  |  |  |  |  startLine: 5
   |  |  |  |  |  |  |  |  |  |  endLine: 5
   |  |  |  |  |  |  |  |  |  startTokenPos: 27
   |  |  |  |  |  |  |  |  |  endTokenPos: 27
   |  |  |  |  |  |  |  |  |  startLine: 5
   |  |  |  |  |  |  |  |  |  endLine: 5
   |  |  |  |  |  |  |  startTokenPos: 22
   |  |  |  |  |  |  |  endTokenPos: 28
   |  |  |  |  |  |  |  startLine: 5
   |  |  |  |  |  |  |  endLine: 5
   |  |  |  |  |  |  startTokenPos: 20
   |  |  |  |  |  |  endTokenPos: 28
   |  |  |  |  |  |  startLine: 5
   |  |  |  |  |  |  endLine: 5
   |  |  |  |  startTokenPos: 20
   |  |  |  |  endTokenPos: 28
   |  |  |  |  startLine: 5
   |  |  |  |  endLine: 5
   |  |  |  startTokenPos: 16
   |  |  |  endTokenPos: 28
   |  |  |  startLine: 4
   |  |  |  endLine: 5
   |  startTokenPos: 7
   |  endTokenPos: 28
   |  startLine: 3
   |  endLine: 5
   startTokenPos: 4
   endTokenPos: 28
   startLine: 2
   endLine: 5