PHP Syntax checking pre-source control

后端 未结 6 1449
孤城傲影
孤城傲影 2021-02-05 01:30

Referring to Is there a static code analyzer [like Lint] for PHP files? -- I am looking at how to assess the content of PHP files before they are committed by developers.

6条回答
  •  梦如初夏
    2021-02-05 02:20

    All of these smart super power tools that eavesdrop every door and look into every keyhole will never be able to compete withe the stupid and blunt action of RUNNING the code.

    What is the value of having compilable, syntactically valid php files in the repo? You can make zounds of such files, commit them on a regular basis to the repo and, rest assured, all of them contribute to the project and add a certain reliable feature, because, well, they went through the pre-commit hook to check their validity?

    There is a cr@pload of problems with the code written by humans, syntax and missing vars being only the tip of the iceberg. Unit testing (as noted by @NikiC) helps quite a bit. It's the responsibility of the developer to make reliable, working, documented code and test it before committing. Silly mistakes of using undeclared vars is something that the IDE can point out (Zend Studio does, for instance). Your goal is to create good working software and unit tests are key here. This should be the main concern in my opinion. Valid php files is a very loose requirement...

提交回复
热议问题