Skip to content

Commit 4071b3b

Browse files
hollodotmepbrisbin
authored andcommitted
Use PSR-4-compatible namespaces
1 parent 9217abf commit 4071b3b

File tree

20 files changed

+755
-704
lines changed

20 files changed

+755
-704
lines changed

Diff for: .gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
.idea/
2+
.vagrant/
3+
Vagrantfile
14
build/
25
vendor/
3-
box.phar
4-
codeclimate-test-reporter.phar
56
composer.lock
67
composer.phar

Diff for: composer.json

+55-35
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,57 @@
11
{
2-
"name": "codeclimate/php-test-reporter",
3-
"description": "PHP client for reporting test coverage to Code Climate",
4-
"keywords": ["codeclimate", "coverage"],
5-
"homepage": "https://github.com/codeclimate/php-test-reporter",
6-
"type": "library",
7-
"license": "MIT",
8-
"authors": [
9-
{
10-
"name": "Code Climate",
11-
"email": "[email protected]",
12-
"homepage": "https://codeclimate.com"
13-
}
14-
],
15-
"require": {
16-
"php": ">=5.3",
17-
"ext-curl": "*",
18-
"satooshi/php-coveralls": "1.0.*",
19-
"symfony/console": ">=2.0"
20-
},
21-
"require-dev": {
22-
"phpunit/phpunit": "3.7.*@stable",
23-
"ext-xdebug": "*"
24-
},
25-
"autoload": {
26-
"psr-0": {
27-
"CodeClimate\\Component": "src/",
28-
"CodeClimate\\Bundle": "src/"
29-
}
30-
},
31-
"bin": ["composer/bin/test-reporter"],
32-
"extra": {
33-
"branch-alias": {
34-
"dev-master": "0.3.x-dev"
35-
}
36-
}
2+
"name": "codeclimate/php-test-reporter",
3+
"description": "PHP client for reporting test coverage to Code Climate",
4+
"keywords": [
5+
"codeclimate",
6+
"coverage"
7+
],
8+
"homepage": "https://github.com/codeclimate/php-test-reporter",
9+
"type": "library",
10+
"license": "MIT",
11+
"authors": [
12+
{
13+
"name": "Code Climate",
14+
"email": "[email protected]",
15+
"homepage": "https://codeclimate.com"
16+
}
17+
],
18+
"require": {
19+
"php": ">=5.3",
20+
"ext-curl": "*",
21+
"satooshi/php-coveralls": "^1.0",
22+
"symfony/console": "^2.0"
23+
},
24+
"require-dev": {
25+
"phpunit/phpunit": "3.7.*@stable",
26+
"ext-xdebug": "*",
27+
"tm/tooly-composer-script": "^1.0"
28+
},
29+
"autoload": {
30+
"psr-4": {
31+
"CodeClimate\\PhpTestReporter\\": "src/"
32+
}
33+
},
34+
"autoload-dev": {
35+
"psr-4": {
36+
"CodeClimate\\PhpTestReporter\\Tests\\": "tests/"
37+
}
38+
},
39+
"bin": [
40+
"composer/bin/test-reporter"
41+
],
42+
"scripts": {
43+
"post-install-cmd": "Tooly\\ScriptHandler::installPharTools",
44+
"post-update-cmd": "Tooly\\ScriptHandler::installPharTools"
45+
},
46+
"extra": {
47+
"branch-alias": {
48+
"dev-master": "0.3.x-dev"
49+
},
50+
"tools": {
51+
"box": {
52+
"url": "https://github.com/box-project/box2/releases/download/2.7.2/box-2.7.2.phar",
53+
"only-dev": true
54+
}
55+
}
56+
}
3757
}

Diff for: composer/bin/test-reporter

+25-21
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
#!/usr/bin/env php
22
<?php
33

4-
$files = array(
5-
__DIR__ . '/../../vendor/autoload.php',
6-
__DIR__ . '/../../../../autoload.php'
7-
);
4+
namespace CodeClimate\PhpTestReporter;
85

