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 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 master branch 3 times, most recently from 4248460 to 2378ea6 Compare Jul 19, 2019
@dg
Copy link
Member

@dg dg commented Jul 19, 2019

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

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

Successfully merging this pull request may close these issues.

None yet

2 participants