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

Update files #78

Merged
merged 18 commits into from
Jun 22, 2024
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
11 changes: 7 additions & 4 deletions src/RequirementsChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
use function intval;

/**
* YiiRequirementChecker allows checking, if current system meets the requirements for running the Yii application.
* `RequirementsChecker` allows checking, if current system meets the requirements for running the Yii application.
* This class allows rendering of the check report for the web and console application interface.
*
* Example:
*
* ```php
* require_once 'path/to/YiiRequirementChecker.php';
* $requirementsChecker = new YiiRequirementChecker();
* use Yiisoft\Requirements\RequirementsChecker;
*
* require_once('vendor/yiisoft/requirements/src/RequirementsChecker.php');
*
* $requirementsChecker = new RequirementsChecker;
* $requirements = [
* [
* 'name' => 'PHP Some Extension',
Expand Down Expand Up @@ -99,7 +102,7 @@
if (!$requirement['condition']) {
if ($requirement['mandatory']) {
$requirement['error'] = true;
$requirement['warning'] = true;

Check warning on line 105 in src/RequirementsChecker.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "TrueValue": --- Original +++ New @@ @@ if (!$requirement['condition']) { if ($requirement['mandatory']) { $requirement['error'] = true; - $requirement['warning'] = true; + $requirement['warning'] = false; $this->result['summary']['errors']++; } else { $requirement['error'] = false;
$this->result['summary']['errors']++;
} else {
$requirement['error'] = false;
Expand Down Expand Up @@ -179,7 +182,7 @@
if (empty($extensionVersion)) {
return false;
}
if (strncasecmp($extensionVersion, 'PECL-', 5) === 0) {

Check warning on line 185 in src/RequirementsChecker.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": --- Original +++ New @@ @@ if (empty($extensionVersion)) { return false; } - if (strncasecmp($extensionVersion, 'PECL-', 5) === 0) { + if (strncasecmp($extensionVersion, 'PECL-', 4) === 0) { $extensionVersion = substr($extensionVersion, 5); } /** @var bool */

Check warning on line 185 in src/RequirementsChecker.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ if (empty($extensionVersion)) { return false; } - if (strncasecmp($extensionVersion, 'PECL-', 5) === 0) { + if (strncasecmp($extensionVersion, 'PECL-', 6) === 0) { $extensionVersion = substr($extensionVersion, 5); } /** @var bool */

Check warning on line 185 in src/RequirementsChecker.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": --- Original +++ New @@ @@ if (empty($extensionVersion)) { return false; } - if (strncasecmp($extensionVersion, 'PECL-', 5) === 0) { + if (strncasecmp($extensionVersion, 'PECL-', 5) === -1) { $extensionVersion = substr($extensionVersion, 5); } /** @var bool */
$extensionVersion = substr($extensionVersion, 5);
}

Expand Down Expand Up @@ -248,7 +251,7 @@
return (int) $verboseSize;
}
$sizeUnit = trim($verboseSize, '0123456789');
$size = trim(str_replace($sizeUnit, '', $verboseSize));

Check warning on line 254 in src/RequirementsChecker.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "UnwrapTrim": --- Original +++ New @@ @@ return (int) $verboseSize; } $sizeUnit = trim($verboseSize, '0123456789'); - $size = trim(str_replace($sizeUnit, '', $verboseSize)); + $size = str_replace($sizeUnit, '', $verboseSize); if (!is_numeric($size)) { return 0; }
if (!is_numeric($size)) {
return 0;
}
Expand Down Expand Up @@ -333,7 +336,7 @@
* @param int|string $requirementKey Requirement key in the list.
* @return array Normalized requirement.
*/
public function normalizeRequirement(array $requirement, $requirementKey = 0): array

Check warning on line 339 in src/RequirementsChecker.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": --- Original +++ New @@ @@ * @param int|string $requirementKey Requirement key in the list. * @return array Normalized requirement. */ - public function normalizeRequirement(array $requirement, $requirementKey = 0) : array + public function normalizeRequirement(array $requirement, $requirementKey = -1) : array { if (!array_key_exists('condition', $requirement)) { $this->usageError("Requirement \"{$requirementKey}\" has no condition!");

Check warning on line 339 in src/RequirementsChecker.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ * @param int|string $requirementKey Requirement key in the list. * @return array Normalized requirement. */ - public function normalizeRequirement(array $requirement, $requirementKey = 0) : array + public function normalizeRequirement(array $requirement, $requirementKey = 1) : array { if (!array_key_exists('condition', $requirement)) { $this->usageError("Requirement \"{$requirementKey}\" has no condition!");

Check warning on line 339 in src/RequirementsChecker.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "PublicVisibility": --- Original +++ New @@ @@ * @param int|string $requirementKey Requirement key in the list. * @return array Normalized requirement. */ - public function normalizeRequirement(array $requirement, $requirementKey = 0) : array + protected function normalizeRequirement(array $requirement, $requirementKey = 0) : array { if (!array_key_exists('condition', $requirement)) { $this->usageError("Requirement \"{$requirementKey}\" has no condition!");
{
if (!array_key_exists('condition', $requirement)) {
$this->usageError("Requirement \"$requirementKey\" has no condition!");
Expand All @@ -354,10 +357,10 @@
$requirement['mandatory'] = false;
}
}
if (!array_key_exists('by', $requirement)) {

Check warning on line 360 in src/RequirementsChecker.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "LogicalNot": --- Original +++ New @@ @@ $requirement['mandatory'] = false; } } - if (!array_key_exists('by', $requirement)) { + if (array_key_exists('by', $requirement)) { $requirement['by'] = 'Unknown'; } if (!array_key_exists('memo', $requirement)) {
$requirement['by'] = 'Unknown';
}
if (!array_key_exists('memo', $requirement)) {

Check warning on line 363 in src/RequirementsChecker.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "LogicalNot": --- Original +++ New @@ @@ if (!array_key_exists('by', $requirement)) { $requirement['by'] = 'Unknown'; } - if (!array_key_exists('memo', $requirement)) { + if (array_key_exists('memo', $requirement)) { $requirement['memo'] = ''; } return $requirement;
$requirement['memo'] = '';
}

Expand Down Expand Up @@ -402,6 +405,6 @@
*/
public function getNowDate(): string
{
return @strftime('%Y-%m-%d %H:%M', time());
return date('Y-m-d H:i:s');

Check warning on line 408 in src/RequirementsChecker.php

View check run for this annotation

Codecov / codecov/patch

src/RequirementsChecker.php#L408

Added line #L408 was not covered by tests
}
}
2 changes: 1 addition & 1 deletion src/views/console/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
echo 'Required by: ' . strip_tags($requirement['by']) . "\n";
$memo = strip_tags($requirement['memo']);
if (!empty($memo)) {
echo 'Memo: ' . strip_tags($requirement['memo']) . "\n";
echo strip_tags($requirement['memo']) . "\n";

Check warning on line 28 in src/views/console/index.php

View check run for this annotation

Codecov / codecov/patch

src/views/console/index.php#L28

Added line #L28 was not covered by tests
}
}
echo "\n";
Expand Down
Loading