9-
foreach ($files as $file) {
10-
if (file_exists($file)) {
11-
include_once $file;
6+
use CodeClimate\PhpTestReporter\Constants\Version;
127

13-
define('PHP_TEST_REPORTER_COMPOSER_INSTALL', $file);
8+
$files = [
9+
__DIR__ . '/../../vendor/autoload.php',
10+
__DIR__ . '/../../../../autoload.php',
11+
];
1412

15-
break;
16-
}
17-
}
13+
foreach ( $files as $file )
14+
{
15+
if ( file_exists( $file ) )
16+
{
17+
include_once $file;
18+
19+
define( 'PHP_TEST_REPORTER_COMPOSER_INSTALL', $file );
1820

19-
if (!defined('PHP_TEST_REPORTER_COMPOSER_INSTALL')) {
20-
die(
21-
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
22-
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
23-
'php composer.phar install' . PHP_EOL
24-
);
21+
break;
22+
}
2523
}
2624

27-
use CodeClimate\Bundle\TestReporterBundle\Version;
28-
use CodeClimate\Bundle\TestReporterBundle\Console\Application;
25+
if ( !defined( 'PHP_TEST_REPORTER_COMPOSER_INSTALL' ) )
26+
{
27+
die(
28+
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
29+
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
30+
'php composer.phar install' . PHP_EOL
31+
);
32+
}
2933

30-
$rootDir = realpath(dirname(PHP_TEST_REPORTER_COMPOSER_INSTALL) . '/..');
34+
$rootDir = realpath( dirname( PHP_TEST_REPORTER_COMPOSER_INSTALL ) . '/..' );
3135

32-
$app = new Application($rootDir, 'Code Climate PHP Test Reporter', Version::VERSION);
36+
$app = new Application( $rootDir, 'Code Climate PHP Test Reporter', Version::VERSION );
3337
$app->run();

Diff for: src/Application.php

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
namespace CodeClimate\PhpTestReporter;
3+
4+
use CodeClimate\PhpTestReporter\ConsoleCommands\TestReporterCommand;
5+
use Symfony\Component\Console\Application as BaseApplication;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
8+
/**
9+
* Coveralls API application.
10+
* @author Kitamura Satoshi <[email protected]>
11+
*/
12+
class Application extends BaseApplication
13+
{
14+
/**
15+
* Path to project root directory.
16+
* @var string
17+
*/
18+
private $rootDir;
19+
20+
/**
21+
* Constructor.
22+
*
23+
* @param string $rootDir Path to project root directory.
24+
* @param string $name The name of the application
25+
* @param string $version The version of the application
26+
*/
27+
public function __construct( $rootDir, $name = 'UNKNOWN', $version = 'UNKNOWN' )
28+
{
29+
$this->rootDir = $rootDir;
30+
31+
parent::__construct( $name, $version );
32+
}
33+
34+
// internal method
35+
36+
/**
37+
* {@inheritdoc}
38+
* @see \Symfony\Component\Console\Application::getCommandName()
39+
*/
40+
protected function getCommandName( InputInterface $input )
41+
{
42+
return 'test-reporter';
43+
}
44+
45+
/**
46+
* {@inheritdoc}
47+
* @see \Symfony\Component\Console\Application::getDefaultCommands()
48+
*/
49+
protected function getDefaultCommands()
50+
{
51+
// Keep the core default commands to have the HelpCommand
52+
// which is used when using the --help option
53+
$defaultCommands = parent::getDefaultCommands();
54+
$defaultCommands[] = $this->createTestReporterCommand();
55+
56+
return $defaultCommands;
57+
}
58+
59+
/**
60+
* Create TestReporterCommand.
61+
* @return TestReporterCommand
62+
*/
63+
protected function createTestReporterCommand()
64+
{
65+
$command = new TestReporterCommand();
66+
$command->setRootDir( $this->rootDir );
67+
68+
return $command;
69+
}
70+
71+
// accessor
72+
73+
/**
74+
* {@inheritdoc}
75+
* @see \Symfony\Component\Console\Application::getDefinition()
76+
*/
77+
public function getDefinition()
78+
{
79+
$inputDefinition = parent::getDefinition();
80+
// clear out the normal first argument, which is the command name
81+
$inputDefinition->setArguments();
82+
83+
return $inputDefinition;
84+
}
85+
}

Diff for: src/CodeClimate/Bundle/TestReporterBundle/ApiClient.php

-123
This file was deleted.

0 commit comments

Comments
 (0)