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

chore: introduce phpcs and phpstan #159

Merged
merged 6 commits into from May 21, 2024
Merged

Conversation

Levdbas
Copy link
Member

@Levdbas Levdbas commented May 2, 2024

Related:

Issue

Since the creation of the starter theme a lot has happened in PHP, WordPress and Timber. I want to make the starter-theme a more modern starting point for custom theme development.

As mentioned by @szepeviktor in #147 (comment), it's a good idea to introduce a coding style.

I would like the help of you @szepeviktor and @gchtr to help me enhance the introduction of these two tools. This is my first time introducing them in a project, so any help/tips are welcome.

I want to start linting file and introduce taskrunners when we have the overhaul with all the other PRs in place. So linting would be a final step as I see it now.

Solution

Introduce phpcs and phpstan so we can start linting files.

Impact

A coding style to adhere to is always great.

Usage Changes

No

Considerations

I just plucked some configurations from the internet and that can be improved of course, please help out 🗡️

Testing

no

@Levdbas
Copy link
Member Author

Levdbas commented May 3, 2024

Hi @szepeviktor , especially looking for your feedback on this!

@szepeviktor
Copy link
Contributor

@Levdbas What is the current error count?

@Levdbas
Copy link
Member Author

Levdbas commented May 3, 2024

@Levdbas What is the current error count?

Currently 30 PHPstan issues but most of them will be fixed by #152 by the correct use. I now also was able to scan the files in the root directory by changing the config a bit.

@Levdbas
Copy link
Member Author

Levdbas commented May 14, 2024

@szepeviktor , Lukas and I discussed the PHP cs rulesets. Could you advice in how to implement https://github.com/szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset while keep the possibility that users can add their own rules? I am pretty new to the whole ruleset creation thing so any help is appreciated!

@szepeviktor
Copy link
Contributor

szepeviktor commented May 14, 2024

I am pretty new to the whole ruleset creation thing so any help is appreciated!

A ruleset is simply one XML file with rules listed in it.

@szepeviktor
Copy link
Contributor

One can disable an existing rule or add a new one in the theme.

@szepeviktor
Copy link
Contributor

Could you advice in how to implement

BTW This frankenstein is dangerous. It wears out your keyboard and your brain.

@Levdbas Levdbas mentioned this pull request May 20, 2024
@Levdbas
Copy link
Member Author

Levdbas commented May 20, 2024

Updated the PHPCS ruleset base

phpcs.xml.dist Outdated Show resolved Hide resolved
@gchtr
Copy link
Member

gchtr commented May 21, 2024

@Levdbas Thanks for the update. I think it’s good to use a standard like the 10up standard. It means less work for us. And the phpcs.xml.dist looks a bit more accessible now.

In my opinion, it’s easy to spot that we load in a standard through Composer which is then applied in phpcs.xml.dist. This also makes it easy to swap it out with another standard of your choice.

@Levdbas Levdbas merged commit b8dd129 into 2.x May 21, 2024
6 checks passed
@Levdbas Levdbas deleted the chore-introduce-code-styles branch May 21, 2024 15:20
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