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

SearchExtension: compatible with trait Nette\StaticClass #292

Closed
h4kuna opened this issue Aug 28, 2023 · 1 comment
Closed

SearchExtension: compatible with trait Nette\StaticClass #292

h4kuna opened this issue Aug 28, 2023 · 1 comment

Comments

@h4kuna
Copy link
Contributor

h4kuna commented Aug 28, 2023

Hello if I use trait Nette\StaticClass the extension Search automatically register the class like a service to container.

There are two ways:

  1. in trait Nette\StaticClass change visibility of constructor from final public to private. The ReflectionClass::isInstantiable will work fine. I prefer

  2. add exception for this trait to Search extension

I know if you have registered static classes, it doesn't matter, because these classes are not in constructors, but this is no reason to register in container.

Example of bad behavior:

namespace Uget;

use Nette\StaticClass;

final class Tools
{
	use StaticClass;
}

In Container i see

	public function createService017(): Uget\Tools
	{
		return new Uget\Tools; // throw exception
	}

I must add to ignore

search:
	exclude:
		classes:
			- Uget\Tools
dg added a commit to nette/utils that referenced this issue Aug 29, 2023
- ReflectionClass::isInstance() returns false
- it is marked as an error in the IDE
dg added a commit to nette/utils that referenced this issue Aug 29, 2023
- ReflectionClass::isInstance() returns false
- it is marked as an error in the IDE
dg added a commit to nette/utils that referenced this issue Aug 29, 2023
- ReflectionClass::isInstance() returns false
- it is marked as an error in the IDE
dg added a commit to nette/utils that referenced this issue Aug 29, 2023
- ReflectionClass::isInstance() returns false
- it is marked as an error in the IDE
@dg
Copy link
Member

dg commented Aug 29, 2023

Yes, it's better to use a private constructor.

dg added a commit to nette/utils that referenced this issue Sep 19, 2023
- ReflectionClass::isInstance() returns false
- it is marked as an error in the IDE
dg added a commit to nette/union that referenced this issue Sep 26, 2023
- ReflectionClass::isInstance() returns false
- it is marked as an error in the IDE

nette/utils@dd7502e
dg added a commit to nette/union that referenced this issue Oct 9, 2023
- ReflectionClass::isInstance() returns false
- it is marked as an error in the IDE

nette/utils@dd7502e
dg added a commit to nette/union that referenced this issue Oct 17, 2023
- ReflectionClass::isInstance() returns false
- it is marked as an error in the IDE

nette/utils@dd7502e
dg added a commit to nette/union that referenced this issue Oct 25, 2023
- ReflectionClass::isInstance() returns false
- it is marked as an error in the IDE

nette/utils@dd7502e
dg added a commit to nette/utils that referenced this issue Jan 17, 2024
- ReflectionClass::isInstance() returns false
- it is marked as an error in the IDE
dg added a commit to nette/union that referenced this issue May 28, 2024
- ReflectionClass::isInstance() returns false
- it is marked as an error in the IDE

nette/utils@dd7502e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants