Skip to content

Commit

Permalink
phpcs fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
torounit committed Dec 3, 2019
1 parent 3499dd7 commit 67cb715
Show file tree
Hide file tree
Showing 11 changed files with 487 additions and 109 deletions.
80 changes: 43 additions & 37 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,61 @@
language: php

php:
- 7.1.9

services:
- docker

cache:
directories:
- vendor
- $HOME/.composer/cache
dist: trusty

notifications:
email:
on_success: never
on_failure: change

cache:
directories:
- $HOME/.composer/cache

matrix:
include:
- env: PHP_VERSION=5.3 WP_VERSION=4.2.16
- env: PHP_VERSION=5.3 WP_VERSION=latest WP_PULUGIN_DEPLOY=1
- env: PHP_VERSION=5.3 WP_VERSION=trunk
- env: PHP_VERSION=7.1 WP_VERSION=4.2.16
- env: PHP_VERSION=7.1 WP_VERSION=latest
- env: PHP_VERSION=7.1 WP_VERSION=trunk

allow_failures:
- env: PHP_VERSION=5.3 WP_VERSION=trunk
- env: PHP_VERSION=7.1 WP_VERSION=trunk

- php: 7.3
env: WP_VERSION=trunk
- php: 7.3
env: WP_VERSION=latest WP_PULUGIN_DEPLOY=1
- php: 7.2
env: WP_VERSION=latest
- php: 7.1
env: WP_VERSION=latest
- php: 7.0
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=4.3
- php: 5.6
env: WP_TRAVISCI=phpcs
before_script:
- composer install
- curl -L https://raw.githubusercontent.com/torounit/wpenv/issue/support-nightly/run.sh | bash -s $PHP_VERSION $WP_VERSION
- docker exec -u root wpenv ln -s /home/ubuntu/.phpenv/shims/php /usr/local/bin/
- docker exec -u root wpenv ln -s /home/ubuntu/.phpenv/shims/composer /usr/local/bin/
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- |
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
phpenv config-rm xdebug.ini
else
echo "xdebug.ini does not exist"
fi
- |
if [[ ! -z "$WP_VERSION" ]] ; then
docker exec wpenv composer global remove "phpunit/phpunit"
if [[ ${PHP_VERSION:0:2} == "5." ]]; then
docker exec wpenv composer global require "phpunit/phpunit=4.8.*"
else
docker exec wpenv composer global require "phpunit/phpunit=5.7.*"
fi
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
composer global require "phpunit/phpunit=4.8.*|5.7.*"
fi
- |
- docker exec -u root wpenv ln -s /home/ubuntu/.phpenv/shims/phpunit /usr/local/bin/
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
composer global require wp-coding-standards/wpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
fi
script:
- docker exec wpenv composer phpcs
- docker exec wpenv phpunit
- docker exec -e WP_MULTISITE=1 wpenv phpunit

after_success: curl -L https://raw.githubusercontent.com/miya0001/travis2wpplugin/master/deploy.sh | bash
- |
if [[ ! -z "$WP_VERSION" ]] ; then
phpunit
WP_MULTISITE=1 phpunit
fi
- |
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
composer phpcs
fi
after_success:
- bash bin/deploy.sh
2 changes: 1 addition & 1 deletion PPPP/Module/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ public function pre_get_posts( WP_Query $query ) {
return;
}
}
}
}
}
}
1 change: 0 additions & 1 deletion PPPP/Module/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class PPPP_Module_Option extends PPPP_Module {
*/
public function add_hook() {
register_uninstall_hook( PPPP_PLUGIN_FILE, array( __CLASS__, 'uninstall_hook' ) );

}

/**
Expand Down
17 changes: 17 additions & 0 deletions bin/create-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -e

if [ $# -lt 1 ]; then
echo "usage: $0 <version>"
exit 1
fi

version=$1

if [ ! `echo $version | grep -e 'alpha' -e 'beta' -e 'RC' -e 'rc'` ] ; then
sed -i '' -e "s/^Stable tag: .*/Stable tag: ${version}/g" readme.txt;
fi

sed -i '' -e "s/^ \* Version: .*/ * Version: ${version}/g" pppp.php;
sed -i '' -e "s/^ \* @version .*/ * @version ${version}/g" pppp.php;
82 changes: 82 additions & 0 deletions bin/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env bash

set -e

if [[ "false" != "$TRAVIS_PULL_REQUEST" ]]; then
echo "Not deploying pull requests."
exit
fi

if [[ ! $WP_PULUGIN_DEPLOY ]]; then
echo "Not deploying."
exit
fi

if [[ ! $SVN_REPO ]]; then
echo "SVN repo is not specified."
exit
fi

# Untrailing slash of SVN_REPO path
SVN_REPO=`echo $SVN_REPO | sed -e "s/\/$//"`
# Git repository
GH_REF=https://github.com/${TRAVIS_REPO_SLUG}.git

echo "Starting deploy..."

mkdir deploy

cd deploy
BASE_DIR=$(pwd)

echo "Checking out trunk from $SVN_REPO ..."
svn co -q $SVN_REPO/trunk

echo "Getting clone from $GH_REF to $SVN_REPO ..."
git clone -q $GH_REF ./git

cd ./git

if [ -e "bin/build.sh" ]; then
echo "Starting bin/build.sh."
bash bin/build.sh
fi

cd $BASE_DIR

echo "Syncing git repository to svn"
rsync -a --exclude=".svn" --checksum --delete ./git/ ./trunk/
rm -fr ./git

cd ./trunk

if [ -e ".distignore" ]; then
echo "svn propset form .distignore"
svn propset -q -R svn:ignore -F .distignore .

else
if [ -e ".svnignore" ]; then
echo "svn propset"
svn propset -q -R svn:ignore -F .svnignore .
fi
fi

echo "Run svn add"
svn st | grep '^!' | sed -e 's/\![ ]*/svn del -q /g' | sh
echo "Run svn del"
svn st | grep '^?' | sed -e 's/\?[ ]*/svn add -q /g' | sh

# If tag number and credentials are provided, commit to trunk.
if [[ $TRAVIS_TAG && $SVN_USER && $SVN_PASS ]]; then
if [[ ! -d tags/$TRAVIS_TAG ]]; then
echo "Commit to $SVN_REPO."
svn commit -m "commit version $TRAVIS_TAG" --username $SVN_USER --password $SVN_PASS --non-interactive 2>/dev/null
echo "Take snapshot of $TRAVIS_TAG"
svn copy $SVN_REPO/trunk $SVN_REPO/tags/$TRAVIS_TAG -m "Take snapshot of $TRAVIS_TAG" --username $SVN_USER --password $SVN_PASS --non-interactive 2>/dev/null
else
echo "tags/$TRAVIS_TAG already exists."
fi
else
echo "Nothing to commit and check \`svn st\`."
svn st
fi
59 changes: 47 additions & 12 deletions codesniffer.ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,50 @@
<?xml version="1.0"?>
<ruleset>
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/WordPress-Core/ruleset.xml -->
<!-- Include the WordPress ruleset, with exclusions. -->
<rule ref="WordPress">
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" />
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
<exclude name="WordPress.VIP" />
<exclude name="Generic.Files.LowercasedFilename" />
</rule>
<ruleset name="WordPress Coding Standards based custom ruleset for your plugin">
<description>Generally-applicable sniffs for WordPress plugins.</description>

<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<!-- What to scan -->
<file>.</file>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/node_modules/</exclude-pattern>
<exclude-pattern>/wordpress/</exclude-pattern>
<exclude-pattern>/tests/</exclude-pattern>
<!-- How to scan -->
<!-- Usage instructions: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
<!-- Annotated ruleset: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<arg value="sp"/> <!-- Show sniff and progress -->
<arg name="basepath" value="./"/><!-- Strip the file paths down to the relevant bit -->
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="8"/><!-- Enables parallel processing when available for faster results. -->

<!-- Rules: Check PHP version compatibility -->
<!-- https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="5.6-"/>
<!-- https://github.com/PHPCompatibility/PHPCompatibilityWP -->
<rule ref="PHPCompatibilityWP"/>
<config name="minimum_supported_wp_version" value="4.3"/>
<rule ref="WordPress-Core">
<exclude name="WordPress.Files.FileName" />
<exclude name="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase" />
<exclude name="WordPress.NamingConventions.ValidHookName" />
<exclude name="WordPress.WP.I18n.MissingArgDomain" />
</rule>
<rule ref="WordPress-Docs"/>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. -->
<property name="prefixes" type="array" value="PPPP"/>
</properties>
</rule>
<rule ref="WordPress.WP.I18n">
<properties>
<!-- Value: replace the text domain used. -->
<property name="text_domain" type="array" value="pppp"/>
</properties>
</rule>
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing">
<properties>
<property name="blank_line_check" value="true"/>
</properties>
</rule>
</ruleset>
14 changes: 8 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@
],
"require": {},
"require-dev": {
"squizlabs/php_codesniffer": "^2.7",
"wp-coding-standards/wpcs": "^0.10"
"squizlabs/php_codesniffer": "^3.4.2",
"wp-coding-standards/wpcs": "^2.0",
"phpcompatibility/phpcompatibility-wp": "^2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0"
},
"scripts": {
"post-install-cmd": [
"@php vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs/"
"phpcs -i"
],
"post-update-cmd": [
"@php vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs/"
"fix": [
"phpcs -p -s -v -n --standard=./codesniffer.ruleset.xml --extensions=php --report-diff=changes.diff; patch -p0 -ui changes.diff; rm changes.diff"
],
"phpcs": [
"@php vendor/bin/phpcs -p -s -v -n . --standard=./codesniffer.ruleset.xml --extensions=php"
"phpcs -p -s -v -n . --standard=./codesniffer.ruleset.xml --extensions=php"
]
}
}
Loading

0 comments on commit 67cb715

Please sign in to comment.