Code Monkey home page Code Monkey logo

coding-standards's Introduction

Some custom PHP sniffs for Drupal / PHP Projects

Provide some custom PHP Sniffs for the Drupal / PHP based projects.

How to add this to project

In project root composer.json file, add below entry under repositories section -

"type": "git",
"url": "[email protected]:joshirohit100/coding-standards.git"

Then run the composer require command

composer require joshirohit100/coding-standards

Sniffs

DrupalLibraryVersionPattern

Provides a sniff to check the version key in the drupal *.libraries.yml files. Sample library definition

test.my_library:
    version: 1.x
    js:
        somejsfilepath/jsfile.js

This will fail the sniff because library version is not proper like 1.0.0 (check for only number and dot in library version)

To add this sniff in project, just add below in phpcs.xml file

<rule ref="DrupalLibraryVersionPattern"/>

DrupalUpdateHookSequence

Provides a sniff to check the order of update hooks in *.install file.

Update hooks should be in decreasing sequence. This means, latest version should be on top.

To add this sniff in project, just add below in phpcs.xml file

<rule ref="DrupalUpdateHookSequence"/>

DrupalHookUpdateNComment

Provides a sniff to not allow "hook_update_N()" in update hooks comment in *.install file.

To add this sniff in project, just add below in phpcs.xml file

<rule ref="DrupalHookUpdateNComment"/>

DrupalHookInstallLast

Provides a sniff to check for hook_install() should always be at bottom in file, after all update hooks.

To add this sniff in project, just add below in phpcs.xml file

<rule ref="DrupalHookInstallLast"/>

coding-standards's People

Contributors

joshirohit100 avatar

Stargazers

Swarad avatar Akram ZAIRIG avatar

Watchers

 avatar  avatar

Forkers

swarad07

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.