├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── RELEASE_NOTES.txt
├── Vagrantfile
├── build.xml
├── checkstyle_result
└── .gitignore
├── composer.json
├── config
├── codeigniter.cfg.xml
├── default.cfg.xml
├── sameline.cfg.xml
├── spaceindent.cfg.xml
├── symfony.cfg.xml
├── test.cfg.xml
└── zend.cfg.xml
├── html
├── README
├── css
│ └── global.css
├── images
│ ├── Logo_phpcheckstyle.png
│ ├── Logo_phpcheckstyle.svg
│ └── spacer.gif
└── template
│ ├── detail.tmpl
│ ├── detail_body.tmpl
│ ├── detail_foot.tmpl
│ ├── detail_head.tmpl
│ ├── files.tmpl
│ ├── files_body.tmpl
│ ├── files_foot.tmpl
│ ├── footer.tmpl
│ ├── header.tmpl
│ └── summary.tmpl
├── index.php
├── phpcheckstyle
├── phpcheckstyle.cmd
├── phpcheckstyle.sh
├── phpcheckstyle_sample.sh
├── phpunit.sh
├── phpunit.xml
├── run.php
├── runFromWeb.php
├── src
└── PHPCheckstyle
│ ├── Config
│ ├── CheckArrayStyleConfig.php
│ ├── CheckStyleConfig.php
│ └── CheckXMLStyleConfig.php
│ ├── Lang
│ ├── en-us.ini
│ ├── fr-fr.ini
│ └── kr.ini
│ ├── PHPCheckstyle.php
│ ├── Reporter
│ ├── ArrayReporter.php
│ ├── ConsoleReporter.php
│ ├── HTMLConsoleFormatReporter.php
│ ├── HTMLFormatReporter.php
│ ├── NullReporter.php
│ ├── PlainFormatReporter.php
│ ├── Reporter.php
│ ├── Reporters.php
│ ├── XmlConsoleFormatReporter.php
│ ├── XmlFormatReporter.php
│ └── XmlNCSSReporter.php
│ ├── StatementItem.php
│ ├── StatementStack.php
│ ├── TokenInfo.php
│ ├── Tokenizer.php
│ ├── VariableInfo.php
│ └── _Constants.php
├── test
├── AliasesTest.php
├── CommentsTest.php
├── DeprecationTest.php
├── GoodTest.php
├── IndentationTest.php
├── MetricsTest.php
├── NamingTest.php
├── OptimizationTest.php
├── OtherTest.php
├── PHPTagsTest.php
├── ProhibitedTest.php
├── StrictCompareTest.php
├── TestRunner.php
├── UnusedTest.php
└── sample
│ ├── _bad_naming.php
│ ├── bad_alias.php
│ ├── bad_comments.php
│ ├── bad_deprecation.php
│ ├── bad_indentation.php
│ ├── bad_indentation_array.php
│ ├── bad_metrics.php
│ ├── bad_optimisation.php
│ ├── bad_other.php
│ ├── bad_php_tags_end_not_needed.php
│ ├── bad_php_tags_text_after_end.php
│ ├── bad_prohibited.php
│ ├── bad_space_after_control.php
│ ├── bad_spaces.php
│ ├── bad_strictcompare.php
│ ├── bad_unused.php
│ ├── closure_in_string.php
│ ├── empty.php
│ ├── emptyline.php
│ ├── good.php
│ ├── good_anonymous_function.php
│ ├── good_do_while.php
│ ├── good_doc.php
│ ├── good_exception.php
│ ├── good_function_naming.php
│ ├── good_indentation_array.php
│ ├── good_indentation_newline.php
│ ├── good_indentation_space.php
│ ├── good_unused.php
│ ├── issue29.php
│ ├── issue48sample.php
│ ├── issue53.php
│ ├── issue55.php
│ ├── issue56.php
│ ├── issue58.php
│ ├── issue59.php
│ ├── issue61.php
│ ├── issue69.php
│ ├── issue70.php
│ ├── issue73.php
│ ├── issue78.php
│ ├── issuegithub32.php
│ ├── issuegithub40.php
│ ├── issuegithub62.php
│ ├── issuegithub65.php
│ ├── issuegithub66.php
│ ├── issuegithub89.php
│ ├── switch_multi_case.php
│ ├── t_and_equal.php
│ ├── test_unused_2.php
│ ├── todo.php
│ └── unterminated_comment.php
├── vagrant_config
└── scripts
│ ├── install_composer.sh
│ └── install_composer_libraries.sh
└── vendor
├── autoload.php
├── composer
├── ClassLoader.php
├── autoload_classmap.php
├── autoload_namespaces.php
├── autoload_psr4.php
├── autoload_real.php
├── autoload_static.php
└── platform_check.php
├── myclabs
└── deep-copy
│ └── src
│ └── DeepCopy
│ └── deep_copy.php
└── phpunit
└── phpunit
└── src
└── Framework
└── Assert
└── Functions.php
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .vagrant/
3 | composer.lock
4 | style-report/
5 | vendor/
6 | checkstyle_resultncss.xml
7 | .project
8 | .models
9 | .buildpath
10 | .settings
11 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 | php:
3 | - '5.6'
4 | - '7.0'
5 | - '7.1'
6 | before_install:
7 | - chmod +x phpunit.sh
8 | - chmod +x phpcheckstyle.sh
9 | before_script: composer update
10 | script:
11 | - ./phpunit.sh
12 | - ./phpcheckstyle.sh
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PHPCheckstyle
2 |
3 | [](https://travis-ci.org/PHPCheckstyle/phpcheckstyle)
4 |
5 | ## Overview
6 |
7 | PHPCheckstyle is an open-source tool that helps PHP programmers
8 | adhere to certain coding conventions. The tools checks the input PHP
9 | source code and reports any deviations from the coding convention.
10 |
11 | The tool uses the PEAR Coding Standards as the default coding convention.
12 | But it allows you to configure it to suit your coding standards.
13 |
14 | Please visit [https://github.com/PHPCheckstyle/phpcheckstyle/wiki](https://github.com/PHPCheckstyle/phpcheckstyle/wiki) for
15 | more information and documentation
16 |
17 |
18 | ## Requirements
19 |
20 | - PHP 5.0 or newer.
21 | - Web browser to view the checkstyle report (only for html view)
22 | - That's all.
23 |
24 |
25 | ## Installation
26 |
27 | ### Installation with Composer
28 |
29 | ```sh
30 | composer require phpcheckstyle/phpcheckstyle
31 | ```
32 |
33 | or Add `phpcheckstyle/phpcheckstyle` as a requirement to `composer.json`:
34 |
35 | ```json
36 | {
37 | "require": {
38 | "phpcheckstyle/phpcheckstyle": "dev-master"
39 | }
40 | }
41 | ```
42 |
43 | Update your packages with `composer update` or if installing from fresh, with `composer install`.
44 |
45 | ### Manual Installation
46 |
47 | Just download [https://github.com/PHPCheckstyle/phpcheckstyle/archive/master.zip](https://github.com/PHPCheckstyle/phpcheckstyle/archive/master.zip) and unzip the distribution.
48 |
49 | ```bash
50 | $> unzip PhpCheckstyle.zip
51 | ```
52 |
53 | This will create a directory called `phpcheckstyle` and expand all
54 | files in it.
55 |
56 |
57 | ### Testing with Vagrant
58 |
59 | * install [VirtualBox](https://www.virtualbox.org/)
60 | * install [Vagrant](https://www.vagrantup.com/)
61 | * launch `vagrant up` in the project root directory to start the VM
62 |
63 | * In case of problem with the "guest additions", launch :
64 |
65 | >vagrant plugin install vagrant-vbguest
66 |
67 | * to run PHPCheckstyle on itself, type `vagrant provision --provision-with run_phpcheckstyle`
68 | * to run PHPUnit, type `vagrant provision --provision-with run_phpunit`
69 | * to log inside the VM, type `vagrant ssh`
70 |
71 | ## Usage
72 |
73 | - Change directory to the PHPCheckstyle installation directory.
74 |
75 | ```bash
76 | $> cd phpcheckstyle
77 | ```
78 |
79 | - Execute the `run.php` script providing the `--src` option.
80 |
81 | ```bash
82 | $> php run.php --src
83 | ```
84 |
85 | - Use the `--help` option to see more options
86 |
87 | ```bash
88 | $> php run.php --help
89 | ```
90 |
91 |
92 | # License
93 | See [LICENSE](/LICENSE.txt)
94 |
--------------------------------------------------------------------------------
/RELEASE_NOTES.txt:
--------------------------------------------------------------------------------
1 | PHPCheckstyle Release Notes
2 | ===========================
3 |
4 |
5 | Version 0.14.9
6 | --------------
7 | * Issue #93 : Use Bootstrap4 for styling (thanks to HCrane)
8 | * Issue #94 : Add no space after control stmt test option (thanks to CharlotteDunois)
9 |
10 | Version 0.14.8
11 | --------------
12 | * Issue #92 : checkWhiteSpaceBefore "{", unless it's in ${var}
13 | * Issue #89 : False error "The function parameters must match those in its docblock @param" when using local variable tag
14 |
15 |
16 | Version 0.14.7
17 | --------------
18 | * Issue #81 : Fail to detect private functions with spaces after function (thanks to Hans-Christian Halfbrodt)
19 | * Fix square bracket for arrays on method assignation with test case. (thanks to GuillermoMI)
20 | * Add flag to force error level only on console report (thanks to Jean-Philippe Quéméner)
21 | * Issue #82 : Cannot define independent rules for function parameter namings and local variable namings (thanks to dpalic)
22 | * Issue #84 : Set maximum errors for build fail (thanks to hafah)
23 |
24 |
25 | Version 0.14.6
26 | --------------
27 | * Added config for Symfony standards
28 | * Issue #70 : List the statement types in a interface
29 | * Issue #69 : Whitespace must not follow : exception for comments
30 | * Issue #66 : Indentation level inside an array
31 | * Issue #65 : Indentation level should increase inside a case
32 | * Issue #64 : Silence doc warnings when @inheritdoc is present
33 |
34 |
35 | Version 0.14.5
36 | --------------
37 | * Issue #62 : Corrected the indentation level count for short array syntax
38 | * Issue #41 : Ability to add exceptions to "unused variable" test
39 | * Issue #24 : Grouped cases must contain a break
40 | * Issue #23 : Added a --time option on the CLI to print the processing time
41 | * Corrected line numbering for indentation check
42 | * Added PHPUnit tests
43 | * Added Vagrant configuration files to spawn a local VirtualBox VM
44 | * Added TravisCI configuration file
45 | * When running from CLI PHPCheckstyle return code is now <> 0 if some errors are detected
46 |
47 |
48 | Version 0.14.4
49 | --------------
50 | * Moved the project from SourceForge to Github
51 |
52 |
53 | Version 0.14.3
54 | --------------
55 | * New check : thisInStatic.
56 |
57 |
58 | Version 0.14.2
59 | --------------
60 | * Added a summary output on the command line (thanks to jarrettchisholm).
61 | * New check : Detect forbidden keywords (thanks to jarrettchisholm).
62 | * New check : Detect forbidden regular expressions like IP address, etc. (thanks to jarrettchisholm).
63 | * New check : Detect variable variable.
64 |
65 |
66 | Version 0.14.1
67 | --------------
68 | * Improved performances A LOT !
69 | * Better checking of ignored files/directories
70 | * Added T_FINALLY token to the parser
71 | * Better messages for logical operators && and ||
72 | * Outsourced the error messages
73 | * Added French translation
74 | * New check : NPath complexity
75 | * New check : Prefered quotes style
76 |
77 |
78 | Version 0.14.0
79 | --------------
80 | * PSR-0 Compliance (thanks to James Brooks).
81 | * new Array Reporter (thanks to James Brooks).
82 | * Allow an array of configuration values to be passed through, rather than XML (thanks to James Brooks).
83 | * Better detection of package names for NCSS report (filename by default, namespace if present).
84 | * New check : "mandatoryHeader" to verify the presence of a header for each file.
85 | * New check : "localScopeVariableLength" to verify the lenght of the variable names.
86 | NOTE : This may generate lots of new warnings.
87 |
88 |
89 | Version 0.13.2
90 | --------------
91 | * Change in the default configurations : White spaces are required before and after the concatenation operator ".".
92 | NOTE : This may generate lots of new warnings.
93 | * Issue 77: Exclude files/directories option from the web launcher.
94 |
95 |
96 | Version 0.13.1
97 | --------------
98 | * Issue 71: False positive : close()
99 | * Issue 72: Allow the config file to be in any directory
100 | * Issue 73: False positive : delete()
101 | * Issue 74: Allow multiple src directories/files in the command line.
102 |
103 |
104 | Version 0.13.0
105 | --------------
106 | * Issue 70: Simplification of the "strictCompare" rule. When active this rule will be checked everywhere.
107 | This may generate lots of warnings.
108 |
109 |
110 | Version 0.12.5
111 | --------------
112 | * Issue 69: PHP tag should be at the beginning of the line
113 |
114 |
115 | Version 0.12.4
116 | --------------
117 | * Issue 59: Enhancement: Add allowed exceptions to docBlocks section of configuration
118 | * Issue 63: Catch parsing exceptions and other PHP errors
119 | * Issue 65: Add composer.json file
120 | * Issue 66: block closure '}' detected in a string
121 |
122 |
123 | Version 0.12.3
124 | --------------
125 | * Issue 52: Config for PHP frameworks
126 | * Issue 54: Detect empty files
127 |
128 |
129 | Version 0.12.2
130 | --------------
131 | * Issue 53: else/ elseif without curly braces (thanks to Maximilian Pachl)
132 | * Added a check of the curly braces after a "else" statement
133 |
134 |
135 | Version 0.12.1
136 | --------------
137 | * Issue 50 : --exclude flag is not honoured
138 | * No space expected after '=' when used in assignation by reference
139 |
140 |
141 | Version 0.12.0
142 | --------------
143 | * New reporter : xml_console (for use with Netbeans plugin : http://sourceforge.net/projects/phpmdnb/), thanks to Jens Radtke
144 | * Issue 47 : False docBlock error when using empty return in a method
145 | * Added the version number in the run.php file
146 |
147 |
148 | Version 0.11.0
149 | --------------
150 | * Issue 1 : Refactoring of the code
151 | * Issue 43: False positive for "The function throws an exception"
152 | * Issue 41: False positive : The statement 'while' must contain its code within a {} block.
153 | * Issue 24: Line length checking of non-PHP code should be toggleable in a config option.
154 | * Added Zend Framework style configuration file
155 |
156 |
157 | Version 0.10.6
158 | --------------
159 | * Issue 40: Propose replacement for PHP aliases
160 | * Now generates absolute file path in the reports (allow Jenkins to display the source code)
161 |
162 |
163 | Version 0.10.5
164 | --------------
165 | * Issue 39: Error on closing tag for space-based indentation checks
166 | * Issue 38: False positive for : The function XXX must have a docblock comment
167 |
168 |
169 | Version 0.10.4
170 | --------------
171 | * Issue 37: Web interface (currently very limited)
172 |
173 |
174 | Version 0.10.3
175 | --------------
176 | * Issue 35: New Rule : Use of "==" in strpos
177 | * Bug correction: Not correctly counting the end of a stack item after a "ELSE IF"
178 |
179 |
180 | Version 0.10.2
181 | --------------
182 | * issue 27 : Unused code is wrongly detected
183 | * issue 26 : Empty lines in comments will corrupt line numbering
184 | * issue 25 : Error: Notice: Trying to get property of non-object
185 | * issue 23 : Wrong indentation level for curly braces on new line
186 | * Embedding of CSS inside HTML Header
187 | * Fix for null pointer exceptions when run against newer code
188 |
189 |
190 | Version 0.10.1
191 | --------------
192 | * Fixed Rule encapsedVariablesInsideString : False positive when using heredoc
193 | * Rule needBraces : False positive for do/while
194 |
195 |
196 | Version 0.10.0
197 | --------------
198 | * Added support for interfaces
199 | * Improved checking of variables by scope
200 | * Rewrote the _checkLargeLine() function
201 | * Added rudimentary progress reporting, invoked with the parameter --progress
202 | * Edited Style errors for clarity
203 | * Included regex in the error report for appropriate types
204 | * Errors are now described in much greater detail and more consistent language
205 | * Removed 'old : ' and 'new : ' prefixes from constructor name hints
206 | * New output type - html console
207 | * Removed "controlStructNeedCurly" rule, duplicate with "needBraces" rule
208 | * Completed the test cases
209 | * The tokenizer now returns T_TAB separately from T_WHITESPACE
210 |
211 | Thanks a lot to Justin Creasey and Adam King
212 |
213 |
214 | Version 0.9.8
215 | -------------
216 | * Issue 3: Check for unreachable code
217 |
218 |
219 | Version 0.9.7
220 | -------------
221 | * Deprecation of long $HTTP_*_VARS predefined variables
222 | * Configuration of system variables lists
223 | * Issue 10: Don't blindly remove first 2 chars of file path
224 |
225 |
226 | Version 0.9.6
227 | -------------
228 | * Corrected the inner assignement rule (wasn't detecting the end of a control statement if no brackets).
229 | * Corrected the file exclusion list.
230 | * Corrected a bug with nextToken at the end of a file.
231 | * Added the possibility to add exceptions to the checkVariableNaming rule
232 |
233 |
234 | Version 0.9.5
235 | -------------
236 | * Corrected a bug with @SuppressWarnings on a class.
237 |
238 |
239 | Version 0.9.4
240 | -------------
241 | * Add __invoke and __callStatic to the special functions.
242 |
243 |
244 | Version 0.9.3
245 | -------------
246 | * Refactoring of the indentation check (thanks to Charles Marion). The "noTabs" rule is replaced by the "indentation" rule.
247 | * Reactivation of the "noSpaceAfterControlStmt" rule.
248 | * Correction of a bug with multiple output files.
249 | * Added a rule for the naming of protected functions.
250 |
251 |
252 | Version 0.9.2
253 | -------------
254 | * Multiple output files (separated by a comma in the --format command line parameter)
255 |
256 |
257 | Version 0.9.1
258 | -------------
259 | * Possibility to scan multiple source directories (separated by a comma in the --src command line parameter)
260 |
261 |
262 | Version 0.9
263 | -------------
264 | * Dependency on lib_xsl removed
265 | * Documentation updated to link to the new project home (http://code.google.com/p/phpcheckstyle/)
266 | * HTML Report validated with W3C validator, HTML characters escaped
267 | * Possibility to suppress some warnings using annotations before a class or a function in the code (@SuppressWarnings)
268 | * New logo
269 |
270 |
271 | Version 0.8.11
272 | -------------
273 | * Refactoring : Added the current stack of instruction to provide contextual information
274 | * New test : unusedCode
275 | * New test : deprecated functions
276 |
277 |
278 | Version 0.8.10
279 | -------------
280 | * Corrected JavaNCSS count of packages
281 | * New test : functionInsideLoop
282 |
283 |
284 | Version 0.8.9
285 | -------------
286 | * Corrected LevelOfNesting calculation
287 | * New test : oneClassPerFile
288 |
289 |
290 | Version 0.8.8
291 | -------------
292 | * New test : variableNaming
293 | * Added the possibility to configure the regular expressions for the naming rules
294 | * A taste of it's own dog food
295 |
296 |
297 | Version 0.8.7
298 | -------------
299 | * New test : checkUnusedVariables
300 | * New test : checkUnusedFunctionParameters
301 |
302 |
303 | Version 0.8.6
304 | -------------
305 | * Correction in the controlStructOpenCurly check.
306 |
307 |
308 | Version 0.8.5
309 | -------------
310 | * New test : empty statement (;;)
311 | * New test : inner assignment
312 | * New test : unused private functions
313 |
314 |
315 | Version 0.8.4
316 | -------------
317 | * Refactored the whiteSpaceBore / noSpaceBefore / whiteSpaceAfter / noSpaceAfter methods.
318 | * Refactored peekNextValidToken and peekPrvsValidToken to avoid using call by reference
319 | * New test : function length
320 | * New test : empty block (if ($a) {} )
321 | * New test : avoid heredoc
322 | * New test : excessive function parameters
323 | * New test : need braces
324 | * New test : switch have a default and default is at the end
325 | * New test : switch case should have a break
326 |
327 |
328 | Version 0.8.3
329 | -------------
330 | * Added some tests on the docbloc (@param and @return)
331 | * Added a test on unary operators
332 | * Corrected a bug in the detection of the end of a function
333 |
334 |
335 | Version 0.8.2
336 | -------------
337 | * Added new test (Use boolean operators instead of logical operators)
338 |
339 |
340 | Version 0.8.1
341 | -------------
342 | * Corrected a bug with NEW_LINE caracter inside a constant string
343 |
344 |
345 | Version 0.8
346 | -----------
347 | * Replaced the token_get_all() function by token_get_all_nl() found here : http://php.net/manual/fr/function.token-get-all.php
348 | This function returns the new line caracters as a token. This solve some problems and impact a lot of code.
349 | * Added the possibility to generate a report on the number of lines of code compatible with the JavaNCSS format (http://kclee.de/clemens/java/javancss/)
350 | * Added new tests (Extract TODOs, Avoid passing references)
351 | * Some refactoring
352 |
353 |
354 | Version 0.7.1
355 | -------------
356 | * Added new tests (Cyclomatic Complexity, ...)
357 |
358 |
359 | Version 0.7
360 | -----------
361 | * All tests are now configurable
362 | * Included some propositions from the forum
363 | * Added the possibility to define a severity level for each test rule
364 | * Ignoring the .svn repositories
365 | * Changed the XML outpout in order to be compatible with the checkstyle format (http://checkstyle.sourceforge.net/)
366 |
367 |
368 | Version 0.6.1
369 | -------------
370 | * Bugs Fixes
371 | * HTML Ouput changes
372 |
373 |
374 | Version 0.6
375 | -----------
376 |
377 | This is the very first release of Spike PHPCheckstyle. It is an alpha release.
378 |
379 | * Known Issues
380 |
381 | 1. Indentation: The tools checks only for existence of tabs in a line. It
382 | does not check that every line follows the 4 space indentation rule.
383 | 2. Issue with do/while loop: The tool generates wrong errors when a do/while
384 | loop contains a while loop or another do/while loop.
385 | 3. Global variable nameing: Global variable naming convention checks are
386 | not implemented.
387 | 4. Docblocks: The tool currently checks only for the existence of docblocks
388 | but not for all the required elements within it.
389 | 5. Issue: when a cpp comment (starting with //) is followed by "}" in the
390 | next line, reports that the "}" should be on a new line (even though it
391 | is on a new line).
392 | 6. Expects the configuration file to be {install-dir}/config/pear.cfg.xml.
393 | Can not change it.
394 | 7. Some of the tests are not configurable (that is, they are checked, but can not
395 | disable them). They are: "spaceAfterControlStmt", "spaceAfterSemicolon",
396 | "noSpaceAfterFuncCall" and "spaceAfterFuncNameDefn". (Refer documentation
397 | for more details on configurations).
398 |
--------------------------------------------------------------------------------
/Vagrantfile:
--------------------------------------------------------------------------------
1 | # -*- mode: ruby -*-
2 | # vi: set ft=ruby :
3 |
4 |
5 | # Vagrantfile API/syntax version.
6 | VAGRANTFILE_API_VERSION = "2"
7 |
8 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
9 |
10 | config.vm.box = "geerlingguy/debian9"
11 |
12 | #Dev config
13 | config.vm.define "phpcheckstyle_dev" do |phpcheckstyle_dev|
14 | end
15 | config.vm.provider "virtualbox" do |v|
16 | v.memory = 3072
17 | v.cpus = 4
18 | v.name = "phpcheckstyle_dev"
19 | end
20 |
21 | config.vm.network "private_network", ip: "192.168.50.66"
22 |
23 |
24 | config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
25 |
26 | #
27 | # Middleware installation
28 | # The following provisions are executed as "root"
29 | #
30 | config.vm.provision "install_composer", privileged: true, type: "shell", inline: "/vagrant/vagrant_config/scripts/install_composer.sh"
31 |
32 | #
33 | # Middleware installation
34 | # The following provisions are executed as "vagrant"
35 | #
36 | config.vm.provision "install_composer_libraries", privileged: false, type: "shell", inline: "/vagrant/vagrant_config/scripts/install_composer_libraries.sh"
37 |
38 | #
39 | # Documentation & Code quality & Developers provisions
40 | # The following provisions are executed as "vagrant" and are only run when called explicitly
41 | #
42 |
43 | if ARGV.include? '--provision-with'
44 | config.vm.provision "run_phpunit", privileged: false, type: "shell", inline: "/vagrant/vendor/bin/phpunit"
45 | end
46 |
47 | if ARGV.include? '--provision-with'
48 | config.vm.provision "run_phpcheckstyle", privileged: false, type: "shell", inline: "/vagrant/phpcheckstyle.sh"
49 | end
50 |
51 | config.vm.provision "shell", inline: "echo 'The VM is ready on 192.168.50.66'", run: "always"
52 |
53 | end
54 |
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
17 |
18 |
19 | Static Analysis tool for PHP.
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
43 |
44 |
45 |
46 |
47 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 | Windows
108 |
109 |
110 |
111 |
112 |
113 |
114 | Unix
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/checkstyle_result/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name" : "phpcheckstyle/phpcheckstyle",
3 | "description" : "PHPCheckstyle is an open-source tool that helps PHP programmers adhere to certain coding conventions",
4 | "type" : "library",
5 | "keywords" : [
6 | "checkstyle",
7 | "standard",
8 | "convention"
9 | ],
10 | "homepage" : "https://github.com/phpcheckstyle/phpcheckstyle/",
11 | "license" : "OSL-2.1",
12 | "require" : {
13 | "php" : ">=5.0.0"
14 | },
15 | "require-dev" : {
16 | "phpunit/phpunit" : ">=7.0.0"
17 | },
18 | "support" : {
19 | "wiki" : "https://github.com/phpcheckstyle/phpcheckstyle/wiki",
20 | "source" : "https://github.com/phpcheckstyle/phpcheckstyle"
21 | },
22 | "autoload" : {
23 | "psr-0" : {
24 | "PHPCheckstyle\\" : "src/"
25 | },
26 | "files" : [
27 | "src/PHPCheckstyle/_Constants.php"
28 | ]
29 | },
30 | "bin" : [
31 | "phpcheckstyle"
32 | ]
33 | }
--------------------------------------------------------------------------------
/config/sameline.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
324 |
325 |
326 |
327 |
328 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
--------------------------------------------------------------------------------
/html/README:
--------------------------------------------------------------------------------
1 | Holds files required for html format reporting.
2 |
--------------------------------------------------------------------------------
/html/css/global.css:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: #ffffff;
3 | color: #000000;
4 | margin: 10px;
5 | font-family: Verdana, Arial, Helvetica, sans-serif;
6 | font-size: 13px;
7 | }
8 |
9 | .banner {
10 | width: 100%;
11 | font-size: 20px;
12 | text-align: center;
13 | }
14 |
15 | .banner a {
16 | text-decoration: none;
17 | }
18 |
19 | .title {
20 | font-size: 30px;
21 | font-weight: bold;
22 | vertical-align: top;
23 | }
24 |
25 | h1 {
26 | font-size: 20px;
27 | font-weight: bold;
28 | text-align: center;
29 | }
30 |
31 | h2 {
32 | font-size: 15px;
33 | font-weight: bold;
34 | text-align: center;
35 | }
36 |
37 | .dataTable {
38 | border: 1px solid #CCCCCC;
39 | border-spacing: 0px;
40 | background-color: #F1F1F1;
41 | border-collapse: collapse;
42 | }
43 |
44 | .tableHead {
45 | background-color: #92A9ED;
46 | font-weight: bold;
47 | padding: 2px;
48 | padding-left: 5px;
49 | text-align: center;
50 | vertical-align: top;
51 | border: 1px solid #CCCCCC;
52 | }
53 |
54 | .tableCell {
55 | border: 1px solid #CCCCCC;
56 | padding: 2px;
57 | }
58 |
59 | .tableCellBold {
60 | border: 1px solid #CCCCCC;
61 | padding: 2px;
62 | font-weight: bold;
63 | }
64 |
65 | .emphasis {
66 | color: #990000;
67 | font-weight: bold;
68 | }
69 |
70 | .footer {
71 |
72 | }
73 |
74 | .copyright {
75 | color: #4076B9;
76 | font-size: 10px;
77 | }
78 |
79 | .tableHead {
80 | background-color: #92A9ED;
81 | font-weight: bold;
82 | padding: 2px;
83 | padding-left: 5px;
84 | text-align: center;
85 | vertical-align: top;
86 | border: 1px solid #CCCCCC;
87 | }
88 |
89 | .tableCell {
90 | border: 1px solid #CCCCCC;
91 | padding: 2px;
92 | }
93 |
94 | .tableCellBold {
95 | border: 1px solid #CCCCCC;
96 | padding: 2px;
97 | font-weight: bold;
98 | }
99 |
100 | .emphasis {
101 | color: #990000;
102 | font-weight: bold;
103 | }
104 |
105 | .footer {
106 |
107 | }
108 |
109 | .copyright {
110 | color: #4076B9;
111 | font-size: 10px;
112 | }
113 |
114 |
115 | .badge-error {
116 | color: #212529;
117 | background-color: #dc3545;
118 | }
--------------------------------------------------------------------------------
/html/images/Logo_phpcheckstyle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PHPCheckstyle/phpcheckstyle/aa5c8f2229f6137fc1866faa5bf0569103e760a0/html/images/Logo_phpcheckstyle.png
--------------------------------------------------------------------------------
/html/images/spacer.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PHPCheckstyle/phpcheckstyle/aa5c8f2229f6137fc1866faa5bf0569103e760a0/html/images/spacer.gif
--------------------------------------------------------------------------------
/html/template/detail.tmpl:
--------------------------------------------------------------------------------
1 |
2 |