Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use preferred-install from composer to replace script #2

Merged
merged 1 commit into from
Aug 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "hostnet/phpcs-tool",
"type": "composer-plugin",
"description": "PHP_CodeSniffer tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards. Hostnet version",
"license": "MIT",
"name": "hostnet/phpcs-tool",
"type": "composer-plugin",
"description": "PHP_CodeSniffer tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards. Hostnet version",
"license": "MIT",
"require": {
"php": ">=5.6",
"squizlabs/php_codesniffer": "^2.6.0",
"composer-plugin-api": "^1.0.0",
"hostnet/path-composer-plugin-lib": "^1.0"
"php": ">=5.6",
"composer-plugin-api": "^1.0.0",
"hostnet/path-composer-plugin-lib": "^1.0",
"squizlabs/php_codesniffer": "^2.6.0"
},
"require-dev": {
"phpunit/phpunit": "^5.3.0",
"composer/composer": "^1.0.0"
"composer/composer": "^1.0.0",
"phpunit/phpunit": "^5.3.0"
},
"minimum-stability": "stable",
"autoload": {
Expand All @@ -23,19 +23,21 @@
"psr-0": {
"Hostnet": "test/"
},
"files" : [
"files": [
"vendor/squizlabs/php_codesniffer/tests/Standards/AbstractSniffUnitTest.php"
]
},
"config": {
"bin-dir": "bin"
"config": {
"bin-dir": "bin",
"preferred-install": {
"squizlabs/php_codesniffer": "source"
}
},
"extra": {
"class": "Hostnet\\Component\\CodeSniffer\\Installer"
"class": "Hostnet\\Component\\CodeSniffer\\Installer"
},
"scripts": {
"pre-dependencies-solving": "Hostnet\\Component\\CodeSniffer\\Installer::ensureSource",
"post-autoload-dump": "Hostnet\\Component\\CodeSniffer\\Installer::configureAsRoot"
"post-autoload-dump": "Hostnet\\Component\\CodeSniffer\\Installer::configureAsRoot"
},
"archive": {
"exclude": [
Expand Down
21 changes: 6 additions & 15 deletions src/Hostnet/Component/CodeSniffer/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use Hostnet\Component\Path\Path;

/**
* This small composer installer plugin hooks into the post-autoload-dump event and swaps out the phpcs and phpcbf
* files for their hostnet counter parts.
* This small composer installer plugin hooks into the post-autoload-dump
* and configures the Hostnet standard for PHPCS
*
* @author Stefan Lenselink <[email protected]>
*/
Expand Down Expand Up @@ -59,20 +59,8 @@ public static function getSubscribedEvents()
}

/**
* This function call is called from the phpcs main composer.json file as an 'pre-dependencies-solving' script.
* This function makes sure the Download manager ALWAYS uses source instead of dist to ensure the 'test'-folder of
* PHP Code Sniffer is there...
*
* @param InstallerEvent $event the event fired.
* Configuration for standalone use in a system wide installation senario
*/
public static function ensureSource(InstallerEvent $event)
{
$download_manager = $event->getComposer()->getDownloadManager();
/*@var $dm \Composer\Downloader\DownloadManager */
$download_manager->setPreferDist(false);
$download_manager->setPreferSource(true);
}

public static function configureAsRoot()
{
$vendor_dir = Path::VENDOR_DIR . '/hostnet/phpcs-tool/src/Hostnet';
Expand All @@ -84,6 +72,9 @@ public static function configureAsRoot()
}
}

/**
* Configure the Hostnet code style
*/
public static function configure()
{
$file = Path::VENDOR_DIR . '/squizlabs/php_codesniffer/CodeSniffer.conf';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ public function getErrorList($filename = null)
public function getWarningList()
{
return array();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ public function getErrorList($filename = null)
public function getWarningList()
{
return array();

}
}