CodeIgniter Forums
How to set CodeIgniter 4 coding standard in a phpcs.xml file ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forum-31.html)
+--- Thread: How to set CodeIgniter 4 coding standard in a phpcs.xml file ? (/thread-71998.html)



How to set CodeIgniter 4 coding standard in a phpcs.xml file ? - bvrignaud - 10-24-2018

Hello,

I'm working on IonAuth for CI4 : https://github.com/bvrignaud/CodeIgniter-Ion-Auth/tree/4

I'm trying to set travis jobs.

I have problems with the CodeIgniter coding standard implementation (https://github.com/bcit-ci/CodeIgniter4-Standard).

If I run on command line :
Code:
$ vendor/bin/phpcs --standard=vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 .
It's OK.

But if I set a phpcs.xml.dist with :
Code:
<rule ref="vendor/codeigniter4/codeigniter4-standard/CodeIgniter4/" />
And run it with :
Code:
$ vendor/bin/phpcs

I have this error : PHP Fatal error:  Class 'CodeIgniter4\Sniffs\PHP\ForbiddenFunctionsSniff' not found in /home/benoit/MesProjets/Lab/ci4/src/CodeIgniter-Ion-Auth/vendor/codeigniter4/codeigniter4-standard/CodeIgniter4/Sniffs/PHP/DiscouragedFunctionsSniff.php on line 24

Any ideas ?

Thanks


RE: How to set CodeIgniter 4 coding standard in a phpcs.xml file ? - louisl - 11-11-2018

I haven't had a chance to look at the standard for about a year since writing it, I see things are moving along with CodeIgniter 4 now so I expect things to start heating up soon, my day jobs been ridiculously busy this past year so I've not chased for updates.

Meanwhile I did do an example travis build way back, so this might be helpful. https://github.com/louisl/CodeIgniter4/blob/feature/travis-codesniffer/.travis.yml

I expect the standard probably needs to change a bit since writing, but I've not had instructions as of yet.


RE: How to set CodeIgniter 4 coding standard in a phpcs.xml file ? - ciadmin - 11-11-2018

We have added a git commit pre-hook, so if you are using the latest develop branch, you should end up with phpcs automatically applied as part of each commit.


RE: How to set CodeIgniter 4 coding standard in a phpcs.xml file ? - louisl - 11-11-2018

(11-11-2018, 03:25 PM)ciadmin Wrote: We have added a git commit pre-hook, so if you are using the latest develop branch, you should end up with phpcs automatically applied as part of each commit.

Hi Jim, Nice one, I need to catch up asap I think!. I'm still about if you need me, Just busy as hell. Sad


RE: How to set CodeIgniter 4 coding standard in a phpcs.xml file ? - ciadmin - 11-11-2018

@louisl I think the sniffer rules will need revisiting - they are causing some small degree of havoc and questionable reformatting when used with phpcbf. We are going with the flow for now, and will probably look to do some improvements once we get to the beta.

I think we are all busy, each for different reasons Undecided


RE: How to set CodeIgniter 4 coding standard in a phpcs.xml file ? - bvrignaud - 12-19-2018

I found a solution with this phpcs.xml :
Code:
<?xml version="1.0" encoding="utf-8" ?>
<rulset name="My Project">
    <config name="installed_paths" value="vendor/codeigniter4/codeigniter4-standard/CodeIgniter4"/>
    <description></description>

    <file>application</file>
    <file>tests/app</file>

    <rule ref="vendor/codeigniter4/codeigniter4-standard/CodeIgniter4/ruleset.xml"/>
</rulset>



RE: How to set CodeIgniter 4 coding standard in a phpcs.xml file ? - puschie - 12-21-2018

would be nice if you could make a PR for this
have same problem and the pre-hook doesnt work on windows