vscode-intelephense icon indicating copy to clipboard operation
vscode-intelephense copied to clipboard

Check for methods in functions

Open givanov95 opened this issue 3 years ago • 2 comments

Feature description or problem with existing feature A clear and concise description of what the feature or problem is.

Method in a function not recognized.

I have a function, that calls anonymous class to extend a class and add a method, but have the Error message for undefined method: The function is autoloaded, in file helpers.php .

Here is the code of the function: `function validate_($data) { return new class($data) extends Validator {

	public function __construct($data)
	{
		parent::__construct($data);

	}		

	public function errorsCombined()
	{
		if(!$this->validate()) {
			foreach($this->errors() as $err) {
				foreach($err as $rule) {						
					$combined_rules[] = $rule;
				}
			}
			return $combined_rules;
		}else {
			return [];
		}

	}
	
};

}`

Usage in a Controller: $v = validate_($_POST) ->rule('required', ['Name', 'PublicOrBehindLogin', 'SortOrder','Status', 'Lang']) ->errorsCombined();

Error message: Undefined method 'errorsCombined'.

But it's actually defined in the function.

Describe the solution you'd like A clear and concise description of what you want to happen.

Not showing error when debug, because actually function is defined and works.

Additional context Add any other context or screenshots about the feature request here. image2 image1

givanov95 avatar Jul 07 '22 08:07 givanov95

@givanov95 I think this is similar to the issue reported here. Helpful as the feature is, I decided to turn off the Undefined Methods diagnostic to rid myself of the ugly squigglies.

Screen Shot 2022-07-14 at 12 47 10 PM

qafui avatar Jul 14 '22 16:07 qafui

@givanov95 I think this is similar to the issue reported here. Helpful as the feature is, I decided to turn off the Undefined Methods diagnostic to rid myself of the ugly squigglies.

Screen Shot 2022-07-14 at 12 47 10 PM

That will work, but I find this option very useful in many other cases, like typing errors etc.

givanov95 avatar Jul 15 '22 07:07 givanov95

What type does the rule method return?

bmewburn avatar Dec 28 '22 05:12 bmewburn