|
3 | 3 | <property name="tmp" value="/tmp" /> |
4 | 4 | <property name="package" value="${phing.project.name}" override="true" /> |
5 | 5 | <property name="builddir" value="${tmp}/build/${phing.project.name}" override="true" /> |
6 | | - <property name="basedir" value="${project.basedir}" override="true" /> |
7 | | - <property name="srcdir" value="${basedir}/src/RecordManager" override="true" /> |
| 6 | + <property name="srcdir" value="${project.basedir}" override="true" /> |
8 | 7 | <property name="phpunit_extra_params" value="" /> |
9 | 8 |
|
10 | 9 | <!-- Main Target --> |
|
19 | 18 | <phingcall target="php-cs-fixer-dryrun"/> |
20 | 19 | <phingcall target="psalm"/> |
21 | 20 | <phingcall target="phpstan-console"/> |
| 21 | + <phingcall target="rector-console"/> |
22 | 22 | </target> |
23 | 23 |
|
24 | 24 | <!-- Fix PHP Tasks --> |
25 | 25 | <target name="fix-php" description="quality assurance php tasks"> |
| 26 | + <!-- Rector may introduce style issues, so run it first --> |
| 27 | + <phingcall target="rector"/> |
26 | 28 | <phingcall target="php-cs-fixer"/> |
27 | 29 | <phingcall target="phpcbf"/> |
28 | 30 | </target> |
|
41 | 43 | <mkdir dir="${builddir}/reports/coverage"/> |
42 | 44 | </then> |
43 | 45 | </if> |
44 | | - <exec executable="${basedir}/vendor/bin/phpunit" passthru="true" checkreturn="true"> |
45 | | - <arg line="-c ${basedir}/tests/phpunit.xml --display-deprecations --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/ ${basedir}/tests ${phpunit_extra_params}" /> |
| 46 | + <exec executable="${srcdir}/vendor/bin/phpunit" passthru="true" checkreturn="true"> |
| 47 | + <arg line="-c ${srcdir}/tests/phpunit.xml --display-all-issues --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/ ${srcdir}/tests ${phpunit_extra_params}" /> |
46 | 48 | <env name="XDEBUG_MODE" value="coverage" /> |
47 | 49 | </exec> |
48 | 50 | </target> |
49 | 51 | <target name="phpunitfast" description="Run tests"> |
50 | | - <exec executable="${basedir}/vendor/bin/phpunit" passthru="true" checkreturn="true" > |
51 | | - <arg line="-c ${basedir}/tests/phpunit.xml --display-deprecations ${basedir}/tests ${phpunit_extra_params}" /> |
| 52 | + <exec executable="${srcdir}/vendor/bin/phpunit" passthru="true" checkreturn="true" > |
| 53 | + <arg line="-c ${srcdir}/tests/phpunit.xml --display-all-issues ${srcdir}/tests ${phpunit_extra_params}" /> |
52 | 54 | </exec> |
53 | 55 | </target> |
54 | 56 |
|
55 | 57 | <!-- PHP CodeSniffer --> |
56 | 58 | <target name="phpcbf"> |
57 | | - <exec executable="${basedir}/vendor/bin/phpcbf" escape="false" passthru="true" checkreturn="true"> |
58 | | - <arg line="--standard=${basedir}/tests/phpcs.xml" /> |
| 59 | + <!-- Run phpcs first to find any problems (faster than phpcbf): --> |
| 60 | + <exec executable="${srcdir}/vendor/bin/phpcs" escape="false" returnProperty="phpcs_retval" outputProperty="phpcs_output"> |
| 61 | + <arg line="--cache=${srcdir}/tests/phpcs.cache.json --standard=${srcdir}/tests/phpcs.xml" /> |
| 62 | + </exec> |
| 63 | + <if> |
| 64 | + <not><equals arg1="${phpcs_retval}" arg2="0" /></not> |
| 65 | + <then> |
| 66 | + <echo msg="Trying to fix the following issues: " /> |
| 67 | + <echo msg="${phpcs_output}" /> |
| 68 | + <!-- Extract file names from phpcs output: --> |
| 69 | + <property name="phpcbf_filelist" value="${phpcs_output}"> |
| 70 | + <filterchain> |
| 71 | + <linecontainsregexp> |
| 72 | + <regexp pattern="^FILE: (.*)" /> |
| 73 | + </linecontainsregexp> |
| 74 | + <striplinebreaks /> |
| 75 | + <replaceregexp> |
| 76 | + <regexp pattern="FILE: " replace=" " /> |
| 77 | + </replaceregexp> |
| 78 | + </filterchain> |
| 79 | + </property> |
| 80 | + <!-- Finally, run phpcbf: --> |
| 81 | + <exec executable="${srcdir}/vendor/bin/phpcbf" escape="false" passthru="true"> |
| 82 | + <arg line="--standard=${srcdir}/tests/phpcs.xml ${phpcbf_filelist}" /> |
| 83 | + </exec> |
| 84 | + </then> |
| 85 | + </if> |
| 86 | + </target> |
| 87 | + |
| 88 | + |
| 89 | + <target name="phpcbf"> |
| 90 | + <exec executable="${srcdir}/vendor/bin/phpcbf" escape="false" passthru="true" checkreturn="true"> |
| 91 | + <arg line="--standard=${srcdir}/tests/phpcs.xml" /> |
59 | 92 | </exec> |
60 | 93 | </target> |
61 | 94 | <target name="phpcs"> |
62 | | - <exec executable="${basedir}/vendor/bin/phpcs" escape="false" passthru="true" checkreturn="true"> |
63 | | - <arg line="-s --standard=${basedir}/tests/phpcs.xml" /> |
| 95 | + <exec executable="${srcdir}/vendor/bin/phpcs" escape="false" passthru="true" checkreturn="true"> |
| 96 | + <arg line="-s --standard=${srcdir}/tests/phpcs.xml" /> |
64 | 97 | </exec> |
65 | 98 | </target> |
66 | 99 |
|
67 | 100 | <!-- php-cs-fixer (first task applies fixes, second task simply checks if they are needed) --> |
68 | 101 | <target name="php-cs-fixer"> |
69 | | - <exec executable="${basedir}/vendor/bin/php-cs-fixer" passthru="true" escape="false"> |
70 | | - <arg line="fix --config=${basedir}/tests/recordmanager.php-cs-fixer.php -vvv" /> |
| 102 | + <exec executable="${srcdir}/vendor/bin/php-cs-fixer" passthru="true" escape="false"> |
| 103 | + <arg line="fix --config=${srcdir}/tests/recordmanager.php-cs-fixer.php -vvv" /> |
71 | 104 | </exec> |
72 | 105 | </target> |
73 | 106 | <target name="php-cs-fixer-dryrun"> |
74 | | - <exec executable="${basedir}/vendor/bin/php-cs-fixer" passthru="true" escape="false" checkreturn="true"> |
75 | | - <arg line="fix --config=${basedir}/tests/recordmanager.php-cs-fixer.php --dry-run -vvv --diff" /> |
| 107 | + <exec executable="${srcdir}/vendor/bin/php-cs-fixer" passthru="true" escape="false" checkreturn="true"> |
| 108 | + <arg line="fix --config=${srcdir}/tests/recordmanager.php-cs-fixer.php --dry-run -vvv --diff" /> |
| 109 | + </exec> |
| 110 | + </target> |
| 111 | + |
| 112 | + <!-- Rector --> |
| 113 | + <target name="rector-console"> |
| 114 | + <exec executable="${srcdir}/vendor/bin/rector" escape="false" passthru="true" checkreturn="true"> |
| 115 | + <arg line="--config=${srcdir}/tests/rector.php --dry-run" /> |
| 116 | + </exec> |
| 117 | + </target> |
| 118 | + <target name="rector"> |
| 119 | + <exec executable="${srcdir}/vendor/bin/rector" escape="false" passthru="true" checkreturn="true"> |
| 120 | + <arg line="--config=${srcdir}/tests/rector.php" /> |
76 | 121 | </exec> |
77 | 122 | </target> |
78 | 123 |
|
79 | 124 | <!-- Report rule violations with PHPMD (mess detector) --> |
80 | 125 | <target name="phpmd"> |
81 | 126 | <echo>Make sure you have phpmd installed in path. It's not installed by default due to its dependencies.</echo> |
82 | 127 | <exec executable="phpmd"> |
83 | | - <arg line="${srcdir} html ${basedir}/tests/phpmd.xml --reportfile ${basedir}/reports/phpmd.html" /> |
| 128 | + <arg line="${srcdir}/src html ${srcdir}/tests/phpmd.xml --reportfile ${srcdir}/reports/phpmd.html" /> |
84 | 129 | </exec> |
85 | 130 | </target> |
86 | 131 |
|
87 | 132 | <!-- Psalm --> |
88 | 133 | <target name="psalm"> |
89 | | - <exec executable="${basedir}/vendor/bin/psalm" escape="false" passthru="true" checkreturn="true"> |
| 134 | + <exec executable="${srcdir}/vendor/bin/psalm" escape="false" passthru="true" checkreturn="true"> |
90 | 135 | <!-- threads=1 is a workaround for "Fatal error: Maximum execution time of 0 seconds exceeded" with macOS--> |
91 | 136 | <arg line="--threads=1 --diff" /> |
92 | 137 | </exec> |
93 | 138 | </target> |
94 | 139 | <target name="psalm-info"> |
95 | | - <exec executable="${basedir}/vendor/bin/psalm" escape="false" passthru="true" checkreturn="true"> |
| 140 | + <exec executable="${srcdir}/vendor/bin/psalm" escape="false" passthru="true" checkreturn="true"> |
96 | 141 | <!-- threads=1 is a workaround for "Fatal error: Maximum execution time of 0 seconds exceeded" with macOS--> |
97 | 142 | <arg line="--threads=1 --diff --show-info=true" /> |
98 | 143 | </exec> |
99 | 144 | </target> |
100 | 145 |
|
101 | 146 | <!-- Phpstan --> |
102 | 147 | <target name="phpstan-console"> |
103 | | - <exec executable="${basedir}/vendor/bin/phpstan.phar" escape="false" passthru="true" checkreturn="true"> |
104 | | - <arg line="--configuration=${basedir}/tests/phpstan.neon --memory-limit=2G analyse" /> |
| 148 | + <exec executable="${srcdir}/vendor/bin/phpstan.phar" escape="false" passthru="true" checkreturn="true"> |
| 149 | + <arg line="--configuration=${srcdir}/tests/phpstan.neon --memory-limit=2G analyse" /> |
105 | 150 | </exec> |
106 | 151 | </target> |
107 | 152 | </project> |
0 commit comments