Skip to content

Commit 90b6df8

Browse files
localheinzgdiggs
authored andcommitted
Fix: Restore compatibility with PHP 5.3 (#104)
* Fix: Run builds on PHP5.3 and PHP5.4 * Fix: Reduce minimum required PHP version to PHP5.3 * Fix: Remove dependency on tm/tooly-composer-script * Fix: Restore compatibility with PHP5.3 * Enhancement: Add composer script to build PHAR
1 parent 8c6e6b9 commit 90b6df8

File tree

13 files changed

+66
-57
lines changed

13 files changed

+66
-57
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
Vagrantfile
44
build/
55
vendor/
6+
box.phar
67
composer.lock
78
composer.phar

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ sudo: false
44

55
matrix:
66
include:
7+
- php: 5.3
8+
env: WITH_LOWEST=true
9+
- php: 5.3
10+
env: WITH_HIGHEST=true
11+
- php: 5.4
12+
env: WITH_LOWEST=true
13+
- php: 5.4
14+
env: WITH_HIGHEST=true
715
- php: 5.5
816
env: WITH_LOWEST=true
917
- php: 5.5

box.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
"exclude": [
2323
"bin",
2424
"tests",
25-
"phpunit",
26-
"tm"
25+
"Tests"
2726
],
2827
"in": [
2928
"vendor"

composer.json

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@
1919
"sort-packages": true
2020
},
2121
"require": {
22-
"php": "^5.5 || ^7.0",
22+
"php": "^5.3 || ^7.0",
2323
"ext-curl": "*",
2424
"padraic/phar-updater": "^1.0",
2525
"psr/log": "^1.0",
2626
"satooshi/php-coveralls": "^1.0",
2727
"symfony/console": "^2.0 || ^3.0"
2828
},
2929
"require-dev": {
30-
"phpunit/phpunit": "^4.8.31",
31-
"tm/tooly-composer-script": "^1.0"
30+
"phpunit/phpunit": "^4.8.31"
3231
},
3332
"autoload": {
3433
"psr-4": {
@@ -44,18 +43,16 @@
4443
"composer/bin/test-reporter"
4544
],
4645
"scripts": {
47-
"post-install-cmd": "Tooly\\ScriptHandler::installPharTools",
48-
"post-update-cmd": "Tooly\\ScriptHandler::installPharTools"
46+
"box": [
47+
"composer install --no-dev --prefer-dist",
48+
"curl -LSs https://box-project.github.io/box2/installer.php | php",
49+
"php box.phar --version",
50+
"php box.phar build -v"
51+
]
4952
},
5053
"extra": {
5154
"branch-alias": {
5255
"dev-master": "0.3.x-dev"
53-
},
54-
"tools": {
55-
"box": {
56-
"url": "https://github.com/box-project/box2/releases/download/2.7.2/box-2.7.2.phar",
57-
"only-dev": true
58-
}
5956
}
6057
}
6158
}

composer/bin/test-reporter

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ namespace CodeClimate\PhpTestReporter;
55

66
use CodeClimate\PhpTestReporter\Constants\Version;
77

8-
$files = [
8+
$files = array(
99
__DIR__ . '/../../vendor/autoload.php',
1010
__DIR__ . '/../../../../autoload.php',
11-
];
11+
)
1212

1313
foreach ($files as $file) {
1414
if (file_exists($file)) {

phar/bin/main.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
try {
1616
$app = new Application('Code Climate PHP Test Reporter', '@package_version@');
1717
$app->addCommands(
18-
[
18+
array(
1919
new UploadCommand('upload'),
2020
new SelfUpdateCommand('self-update'),
2121
new RollbackCommand('rollback'),
22-
]
22+
)
2323
);
2424

2525
$code = $app->run();

src/ConsoleCommands/SelfUpdateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class SelfUpdateCommand extends Command
2323
{
2424
protected function configure()
2525
{
26-
$this->setAliases([ 'selfupdate' ]);
26+
$this->setAliases(array( 'selfupdate' ));
2727
$this->setDescription('Updates this PHAR to latest version.');
2828

2929
$this->addOption(

src/ConsoleCommands/UploadCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function configure()
2929
null,
3030
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
3131
'Location of clover style CodeCoverage report, as produced by PHPUnit\'s --coverage-clover option.',
32-
[ 'build/logs/clover.xml' ]
32+
array( 'build/logs/clover.xml' )
3333
);
3434
}
3535

src/TestReporter/ApiClient.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ public function send(Entity\JsonFile $json)
3131
{
3232
$response = new \stdClass;
3333
$payload = (string)$json;
34-
$options = [
35-
'http' => [
34+
$options = array(
35+
'http' => array(
3636
'method' => 'POST',
37-
'header' => [
37+
'header' => array(
3838
'Host: codeclimate.com',
3939
'Content-Type: application/json',
4040
'User-Agent: Code Climate (PHP Test Reporter v' . Version::VERSION . ')',
4141
'Content-Length: ' . strlen($payload),
42-
],
42+
),
4343
'content' => $payload,
4444
"timeout" => 10,
45-
],
46-
];
45+
),
46+
);
4747
$context = stream_context_create($options);
4848
$url = $this->apiHost . '/test_reports';
4949

@@ -81,12 +81,12 @@ private function sendWithCurl($url, $payload)
8181
curl_setopt(
8282
$curl,
8383
CURLOPT_HTTPHEADER,
84-
[
84+
array(
8585
'Host: codeclimate.com',
8686
'Content-Type: application/json',
8787
'User-Agent: Code Climate (PHP Test Reporter v' . Version::VERSION . ')',
8888
'Content-Length: ' . strlen($payload),
89-
]
89+
)
9090
);
9191
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
9292
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
@@ -109,7 +109,7 @@ private function sendWithCurl($url, $payload)
109109

110110
$response->code = $errorCode;
111111
$response->message = $error['message'];
112-
$response->headers = [ ];
112+
$response->headers = array( );
113113
$response->body = null;
114114
}
115115

src/TestReporter/CoverageCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CoverageCollector
1616
* Array that holds list of relative paths to Clover XML files
1717
* @var array
1818
*/
19-
protected $cloverPaths = [ ];
19+
protected $cloverPaths = array( );
2020

2121
/**
2222
* CoverageCollector constructor.

src/TestReporter/Entity/CiInfo.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,113 +40,113 @@ public function toArray()
4040
return $this->werckerProperties();
4141
}
4242

43-
return [ ];
43+
return array( );
4444
}
4545

4646
/**
4747
* @return array
4848
*/
4949
protected function travisProperties()
5050
{
51-
return [
51+
return array(
5252
"name" => "travis-ci",
5353
"branch" => $_SERVER["TRAVIS_BRANCH"],
5454
"build_identifier" => $_SERVER["TRAVIS_JOB_ID"],
5555
"pull_request" => $_SERVER["TRAVIS_PULL_REQUEST"],
56-
];
56+
);
5757
}
5858

5959
/**
6060
* @return array
6161
*/
6262
protected function circleProperties()
6363
{
64-
return [
64+
return array(
6565
"name" => "circleci",
6666
"build_identifier" => $_SERVER["CIRCLE_BUILD_NUM"],
6767
"branch" => $_SERVER["CIRCLE_BRANCH"],
6868
"commit_sha" => $_SERVER["CIRCLE_SHA1"],
69-
];
69+
);
7070
}
7171

7272
/**
7373
* @return array
7474
*/
7575
protected function semaphoreProperties()
7676
{
77-
return [
77+
return array(
7878
"name" => "semaphore",
7979
"branch" => $_SERVER["BRANCH_NAME"],
8080
"build_identifier" => $_SERVER["SEMAPHORE_BUILD_NUMBER"],
81-
];
81+
);
8282
}
8383

8484
/**
8585
* @return array
8686
*/
8787
protected function jenkinsProperties()
8888
{
89-
return [
89+
return array(
9090
"name" => "jenkins",
9191
"build_identifier" => $_SERVER["BUILD_NUMBER"],
9292
"build_url" => $_SERVER["BUILD_URL"],
9393
"branch" => $_SERVER["GIT_BRANCH"],
9494
"commit_sha" => $_SERVER["GIT_COMMIT"],
95-
];
95+
);
9696
}
9797

9898
/**
9999
* @return array
100100
*/
101101
protected function tddiumProperties()
102102
{
103-
return [
103+
return array(
104104
"name" => "tddium",
105105
"build_identifier" => $_SERVER["TDDIUM_SESSION_ID"],
106106
"worker_id" => $_SERVER["TDDIUM_TID"],
107-
];
107+
);
108108
}
109109

110110
/**
111111
* @return array
112112
*/
113113
protected function codeshipProperties()
114114
{
115-
return [
115+
return array(
116116
"name" => "codeship",
117117
"build_identifier" => $_SERVER["CI_BUILD_NUMBER"],
118118
"build_url" => $_SERVER["CI_BUILD_URL"],
119119
"branch" => $_SERVER["CI_BRANCH"],
120120
"commit_sha" => $_SERVER["CI_COMMIT_ID"],
121-
];
121+
);
122122
}
123123

124124
/**
125125
* @return array
126126
*/
127127
protected function buildkiteProperties()
128128
{
129-
return [
129+
return array(
130130
"name" => "buildkite",
131131
"build_identifier" => $_SERVER["BUILDKITE_BUILD_ID"],
132132
"build_url" => $_SERVER["BUILDKITE_BUILD_URL"],
133133
"branch" => $_SERVER["BUILDKITE_BRANCH"],
134134
"commit_sha" => $_SERVER["BUILDKITE_COMMIT"],
135135
"pull_request" => $_SERVER["BUILDKITE_PULL_REQUEST"],
136-
];
136+
);
137137
}
138138

139139
/**
140140
* @return array
141141
*/
142142
protected function werckerProperties()
143143
{
144-
return [
144+
return array(
145145
"name" => "wercker",
146146
"build_identifier" => $_SERVER["WERCKER_BUILD_ID"],
147147
"build_url" => $_SERVER["WERCKER_BUILD_URL"],
148148
"branch" => $_SERVER["WERCKER_GIT_BRANCH"],
149149
"commit_sha" => $_SERVER["WERCKER_GIT_COMMIT"],
150-
];
150+
);
151151
}
152152
}

src/TestReporter/Entity/JsonFile.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ class JsonFile extends SatooshiJsonFile
1010
{
1111
public function toArray()
1212
{
13-
return [
13+
return array(
1414
"partial" => false,
1515
"run_at" => $this->getRunAt(),
1616
"repo_token" => $this->getRepoToken(),
1717
"environment" => $this->getEnvironment(),
1818
"git" => $this->collectGitInfo(),
1919
"ci_service" => $this->collectCiServiceInfo(),
2020
"source_files" => $this->collectSourceFiles(),
21-
];
21+
);
2222
}
2323

2424
public function getRunAt()
@@ -36,10 +36,10 @@ public function getRepoToken()
3636
*/
3737
protected function getEnvironment()
3838
{
39-
return [
39+
return array(
4040
"pwd" => getcwd(),
4141
"package_version" => Version::VERSION,
42-
];
42+
);
4343
}
4444

4545
/**
@@ -49,11 +49,11 @@ protected function collectGitInfo()
4949
{
5050
$command = new GitCommand();
5151

52-
return [
52+
return array(
5353
"head" => $command->getHead(),
5454
"branch" => $command->getBranch(),
5555
"committed_at" => $command->getCommittedAt(),
56-
];
56+
);
5757
}
5858

5959
/**
@@ -71,13 +71,17 @@ protected function collectCiServiceInfo()
7171
*/
7272
protected function collectSourceFiles()
7373
{
74-
return array_map(function (SourceFile $sourceFile) {
75-
return [
74+
$data = array();
75+
76+
foreach ($this->getSourceFiles() as $sourceFile) {
77+
$data[] = array(
7678
"name" => $sourceFile->getName(),
7779
"coverage" => json_encode($sourceFile->getCoverage()),
7880
"blob_id" => $this->calculateBlobId($sourceFile),
79-
];
80-
}, array_values($this->getSourceFiles()));
81+
);
82+
}
83+
84+
return $data;
8185
}
8286

8387
/**

tests/Unit/ApplicationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function shouldExecuteSuccessfully()
2929
$app->setAutoExit(false);
3030
$tester = new ApplicationTester($app);
3131

32-
$status = $tester->run([ '--stdout' => true ]);
32+
$status = $tester->run(array( '--stdout' => true ));
3333

3434
$this->assertEquals(0, $status);
3535
}

0 commit comments

Comments
 (0)