Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Function name after newline not classified correctly #429

Open
roblourens opened this issue Jun 1, 2021 · 1 comment
Open

Function name after newline not classified correctly #429

roblourens opened this issue Jun 1, 2021 · 1 comment

Comments

@roblourens
Copy link
Contributor

<?php

	$x = new class {
		public function
		test(string $hi): string {
			return $hi;
		}
	};
?>

<div class="xyz"></div>
  • Check scopes at test, see that it's a function call meta.function-call.php. This newline is allowed
<?php

	$x = new class {
		public function test(string $hi): string {
			return $hi;
		}
	};
?>

<div class="xyz"></div>
  • Now it's a function in a class body
entity.name.function.php
meta.function.php
meta.class.body.php

Not a problem normally but I think it is the root cause behind an issue like microsoft/vscode#124381 where unexpected syntax in the first context causes more problems

@KapitanOczywisty
Copy link
Contributor

This is very strange formatting, and I'm not sure if we should even fix this. We are supporting PSR format and this should be used. We're unable to make TM based syntax 100% accurate and we need to draw a line somewhere.

For the records code responsible for this:

'begin': '''(?x)
((?:(?:final|abstract|public|private|protected|static)\\s+)*)
(function)\\s+
(?i:
(__(?:call|construct|debugInfo|destruct|get|set|isset|unset|toString|
clone|set_state|sleep|wakeup|autoload|invoke|callStatic|serialize|unserialize))
|(?:(&)?\\s*([a-zA-Z_\\x{7f}-\\x{7fffffff}][a-zA-Z0-9_\\x{7f}-\\x{7fffffff}]*))
)
\\s*(\\()
'''

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants