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

[11.x] Add the --strict option to make:class command #51260

Closed
wants to merge 6 commits into from

Conversation

saMahmoudzadeh
Copy link
Contributor

@saMahmoudzadeh saMahmoudzadeh commented May 1, 2024

This PR, aims to add the --strict option to the make:class command. this option empowers developers to craft Laravel classes with strict typing, thereby harnessing the full potential of PHP's additional features.

The aim is to give developers the option to choose whether to be in strict mode or not?

Example

php artisan make:class MyClass --strict
php artisan make:class MyInokableClass --invokable --strict

The phrase declare(strict_types=1); at the beginning of the generated classes signifies that strict typing mode is enabled.

Tests

Adding tests related to the --strict option and applying strict typing to ensure the correctness of these changes.

Thanks!

Copy link

github-actions bot commented May 1, 2024

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@saMahmoudzadeh saMahmoudzadeh marked this pull request as ready for review May 1, 2024 19:08
@ahinkle
Copy link
Contributor

ahinkle commented May 2, 2024

Duplicate of #50349

@saMahmoudzadeh
Copy link
Contributor Author

saMahmoudzadeh commented May 2, 2024

Hi @ahinkle

This PR ( #50349 ) you mentioned mandates strict mode. However, my PR is optional. That is, the developer had the option to choose whether to select strict mode or not?

This Pull request is only focused on the classes that the user creates through make:class and that too is completely optional for the developer and is not the default. That is, the user must definitely use --strict, but your case indicated it was default and mandatory.

So, the user can optionally use --strict. This approach is a gradual shift towards strict typing.

It means it's better to initially encourage users to opt for strict typing optionally rather than directly modifying the core, which is high-risk.

Thanks!

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!

If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.

@saMahmoudzadeh saMahmoudzadeh deleted the feature/strict branch May 2, 2024 15:07
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

Successfully merging this pull request may close these issues.

None yet

3 participants