Skip to content

Commit 0aa3f5b

Browse files
author
Vincent Langlet
committed
🔧 Automatically check style
1 parent cfa5a06 commit 0aa3f5b

File tree

2 files changed

+35
-19
lines changed

2 files changed

+35
-19
lines changed

build.properties

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
#composer
1+
# Composer
22
composer.url = http://getcomposer.org/composer.phar
33
composer.path = ${basedir}/composer.phar
44

5-
#PHP Code Sniffer
5+
# PHP Code Sniffer
6+
## Paths
7+
phpcs.bin = ${basedir}/vendor/bin/phpcs
68
phpcs.dir = ${basedir}/vendor/squizlabs/php_codesniffer
7-
phpcs.symlink.path = vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Symfony3Custom
9+
phpcs.symlink.path = ${basedir}/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Symfony3Custom
10+
11+
## This project does not respect some PSR rules
12+
phpcs.exclude.sniffs = PSR1.Files.SideEffects,PSR1.Classes.ClassDeclaration,Squiz.Classes.ValidClassName

build.xml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,50 @@
11
<project name="Symfony3-custom-coding-standard" default="test">
2-
<property file="build.properties" />
3-
<available property="composer.exists" file="${composer.path}" />
4-
<available property="symlink.exists" file="${phpcs.symlink.path}" />
2+
<property file="build.properties"/>
53

6-
<target name="test" depends="vendor,lint,phpunit" />
4+
<available property="composer.exists" file="${composer.path}"/>
5+
<available property="symlink.exists" file="${phpcs.symlink.path}"/>
76

8-
<target name="vendor" description="Load composer repositories" depends="composer">
7+
<target name="test" depends="vendor,lint,phpunit,phpcs"/>
8+
9+
<target name="vendor" depends="composer" description="Load composer repositories">
910
<exec executable="composer" failonerror="true">
10-
<arg value="install" />
11+
<arg value="install"/>
1112
</exec>
1213
</target>
1314

1415
<target name="composer" description="Download composer" unless="composer.exists">
15-
<get src="${composer.url}" dest="${composer.path}" />
16+
<get src="${composer.url}" dest="${composer.path}"/>
1617
</target>
1718

1819
<target name="lint" description="Perform syntax check">
1920
<apply executable="php" failonerror="true">
20-
<arg value="-l" />
21+
<arg value="-l"/>
2122
<fileset dir="${basedir}">
22-
<include name="**/*.php" />
23-
<exclude name="vendor/**" />
23+
<include name="**/*.php"/>
24+
<exclude name="vendor/**"/>
2425
</fileset>
2526
</apply>
2627
</target>
2728

28-
<target name="phpunit" depends="symlink-this-coding-standard" description="Run unit tests with PHPUnit">
29+
<target name="phpunit" depends="symlink-cs" description="Run unit tests with PHPUnit">
2930
<exec executable="phpunit" failonerror="true" >
30-
<arg value="--verbose" />
31-
<arg value="--filter=Symfony3Custom_*" />
32-
<arg value="${phpcs.dir}/tests/AllTests.php" />
31+
<arg value="--verbose"/>
32+
<arg value="--filter=Symfony3Custom_*"/>
33+
<arg value="${phpcs.dir}/tests/AllTests.php"/>
34+
</exec>
35+
</target>
36+
37+
<target name="phpcs" depends="symlink-cs" description="Find coding standard violations using PHP Code Sniffer">
38+
<exec executable="${phpcs.bin}" failonerror="true">
39+
<arg value="--standard=Symfony3Custom"/>
40+
<arg value="--extensions=php"/>
41+
<arg value="--ignore=vendor/*"/>
42+
<arg value="--exclude=${phpcs.exclude.sniffs}"/>
43+
<arg path="${basedir}"/>
3344
</exec>
3445
</target>
3546

36-
<target name="symlink-this-coding-standard" description="Symlink this coding standard" unless="symlink.exists">
37-
<symlink link="${basedir}/${phpcs.symlink.path}" resource="${basedir}/Symfony3Custom"/>
47+
<target name="symlink-cs" description="Symlink this coding standard" unless="symlink.exists">
48+
<symlink link="${phpcs.symlink.path}" resource="${basedir}/Symfony3Custom"/>
3849
</target>
3950
</project>

0 commit comments

Comments
 (0)