Skip to content

Option to set or overwrite a method. #152

Description

@kosciuk

hello, if I try to edit a file, I have no way to keep a method and overwrite others, as there is "setMethods" which does a $methods = [].

I think there may be a setMethod() or overwriteMethod() that allows to add without deleting everything.

// copied from addMethod
public function setMethod(Method $method): static
{
	$lower = strtolower($method->getName());
	if (isset($this->methods[$lower])) {
		throw new Nette\InvalidStateException("Cannot add method '$name', because it already exists.");
	}
	if (!$this->isInterface()) {
		$method->setPublic();
	}

	return $this->methods[$lower] = $method;
}

This problem arose when doing a diff between the methods of a class.

I think it is important to have automatically generated files that can be edited by the programmer and the generator without losing data.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions