neos / rector

Neos Rector Recipes for code migrations
6 stars 4 forks source link

warn about `q(node).property('_path')` and `${node.path}` (the latter wont work either way) #34

Closed dlubitz closed 10 months ago

dlubitz commented 10 months ago

@mhsdesign Can you provide me replacement or at least what you like to warn about in this cases?

mhsdesign commented 10 months ago

Hi ;)

There seems to be the \Neos\Neos\Fusion\Helper\NodeHelper::path function that can be used.

In preparation to https://github.com/neos/neos-development-collection/issues/4208 we should migrate all pre 9.0 ways of accessing member fields on the node

I don't know if all those case must be migrated, but i took the list of node properties from https://github.com/neos/neos-development-collection/issues/4208#issuecomment-1573345069 (generated via reflection) and took the ones which most likely could have been used:

q(node).property('_autoCreated'), node.autoCreated => node.classification.tethered
q(node).property('_contextPath'), node.contextPath => Neos.Node.serializedNodeAddress(node)
q(node).property('_depth'), node.depth => Neos.Node.depth(node)
q(node).property('_identifier'), node.identifier => node.nodeAggregateId.value
q(node).property('_label') => node.label
q(node).property('_name'), node.name => node.nodeName.value
q(node).property('_nodeType') => node.nodeType
q(node).property('_parent'), node.parent => q(node).parent().get(0)
q(node).property('_path'), node.path => Neos.Node.path(node)
q(node).property('_hiddenInIndex'), node.hiddenInIndex => node.properties._hiddenInIndex
q(node).property('_dimensions'), node.dimensions => ???
q(node).property('_hidden'), node.hidden => ???
q(node).property('_index'), node.index => ???
q(node).property('_workspace'), node.workspace => ???
q(node).property('_hiddenBeforeDateTime'), node.hiddenBeforeDateTime => -
q(node).property('_hiddenAfterDateTime'), node.hiddenAfterDateTime => -
dlubitz commented 10 months ago

So this might also be outdated, right?

https://github.com/neos/rector/blob/2f46e9ccff3fb2513030d145f8b162ac79f99623/tests/ContentRepository90/Rules/NodeIsHiddenInIndexRector/Fixture/some_class.php.inc

mhsdesign commented 10 months ago

Yes Idk what that is supposed to do 😂

we want to get rid of _* not add it

dlubitz commented 10 months ago

Hmm, but it's actually the current implementation: https://github.com/neos/neos-development-collection/blob/9cd8c4f790955a4d69e7e4baa59a35d5b434e422/Neos.Neos/NodeTypes/Mixin/Document.yaml#L74-L74