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

refactor: use ::class to config() param #7611

Merged
merged 1 commit into from
Jun 26, 2023

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Jun 24, 2023

Description
::class keyword is better than string for IDE or static analysis.

Checklist:

  • Securely signed commits
  • [] Component(s) with PHPDoc blocks, only if necessary or adds value
  • [] Unit testing, with >80% coverage
  • [] User guide updated
  • Conforms to style guide

@kenjis kenjis added the refactor Pull requests that refactor code label Jun 24, 2023
Copy link

@TimexPeachtree TimexPeachtree left a comment

Choose a reason for hiding this comment

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

Code looks great for refactor more concise.
want to check if this has going to be in a major update 4.4.x or within 4.3.x

@kenjis
Copy link
Member Author

kenjis commented Jun 24, 2023

develop means 4.3.x now.

@mostafakhudair
Copy link
Contributor

Why should the framework care about the IDE?
::class means more code line.

@datamweb
Copy link
Contributor

Why should the framework care about the IDE?

Because it guides the developers. and provides more details when programming.

@kenjis
Copy link
Member Author

kenjis commented Jun 25, 2023

  1. If we use ::class, IDE can navigate us to the Config property.
    Screenshot 2023-06-26 7 34 28

  2. When we use ::class, IDE can autocomplete the classname.
    Screenshot 2023-06-26 7 37 53

@kenjis
Copy link
Member Author

kenjis commented Jun 25, 2023

::class means more code line.

If you mean use statements like use Config\Exceptions;,
I think it is better to write all use statements for all dependencies.
Then all classes on which this class depends will be visible.
Too many usesstatements mean too many dependencies, which may be an issue in class design.

config('classname') hides the dependency.

And if you use IDE, the use statement will be added automatically.

@kenjis kenjis merged commit 3bb0831 into codeigniter4:develop Jun 26, 2023
@kenjis kenjis deleted the refactor-config-classname branch June 26, 2023 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Pull requests that refactor code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants