Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant $service variable in case of simply service without dependencies. #206

Conversation

@janbarasek
Copy link
Contributor

janbarasek commented Jul 18, 2019

In case of:

public function createServiceMyService(): Model\MyService
{
	$service = new Model\MyService;
	return $service;
}

Generate simplify version:

public function createServiceMyService(): Model\MyService
{
	return new Model\MyService;
}

And in case of simple static service:

public function createServiceMyService(): Model\MyService
{
	$service = Model\MyServiceFactory::getInstance();
	return $service;
}

Generate:

public function createServiceMyService(): Model\MyService
{
	return Model\MyServiceFactory::getInstance();
}
janbarasek added 2 commits Jul 18, 2019
…dependencies.

In case of:

```php
public function createServiceMyService(): Model\MyService
{
	$service = new Model\MyService;
	return $service;
}
```

Generate simplify version:

```php
public function createServiceMyService(): Model\MyService
{
	return new Model\MyService;
}
```

And in case of simple static service:

```php
public function createServiceMyService(): Model\MyService
{
	$service = Model\MyServiceFactory::getInstance();
	return $service;
}
```

Generate:

```
public function createServiceMyService(): Model\MyService
{
	return Model\MyServiceFactory::getInstance();
}
```
@dg dg force-pushed the nette:master branch 3 times, most recently from 4248460 to 2378ea6 Jul 19, 2019
@dg

This comment has been minimized.

Copy link
Member

dg commented Jul 19, 2019

I think it would be cleaner to deal with this in ServiceDefinition::generateMethod()

@dg dg force-pushed the nette:master branch 4 times, most recently from fecd1fb to 15978c3 Jul 19, 2019
dg added a commit that referenced this pull request Jul 24, 2019
@dg dg closed this in 0112da4 Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.