Skip to content

Commit

Permalink
Drop support for PHP < 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Sep 1, 2015
1 parent 9a0cbb3 commit c472c13
Show file tree
Hide file tree
Showing 21 changed files with 262 additions and 261 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -7,7 +7,7 @@

## Requirements

PHP 5.3.3 is required but using the latest version of PHP is highly recommended
PHP 5.6 is required but using the latest version of PHP is highly recommended

### PHP 5

Expand All @@ -23,11 +23,11 @@ A version of HHVM that implements the Xdebug API for code coverage (`xdebug_*_co

## Installation

To add PHP_CodeCoverage as a local, per-project dependency to your project, simply add a dependency on `phpunit/php-code-coverage` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on PHP_CodeCoverage 2.0:
To add PHP_CodeCoverage as a local, per-project dependency to your project, simply add a dependency on `phpunit/php-code-coverage` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on PHP_CodeCoverage 3.0:

{
"require": {
"phpunit/php-code-coverage": "^2"
"phpunit/php-code-coverage": "^3"
}
}

Expand Down
7 changes: 4 additions & 3 deletions composer.json
Expand Up @@ -20,16 +20,17 @@
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"irc": "irc://irc.freenode.net/phpunit"
},
"minimum-stability": "dev",
"require": {
"php": ">=5.3.3",
"php": ">=5.6",
"phpunit/php-file-iterator": "~1.3",
"phpunit/php-token-stream": "~1.3",
"phpunit/php-text-template": "~1.2",
"sebastian/environment": "^1.3.2",
"sebastian/version": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~4",
"phpunit/phpunit": "~5",
"ext-xdebug": ">=2.1.4"
},
"suggest": {
Expand All @@ -44,7 +45,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.2.x-dev"
"dev-master": "3.0.x-dev"
}
}
}
34 changes: 17 additions & 17 deletions src/CodeCoverage.php
Expand Up @@ -67,12 +67,12 @@ class PHP_CodeCoverage
*
* @var array
*/
private $data = array();
private $data = [];

/**
* @var array
*/
private $ignoredLines = array();
private $ignoredLines = [];

/**
* @var bool
Expand All @@ -84,7 +84,7 @@ class PHP_CodeCoverage
*
* @var array
*/
private $tests = array();
private $tests = [];

/**
* Constructor.
Expand Down Expand Up @@ -127,8 +127,8 @@ public function getReport()
public function clear()
{
$this->currentId = null;
$this->data = array();
$this->tests = array();
$this->data = [];
$this->tests = [];
}

/**
Expand Down Expand Up @@ -231,7 +231,7 @@ public function start($id, $clear = false)
* @return array
* @throws PHP_CodeCoverage_Exception
*/
public function stop($append = true, $linesToBeCovered = array(), array $linesToBeUsed = array())
public function stop($append = true, $linesToBeCovered = [], array $linesToBeUsed = [])
{
if (!is_bool($append)) {
throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory(
Expand Down Expand Up @@ -265,7 +265,7 @@ public function stop($append = true, $linesToBeCovered = array(), array $linesTo
* @param array $linesToBeUsed
* @throws PHP_CodeCoverage_Exception
*/
public function append(array $data, $id = null, $append = true, $linesToBeCovered = array(), array $linesToBeUsed = array())
public function append(array $data, $id = null, $append = true, $linesToBeCovered = [], array $linesToBeUsed = [])
{
if ($id === null) {
$id = $this->currentId;
Expand Down Expand Up @@ -316,7 +316,7 @@ public function append(array $data, $id = null, $append = true, $linesToBeCovere
$id = $id->getName();
}

$this->tests[$id] = array('size' => $size, 'status' => $status);
$this->tests[$id] = ['size' => $size, 'status' => $status];

foreach ($data as $file => $lines) {
if (!$this->filter->isFile($file)) {
Expand Down Expand Up @@ -508,7 +508,7 @@ private function applyCoversAnnotationFilter(array &$data, $linesToBeCovered, ar
{
if ($linesToBeCovered === false ||
($this->forceCoversAnnotation && empty($linesToBeCovered))) {
$data = array();
$data = [];

return;
}
Expand Down Expand Up @@ -577,10 +577,10 @@ private function initializeFilesThatAreSeenTheFirstTime(array $data)
{
foreach ($data as $file => $lines) {
if ($this->filter->isFile($file) && !isset($this->data[$file])) {
$this->data[$file] = array();
$this->data[$file] = [];

foreach ($lines as $k => $v) {
$this->data[$file][$k] = $v == -2 ? null : array();
$this->data[$file][$k] = $v == -2 ? null : [];
}
}
}
Expand All @@ -591,7 +591,7 @@ private function initializeFilesThatAreSeenTheFirstTime(array $data)
*/
private function addUncoveredFilesFromWhitelist()
{
$data = array();
$data = [];
$uncoveredFiles = array_diff(
$this->filter->getWhitelist(),
array_keys($this->data)
Expand All @@ -609,7 +609,7 @@ private function addUncoveredFilesFromWhitelist()
$uncoveredFiles
);
} else {
$data[$uncoveredFile] = array();
$data[$uncoveredFile] = [];

$lines = count(file($uncoveredFile));

Expand Down Expand Up @@ -665,7 +665,7 @@ private function getLinesToBeIgnored($filename)
}

if (!isset($this->ignoredLines[$filename])) {
$this->ignoredLines[$filename] = array();
$this->ignoredLines[$filename] = [];

if ($this->disableIgnoredLines) {
return $this->ignoredLines[$filename];
Expand Down Expand Up @@ -864,11 +864,11 @@ private function performUnintentionallyCoveredCodeCheck(array &$data, array $lin
*/
private function getAllowedLines(array $linesToBeCovered, array $linesToBeUsed)
{
$allowedLines = array();
$allowedLines = [];

foreach (array_keys($linesToBeCovered) as $file) {
if (!isset($allowedLines[$file])) {
$allowedLines[$file] = array();
$allowedLines[$file] = [];
}

$allowedLines[$file] = array_merge(
Expand All @@ -879,7 +879,7 @@ private function getAllowedLines(array $linesToBeCovered, array $linesToBeUsed)

foreach (array_keys($linesToBeUsed) as $file) {
if (!isset($allowedLines[$file])) {
$allowedLines[$file] = array();
$allowedLines[$file] = [];
}

$allowedLines[$file] = array_merge(
Expand Down
8 changes: 4 additions & 4 deletions src/CodeCoverage/Driver/PHPDBG.php
Expand Up @@ -49,11 +49,11 @@ public function start()
*/
public function stop()
{
static $fetchedLines = array();
static $fetchedLines = [];

$dbgData = phpdbg_end_oplog();

if ($fetchedLines == array()) {
if ($fetchedLines == []) {
$sourceLines = phpdbg_get_executable();
} else {
$newFiles = array_diff(
Expand All @@ -63,10 +63,10 @@ public function stop()

if ($newFiles) {
$sourceLines = phpdbg_get_executable(
array('files' => $newFiles)
['files' => $newFiles]
);
} else {
$sourceLines = array();
$sourceLines = [];
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/CodeCoverage/Filter.php
Expand Up @@ -20,14 +20,14 @@ class PHP_CodeCoverage_Filter
*
* @var array
*/
private $blacklistedFiles = array();
private $blacklistedFiles = [];

/**
* Source files that are whitelisted.
*
* @var array
*/
private $whitelistedFiles = array();
private $whitelistedFiles = [];

/**
* Adds a directory to the blacklist (recursively).
Expand Down
12 changes: 6 additions & 6 deletions src/CodeCoverage/Report/Clover.php
Expand Up @@ -39,7 +39,7 @@ public function process(PHP_CodeCoverage $coverage, $target = null, $name = null

$xmlCoverage->appendChild($xmlProject);

$packages = array();
$packages = [];
$report = $coverage->getReport();
unset($coverage);

Expand All @@ -55,7 +55,7 @@ public function process(PHP_CodeCoverage $coverage, $target = null, $name = null

$classes = $item->getClassesAndTraits();
$coverage = $item->getCoverageData();
$lines = array();
$lines = [];

foreach ($classes as $className => $class) {
$classStatements = 0;
Expand Down Expand Up @@ -84,12 +84,12 @@ public function process(PHP_CodeCoverage $coverage, $target = null, $name = null
}
}

$lines[$method['startLine']] = array(
$lines[$method['startLine']] = [
'count' => $methodCount,
'crap' => $method['crap'],
'type' => 'method',
'name' => $methodName
);
];
}

if (!empty($class['package']['namespace'])) {
Expand Down Expand Up @@ -160,9 +160,9 @@ public function process(PHP_CodeCoverage $coverage, $target = null, $name = null
continue;
}

$lines[$line] = array(
$lines[$line] = [
'count' => count($data), 'type' => 'stmt'
);
];
}

ksort($lines);
Expand Down
2 changes: 1 addition & 1 deletion src/CodeCoverage/Report/Factory.php
Expand Up @@ -105,7 +105,7 @@ private function addItems(PHP_CodeCoverage_Report_Node_Directory $root, array $i
*/
private function buildDirectoryStructure($files)
{
$result = array();
$result = [];

foreach ($files as $path => $file) {
$path = explode('/', $path);
Expand Down
12 changes: 6 additions & 6 deletions src/CodeCoverage/Report/HTML/Renderer.php
Expand Up @@ -125,7 +125,7 @@ protected function renderItemTemplate(Text_Template $template, array $data)
}

$template->setVar(
array(
[
'icon' => isset($data['icon']) ? $data['icon'] : '',
'crap' => isset($data['crap']) ? $data['crap'] : '',
'name' => $data['name'],
Expand All @@ -141,7 +141,7 @@ protected function renderItemTemplate(Text_Template $template, array $data)
'classes_tested_percent' => isset($data['testedClassesPercentAsString']) ? $data['testedClassesPercentAsString'] : '',
'classes_level' => $classesLevel,
'classes_number' => $classesNumber
)
]
);

return $template->render();
Expand All @@ -156,7 +156,7 @@ protected function setCommonTemplateVariables(Text_Template $template, PHP_CodeC
$runtime = new Runtime;

$template->setVar(
array(
[
'id' => $node->getId(),
'full_path' => $node->getPath(),
'path_to_root' => $this->getPathToRoot($node),
Expand All @@ -169,15 +169,15 @@ protected function setCommonTemplateVariables(Text_Template $template, PHP_CodeC
'generator' => $this->generator,
'low_upper_bound' => $this->lowUpperBound,
'high_lower_bound' => $this->highLowerBound
)
]
);
}

protected function getBreadcrumbs(PHP_CodeCoverage_Report_Node $node)
{
$breadcrumbs = '';
$path = $node->getPathAsArray();
$pathToRoot = array();
$pathToRoot = [];
$max = count($path);

if ($node instanceof PHP_CodeCoverage_Report_Node_File) {
Expand Down Expand Up @@ -248,7 +248,7 @@ protected function getCoverageBar($percent)
'}}'
);

$template->setVar(array('level' => $level, 'percent' => sprintf('%.2F', $percent)));
$template->setVar(['level' => $level, 'percent' => sprintf('%.2F', $percent)]);

return $template->render();
}
Expand Down

0 comments on commit c472c13

Please sign in to comment.