Skip to content

Commit

Permalink
removed useless type juggling and checking
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 25, 2017
1 parent 0d95852 commit 52ba64f
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Application/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function run(): void
public function createInitialRequest(): Request
{
$request = $this->router->match($this->httpRequest);
if (!$request instanceof Request) {
if (!$request) {
throw new BadRequestException('No route for HTTP request.');
}
return $request;
Expand Down
2 changes: 1 addition & 1 deletion src/Application/PresenterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getPresenterClass(string &$name): string
return $this->cache[$name];
}

if (!is_string($name) || !Nette\Utils\Strings::match($name, '#^[a-zA-Z\x7f-\xff][a-zA-Z0-9\x7f-\xff:]*\z#')) {
if (!Nette\Utils\Strings::match($name, '#^[a-zA-Z\x7f-\xff][a-zA-Z0-9\x7f-\xff:]*\z#')) {
throw new InvalidPresenterException("Presenter name must be alphanumeric string, '$name' is invalid.");
}

Expand Down
2 changes: 1 addition & 1 deletion src/Application/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function isMethod(string $method): bool
*/
public function setFlag(string $flag, bool $value = TRUE)
{
$this->flags[$flag] = (bool) $value;
$this->flags[$flag] = $value;
return $this;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Application/Responses/RedirectResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class RedirectResponse implements Nette\Application\IResponse
*/
public function __construct(string $url, int $code = Http\IResponse::S302_FOUND)
{
$this->url = (string) $url;
$this->code = (int) $code;
$this->url = $url;
$this->code = $code;
}


Expand Down
2 changes: 1 addition & 1 deletion src/Application/UI/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function validateParent(Nette\ComponentModel\IContainer $parent): void
protected function tryCall(string $method, array $params): bool
{
$rc = $this->getReflection();
if ($rc->hasMethod((string) $method)) {
if ($rc->hasMethod($method)) {
$rm = $rc->getMethod($method);
if ($rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic()) {
$this->checkRequirements($rm);
Expand Down
7 changes: 1 addition & 6 deletions src/Application/UI/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ public function setTemplateFactory(ITemplateFactory $templateFactory)
public function getTemplate(): ITemplate
{
if ($this->template === NULL) {
$value = $this->createTemplate();
if (!$value instanceof ITemplate && $value !== NULL) {
$class2 = get_class($value); $class = get_class($this);
throw new Nette\UnexpectedValueException("Object returned by $class::createTemplate() must be instance of Nette\\Application\\UI\\ITemplate, '$class2' given.");
}
$this->template = $value;
$this->template = $this->createTemplate();
}
return $this->template;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Application/UI/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function getAction(bool $fullyQualified = FALSE): string
*/
public function changeAction(string $action): void
{
if (is_string($action) && Nette\Utils\Strings::match($action, '#^[a-zA-Z0-9][a-zA-Z0-9_\x7f-\xff]*\z#')) {
if (Nette\Utils\Strings::match($action, '#^[a-zA-Z0-9][a-zA-Z0-9_\x7f-\xff]*\z#')) {
$this->action = $action;
$this->view = $action;
} else {
Expand All @@ -396,7 +396,7 @@ public function getView(): string
*/
public function setView(string $view)
{
$this->view = (string) $view;
$this->view = $view;
return $this;
}

Expand Down Expand Up @@ -629,7 +629,7 @@ public function forward($destination, $args = []): void
public function redirectUrl(string $url, int $code = NULL): void
{
if ($this->isAjax()) {
$this->payload->redirect = (string) $url;
$this->payload->redirect = $url;
$this->sendPayload();

} elseif (!$code) {
Expand Down

0 comments on commit 52ba64f

Please sign in to comment.