title: How to lint or static analysis for only changed files in a branch?
body: <p>I am using Jenkins and doing PHPMD, PHPCS and PHP lint checks for Pull Requests. What we have is basically a separate branch for each feature and it supposed to merge into the master branch again if it passes checks and tests. </p>
  
  <p>We are checking all php files in the project with this command: </p>
  
  <pre><code>echo "php syntax checks are started"
  find ./ -type f -name \*.php -exec php -l '{}' \; | grep -v "No syntax errors detected" &amp;&amp; echo "PHP Syntax error(s) detected" &amp;&amp; exit 1;
  </code></pre>
  
  <p>Using "php -l" for all php files takes around minute. </p>
  
  <p>I was wondering if there is a way to speed up for this and came up with a solution. Please check my answer below.</p>