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

Minor project style improvements #129

Draft
wants to merge 5 commits into
base: 1.5.x
Choose a base branch
from

Conversation

mvorisek
Copy link
Contributor

@mvorisek mvorisek commented Jun 6, 2024

submitting as a separate PR as requested

@mvorisek mvorisek changed the title Minor project CS improvements Minor project style improvements Jun 6, 2024
@mvorisek mvorisek marked this pull request as ready for review June 6, 2024 12:44
if("cli" !== php_sapi_name()) {
use Doctrine\SqlFormatter\SqlFormatter;

if('cli' !== php_sapi_name()) {
Copy link
Member

Choose a reason for hiding this comment

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

This kind of CS change should be handled by PHPCS. Can we please configure PHPCS so that it runs on the files you've changed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@greg0ire you are an CI expect, might I know why the phpcs is not working for examples/ and for bin/?

examples/ - they are added in https://github.com/doctrine/sql-formatter/blob/e1e39d8f4c/phpcs.xml.dist#L22 and ending with .php, but it seems they are completely ignored as for ex. constants like in https://github.com/doctrine/sql-formatter/blob/e1e39d8f4c/examples/cli.php#L10 are not added to uses.

bin/ - the file does not end with .php but a full path is specified - it seems ignored currently as well as I would expect the php_sapi_name() in https://github.com/doctrine/sql-formatter/blob/e1e39d8f4c/bin/sql-formatter#L6 to be replaced with a constant.

Copy link
Member

Choose a reason for hiding this comment

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

It works, it's just that you did not spot

<rule ref="Generic.Files.InlineHTML">
<exclude-pattern>examples/*.php</exclude-pattern>
<exclude-pattern>tests/performance.php</exclude-pattern>
</rule>
<!-- The sniff does not detect usages for some reason -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<exclude-pattern>examples/*.php</exclude-pattern>
</rule>
<!-- The sniff attempts to badly format templating syntax end blocks -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountAfterControlStructure">
<exclude-pattern>examples/*.php</exclude-pattern>
</rule>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I spot the config but found UnusedUses rule not relevant...

So in examples/ - InlineHTML is still preventing any CS rules when a single inline HTML/PHP is found?

And in bin/ the CS rules are still not applied.

Copy link
Member

Choose a reason for hiding this comment

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

Well in bin, there are no files ending with .php 🤷‍♂️

Copy link
Member

Choose a reason for hiding this comment

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

InlineHTML is still preventing any CS rules when a single inline HTML/PHP is found?

You don't need a working Github CI to figure that out, do you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well in bin, there are no files ending with .php 🤷‍♂️

In the config, I am using <file>bin/sql-formatter</file>, so I wonder how to do that, I need a help in this topic, IDK the solution myself.

Copy link
Member

Choose a reason for hiding this comment

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

README.md Outdated Show resolved Hide resolved
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.

4 participants