Skip to content

Commit

Permalink
Add PHP_CodeSniffer
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanphp committed Jan 30, 2024
1 parent a58b3b3 commit 7d6b8f4
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PHP code quality

on:
push:
branches:
- master
paths-ignore:
- README.md
pull_request:
workflow_dispatch:

jobs:
run:
runs-on: ubuntu-latest
name: PHP_CodeSniffer
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: cs2pr, phpcs

- name: Run phpcs
run: phpcs -q --report=checkstyle . | cs2pr
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
php-version: ${{ matrix.php-version }}
tools: composer:v2

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# PHP PASSBOOK LIBRARY

[![CircleCI](https://circleci.com/gh/eymengunay/php-passbook.svg?style=shield)](https://circleci.com/gh/eymengunay/php-passbook)
[![Code Coverage](https://scrutinizer-ci.com/g/eymengunay/php-passbook/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/eymengunay/php-passbook/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/eymengunay/php-passbook/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/eymengunay/php-passbook/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/eymengunay/php-passbook/badges/build.png?b=master)](https://scrutinizer-ci.com/g/eymengunay/php-passbook/build-status/master)
[![Total Downloads](https://img.shields.io/packagist/dt/eo/passbook.svg)](https://packagist.org/packages/eo/passbook)
[![Latest Stable Version](https://img.shields.io/packagist/v/eo/passbook.svg)](https://packagist.org/packages/eo/passbook)

Expand Down Expand Up @@ -49,7 +51,7 @@ This example will create a pass of type Ticket and will save the pkpass file in
* [Obtain a Pass Type Identifier and Team Identifier from Apple](#obtaining-the-pass-type-identifier-and-team-id)
* Get an icon (29x29 png file) for the pass
* Specify a name for your organization
* Specify the output path where the pass will be saved
* Specify the output path where the pass will be saved

```php
<?php
Expand Down
38 changes: 38 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Passbook">

<rule ref="PSR12">
<!-- We don't have line length (line width) limits. -->
<exclude name="Generic.Files.LineLength"/>
</rule>

<!-- display progress -->
<arg value="p"/>
<arg name="colors"/>

<!-- No lines with only whitespace -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>

<!-- Ensure 1 blank line before and after functions, except at the top and bottom. -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0" />
<property name="spacingAfterLast" value="0" />
</properties>
</rule>

<rule ref="Squiz.WhiteSpace.MemberVarSpacing">
<properties>
<property name="spacing" value="1"/>
<property name="spacingBeforeFirst" value="0" />
</properties>
</rule>

<exclude-pattern>/vendor/*</exclude-pattern>

</ruleset>

0 comments on commit 7d6b8f4

Please sign in to comment.