diff --git a/src/PhpGenerator/Factory.php b/src/PhpGenerator/Factory.php index 33c6f115..db5fa118 100644 --- a/src/PhpGenerator/Factory.php +++ b/src/PhpGenerator/Factory.php @@ -14,7 +14,7 @@ /** - * Creates a representation based on reflection. + * Creates a representations based on reflection or source code. */ final class Factory { diff --git a/src/PhpGenerator/Traits/MethodsAware.php b/src/PhpGenerator/Traits/MethodsAware.php index 76e50f34..a28c0613 100644 --- a/src/PhpGenerator/Traits/MethodsAware.php +++ b/src/PhpGenerator/Traits/MethodsAware.php @@ -49,12 +49,7 @@ public function getMethods(): array public function getMethod(string $name): Method { - $m = $this->methods[strtolower($name)] ?? null; - if (!$m) { - throw new Nette\InvalidArgumentException("Method '$name' not found."); - } - - return $m; + return $this->methods[strtolower($name)] ?? throw new Nette\InvalidArgumentException("Method '$name' not found."); } diff --git a/src/PhpGenerator/Traits/PropertiesAware.php b/src/PhpGenerator/Traits/PropertiesAware.php index ead392de..2bc958cf 100644 --- a/src/PhpGenerator/Traits/PropertiesAware.php +++ b/src/PhpGenerator/Traits/PropertiesAware.php @@ -44,11 +44,7 @@ public function getProperties(): array public function getProperty(string $name): Property { - if (!isset($this->properties[$name])) { - throw new Nette\InvalidArgumentException("Property '$name' not found."); - } - - return $this->properties[$name]; + return $this->properties[$name] ?? throw new Nette\InvalidArgumentException("Property '$name' not found."); }