Fixes issue 7, adds testing to prevent the issue from occuring in the… #25
ci.yml
on: pull_request
Matrix: Coding standards, code quality and static code analysis
Matrix: Test suite and coverage
Annotations
2 errors and 20 warnings
Test suite and coverage (8.3)
Process completed with exit code 1.
|
Test suite and coverage (8.2)
Process completed with exit code 1.
|
Test suite and coverage (8.3):
src/OdataQueryParser.php#L79
Escaped Mutant for Mutator "ProtectedVisibility":
--- Original
+++ New
@@ @@
* @return string|null The query string from the input URL. Null if there is no query string.
* @throws InvalidArgumentException The URL is malformed and the query string could not be extracted
*/
- protected static function extractQueryString(string $url) : ?string
+ private static function extractQueryString(string $url) : ?string
{
$queryString = parse_url($url, PHP_URL_QUERY);
if ($queryString === false) {
|
Test suite and coverage (8.3):
src/OdataQueryParser.php#L83
Escaped Mutant for Mutator "FalseValue":
--- Original
+++ New
@@ @@
protected static function extractQueryString(string $url) : ?string
{
$queryString = parse_url($url, PHP_URL_QUERY);
- if ($queryString === false) {
+ if ($queryString === true) {
throw new InvalidArgumentException("URL could not be parsed. Ensure the URL is not malformed.");
}
// The URL query string parser should return a string or null query string
|
Test suite and coverage (8.3):
src/OdataQueryParser.php#L88
Escaped Mutant for Mutator "LogicalOrAllSubExprNegation":
--- Original
+++ New
@@ @@
throw new InvalidArgumentException("URL could not be parsed. Ensure the URL is not malformed.");
}
// The URL query string parser should return a string or null query string
- if (!($queryString === null || is_string($queryString))) {
+ if (!(!($queryString === null) || !is_string($queryString))) {
throw new InvalidArgumentException("URL query string should be a string.");
}
return $queryString;
|
Test suite and coverage (8.3):
src/OdataQueryParser.php#L102
Escaped Mutant for Mutator "PublicVisibility":
--- Original
+++ New
@@ @@
*
* @return array<string, string> The components of the query string, split up into an array
*/
- public static function parseQueryString(string $queryString) : array
+ protected static function parseQueryString(string $queryString) : array
{
$result = [];
parse_str($queryString, $result);
|
Test suite and coverage (8.3):
src/OdataQueryParser.php#L108
Escaped Mutant for Mutator "Foreach_":
--- Original
+++ New
@@ @@
$result = [];
parse_str($queryString, $result);
// Verify that the parsed result only has string key and values
- foreach ($result as $key => $value) {
+ foreach (array() as $key => $value) {
if (!is_string($key) || !is_string($value)) {
throw new InvalidArgumentException("Parsed query string has non-string values.");
}
|
Test suite and coverage (8.3):
src/OdataQueryParser.php#L109
Escaped Mutant for Mutator "LogicalOr":
--- Original
+++ New
@@ @@
parse_str($queryString, $result);
// Verify that the parsed result only has string key and values
foreach ($result as $key => $value) {
- if (!is_string($key) || !is_string($value)) {
+ if (!is_string($key) && !is_string($value)) {
throw new InvalidArgumentException("Parsed query string has non-string values.");
}
}
|
Test suite and coverage (8.3):
src/OdataQueryParser.php#L143
Escaped Mutant for Mutator "ProtectedVisibility":
--- Original
+++ New
@@ @@
*
* @return string The key with or without dollar sign prepended
*/
- protected static function buildKeyConstant(string $key, bool $withDollar) : string
+ private static function buildKeyConstant(string $key, bool $withDollar) : string
{
return $withDollar ? '$' . $key : $key;
}
|
Test suite and coverage (8.3):
src/OdataQueryParser.php#L156
Escaped Mutant for Mutator "ProtectedVisibility":
--- Original
+++ New
@@ @@
*
* @return bool Whether the odata key is present in the input query string
*/
- protected static function hasKey(string $key, array $queryString) : bool
+ private static function hasKey(string $key, array $queryString) : bool
{
return array_key_exists($key, $queryString);
}
|
Test suite and coverage (8.3):
src/OdataQueryParser.php#L226
Escaped Mutant for Mutator "Identical":
--- Original
+++ New
@@ @@
{
if (!self::validateWithFilterValidate($queryString, self::$count, FILTER_VALIDATE_BOOLEAN)) {
// 0 and 1 are also valid values for a boolean
- if (!(array_key_exists(self::$count, $queryString) && (trim($queryString[self::$count]) === '0' || trim($queryString[self::$count]) === '1'))) {
+ if (!(array_key_exists(self::$count, $queryString) && (trim($queryString[self::$count]) !== '0' || trim($queryString[self::$count]) === '1'))) {
return null;
}
}
|
Test suite and coverage (8.3):
src/OdataQueryParser.php#L226
Escaped Mutant for Mutator "UnwrapTrim":
--- Original
+++ New
@@ @@
{
if (!self::validateWithFilterValidate($queryString, self::$count, FILTER_VALIDATE_BOOLEAN)) {
// 0 and 1 are also valid values for a boolean
- if (!(array_key_exists(self::$count, $queryString) && (trim($queryString[self::$count]) === '0' || trim($queryString[self::$count]) === '1'))) {
+ if (!(array_key_exists(self::$count, $queryString) && ($queryString[self::$count] === '0' || trim($queryString[self::$count]) === '1'))) {
return null;
}
}
|
Test suite and coverage (8.2):
src/OdataQueryParser.php#L79
Escaped Mutant for Mutator "ProtectedVisibility":
--- Original
+++ New
@@ @@
* @return string|null The query string from the input URL. Null if there is no query string.
* @throws InvalidArgumentException The URL is malformed and the query string could not be extracted
*/
- protected static function extractQueryString(string $url) : ?string
+ private static function extractQueryString(string $url) : ?string
{
$queryString = parse_url($url, PHP_URL_QUERY);
if ($queryString === false) {
|
Test suite and coverage (8.2):
src/OdataQueryParser.php#L83
Escaped Mutant for Mutator "FalseValue":
--- Original
+++ New
@@ @@
protected static function extractQueryString(string $url) : ?string
{
$queryString = parse_url($url, PHP_URL_QUERY);
- if ($queryString === false) {
+ if ($queryString === true) {
throw new InvalidArgumentException("URL could not be parsed. Ensure the URL is not malformed.");
}
// The URL query string parser should return a string or null query string
|
Test suite and coverage (8.2):
src/OdataQueryParser.php#L88
Escaped Mutant for Mutator "LogicalOrAllSubExprNegation":
--- Original
+++ New
@@ @@
throw new InvalidArgumentException("URL could not be parsed. Ensure the URL is not malformed.");
}
// The URL query string parser should return a string or null query string
- if (!($queryString === null || is_string($queryString))) {
+ if (!(!($queryString === null) || !is_string($queryString))) {
throw new InvalidArgumentException("URL query string should be a string.");
}
return $queryString;
|
Test suite and coverage (8.2):
src/OdataQueryParser.php#L102
Escaped Mutant for Mutator "PublicVisibility":
--- Original
+++ New
@@ @@
*
* @return array<string, string> The components of the query string, split up into an array
*/
- public static function parseQueryString(string $queryString) : array
+ protected static function parseQueryString(string $queryString) : array
{
$result = [];
parse_str($queryString, $result);
|
Test suite and coverage (8.2):
src/OdataQueryParser.php#L108
Escaped Mutant for Mutator "Foreach_":
--- Original
+++ New
@@ @@
$result = [];
parse_str($queryString, $result);
// Verify that the parsed result only has string key and values
- foreach ($result as $key => $value) {
+ foreach (array() as $key => $value) {
if (!is_string($key) || !is_string($value)) {
throw new InvalidArgumentException("Parsed query string has non-string values.");
}
|
Test suite and coverage (8.2):
src/OdataQueryParser.php#L109
Escaped Mutant for Mutator "LogicalOr":
--- Original
+++ New
@@ @@
parse_str($queryString, $result);
// Verify that the parsed result only has string key and values
foreach ($result as $key => $value) {
- if (!is_string($key) || !is_string($value)) {
+ if (!is_string($key) && !is_string($value)) {
throw new InvalidArgumentException("Parsed query string has non-string values.");
}
}
|
Test suite and coverage (8.2):
src/OdataQueryParser.php#L143
Escaped Mutant for Mutator "ProtectedVisibility":
--- Original
+++ New
@@ @@
*
* @return string The key with or without dollar sign prepended
*/
- protected static function buildKeyConstant(string $key, bool $withDollar) : string
+ private static function buildKeyConstant(string $key, bool $withDollar) : string
{
return $withDollar ? '$' . $key : $key;
}
|
Test suite and coverage (8.2):
src/OdataQueryParser.php#L156
Escaped Mutant for Mutator "ProtectedVisibility":
--- Original
+++ New
@@ @@
*
* @return bool Whether the odata key is present in the input query string
*/
- protected static function hasKey(string $key, array $queryString) : bool
+ private static function hasKey(string $key, array $queryString) : bool
{
return array_key_exists($key, $queryString);
}
|
Test suite and coverage (8.2):
src/OdataQueryParser.php#L226
Escaped Mutant for Mutator "UnwrapTrim":
--- Original
+++ New
@@ @@
{
if (!self::validateWithFilterValidate($queryString, self::$count, FILTER_VALIDATE_BOOLEAN)) {
// 0 and 1 are also valid values for a boolean
- if (!(array_key_exists(self::$count, $queryString) && (trim($queryString[self::$count]) === '0' || trim($queryString[self::$count]) === '1'))) {
+ if (!(array_key_exists(self::$count, $queryString) && ($queryString[self::$count] === '0' || trim($queryString[self::$count]) === '1'))) {
return null;
}
}
|
Test suite and coverage (8.2):
src/OdataQueryParser.php#L226
Escaped Mutant for Mutator "Identical":
--- Original
+++ New
@@ @@
{
if (!self::validateWithFilterValidate($queryString, self::$count, FILTER_VALIDATE_BOOLEAN)) {
// 0 and 1 are also valid values for a boolean
- if (!(array_key_exists(self::$count, $queryString) && (trim($queryString[self::$count]) === '0' || trim($queryString[self::$count]) === '1'))) {
+ if (!(array_key_exists(self::$count, $queryString) && (trim($queryString[self::$count]) !== '0' || trim($queryString[self::$count]) === '1'))) {
return null;
}
}
|