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

Enforce code style more strictly #1747

Open
phavekes opened this issue Nov 29, 2024 · 5 comments
Open

Enforce code style more strictly #1747

phavekes opened this issue Nov 29, 2024 · 5 comments
Labels

Comments

@phavekes
Copy link
Member

This issue is imported from pivotal - Originaly created at Oct 15, 2019 by Michiel Kodde

The last couple of PR reviews, we had some discussion about enforcing thecode style. See some tasks below.

@phavekes phavekes self-assigned this Nov 29, 2024
@phavekes
Copy link
Member Author

For typehint annotations we could use:
https://github.com/slevomat/coding-standard (bstrooband - Oct 15, 2019)

@phavekes
Copy link
Member Author

I think we should take into account that the typehints could be needed by external libraries (i.e. doctrine) (bstrooband - Oct 15, 2019)

@phavekes
Copy link
Member Author

@bstrooband I think Doctrine only relies on it\'s annotations if you choose to use Doctrine with annotations. Or do they rely on other type hints? If so I\'m most interested in a link to the documentation. (Michiel Kodde - Oct 15, 2019)

@phavekes
Copy link
Member Author

Experimented with Slevomat CS rules. I added these rules to the phpcs.xml

    <rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration" />
    <rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint" />
    <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes" />
    <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue" />

That resulted in a nice set of required changes in the src folder. Many of these can be addressed automatically via phpcbf. But this results in a non-functional set of changes. As some type hints are not correctly set on interfaces/implementations of interfaces.

Bottom line is: in order to use PHP 7 type hints on the existing code. We should update the existing code to use type hints correctly. (Michiel Kodde - Oct 21, 2019)

@phavekes
Copy link
Member Author

Created a branch that addresses some of the tasks of this story
https://github.com/OpenConext/OpenConext-engineblock/tree/feature/improve-cs

The todo on this branch is to implement PHP 7 strict types and type definitions on all classes. This is a change that should not be taken lightly. As increasing the strictness of the application might lead to unexpected errors/issues. (Michiel Kodde - Oct 21, 2019)

@phavekes phavekes removed their assignment Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant