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

Added DontInstantiate to the supported traits #33

Merged
merged 1 commit into from
Nov 24, 2021

Conversation

vudaltsov
Copy link
Contributor

This is useful for static helpers.

There are two ways to implement this:

  1. final private constructor, which will natively throw an instance of Error on instantiation attempt,
  2. final public constructor with a custom NonInstantiatableObject exception like in other traits.

I've decided to implement the first one, since it's a native approach and also PhpStorm automatically removes such classes from new ... autocompletion.

I didn't add DontInstantiate to JustDont, because it obviously breaks BC and also because it makes JustDont unusable in most situations.

@vudaltsov
Copy link
Contributor Author

@Ocramius , any comments on this? Does this trait make sense for the library?

Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Ocramius Ocramius added this to the 1.4.0 milestone Nov 24, 2021
@Ocramius Ocramius self-assigned this Nov 24, 2021
@Ocramius
Copy link
Member

Sorry @vudaltsov, I had totally missed reviewing this!

@Ocramius Ocramius changed the title Added DontInstantiate Added DontInstantiate to the supported traits Nov 24, 2021
@Ocramius Ocramius merged commit 0291081 into Roave:1.4.x Nov 24, 2021
@vudaltsov vudaltsov deleted the dont-instantiate branch November 24, 2021 13:15
@vudaltsov
Copy link
Contributor Author

No problem, thank you!

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

Successfully merging this pull request may close these issues.

2 participants