phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

NodeScopeResolver analysed files not as global state and optional

Open MartinMystikJonas opened this issue 3 years ago • 2 comments

@ondrejmirtes We discussed this on our friday call. I prepared PR that would make NodeScopeResolver usable for our use case of collecting latte templates context.

  1. analysedFiles are not global state anymore but passed as optional parameter to resolveNodes and resolveStmtNodes
  2. It is optional parameter - when omitted NodeScopeResolver will not limit what traits it resolves

I split resolveStmtNodes to public resolveStmtNodes which can set analysedFiles and private iterateStmtNodes used internally in NodeScopeResolver to avoid reseting analysedFiles or passing it arround all private methods of NodeScopeResolver

MartinMystikJonas avatar Dec 18 '22 10:12 MartinMystikJonas

Now I see this global state is used by rector. Would you preffer to just make it optional and kept as global state? It would be enough for our use case. I just want to remove global state when I was already making changes to it.

Or make setAnalysedFiles public and mark it as deprecated?

MartinMystikJonas avatar Dec 18 '22 11:12 MartinMystikJonas

I created simpler version that only makes setting analysedPaths optionsl for NodeScopeREsolver (used to limit analysis of trait outside of analysedPaths). See #2123

MartinMystikJonas avatar Dec 18 '22 11:12 MartinMystikJonas