Skip to content

Instantly share code, notes, and snippets.

@jeremysells
Last active July 27, 2018 17:45
Show Gist options
  • Save jeremysells/22631d190acd1f18fc95c7f3f89d6d39 to your computer and use it in GitHub Desktop.
Save jeremysells/22631d190acd1f18fc95c7f3f89d6d39 to your computer and use it in GitHub Desktop.
Netbeans PHP QA tweaks
#!/bin/bash
# This script makes Netbeans use a custom phpcs.xml (PHP Codesniffer)
# Note: git dir does not work (NB runs out of the git dir)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# When asked for the standards, return them
# note: The last file is our standard!
if [ $1 = '-i' ]; then
echo "The installed coding standards are PEAR, PHPCS, PSR2, MySource, PSR1, Zend, Squiz and $DIR/../phpcs.xml"
exit
fi
# Else redirect all to PHPCS in the vendor folder
$DIR/../../vendor/bin/phpcs "$@"
#!/usr/bin/env php
<?php
//This file is a hack, that forces Netbeans to use the projects XML config file for mess detector
/**
* Function that runs after the buffer is cleared
* @param string $output
* @return string
*/
$outputFilter = function($output)
{
$outputLines = explode("\n", $output);
//Delete first line, its "#!/usr/bin/env php"
//And breaks Netbeans interpretation of the output
array_shift($outputLines);
return implode("\n", $outputLines);
};
ob_start($outputFilter);
$root = realpath(__DIR__."/../") . "/";
$inputFile = $argv[0];
$whatToScan = $argv[1];
$outputFormat = $argv[2];
$argv = array(
$inputFile,
$whatToScan,
$outputFormat,
$root."build/phpmd.xml" //http://phpqatools.org/
);
include $root . "bin/phpmd";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment