mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-11-30 04:39:48 +01:00
remove unused function call suppression (#165)
* remove unused function call suppression * run static analysis every 3 hours ( with latest psalm version )
This commit is contained in:
parent
2f65c9f878
commit
887324a0c3
4
.github/workflows/code-coverage.yml
vendored
4
.github/workflows/code-coverage.yml
vendored
@ -1,6 +1,8 @@
|
|||||||
name: "code coverage"
|
name: "code coverage"
|
||||||
|
|
||||||
on: ["pull_request", "push"]
|
on:
|
||||||
|
pull_request: ~
|
||||||
|
push: ~
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
code-coverage:
|
code-coverage:
|
||||||
|
4
.github/workflows/coding-standards.yml
vendored
4
.github/workflows/coding-standards.yml
vendored
@ -1,6 +1,8 @@
|
|||||||
name: "coding standards"
|
name: "coding standards"
|
||||||
|
|
||||||
on: ["pull_request", "push"]
|
on:
|
||||||
|
pull_request: ~
|
||||||
|
push: ~
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
coding-standards:
|
coding-standards:
|
||||||
|
4
.github/workflows/documentation-check.yml
vendored
4
.github/workflows/documentation-check.yml
vendored
@ -1,6 +1,8 @@
|
|||||||
name: "documentation check"
|
name: "documentation check"
|
||||||
|
|
||||||
on: ["pull_request", "push"]
|
on:
|
||||||
|
pull_request: ~
|
||||||
|
push: ~
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
doc-check:
|
doc-check:
|
||||||
|
4
.github/workflows/security-analysis.yml
vendored
4
.github/workflows/security-analysis.yml
vendored
@ -1,6 +1,8 @@
|
|||||||
name: "security analysis"
|
name: "security analysis"
|
||||||
|
|
||||||
on: ["pull_request", "push"]
|
on:
|
||||||
|
pull_request: ~
|
||||||
|
push: ~
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
security-analysis:
|
security-analysis:
|
||||||
|
6
.github/workflows/static-analysis.yml
vendored
6
.github/workflows/static-analysis.yml
vendored
@ -1,6 +1,10 @@
|
|||||||
name: "static analysis"
|
name: "static analysis"
|
||||||
|
|
||||||
on: ["pull_request", "push"]
|
on:
|
||||||
|
pull_request: ~
|
||||||
|
push: ~
|
||||||
|
schedule:
|
||||||
|
- cron: '0 */3 * * *'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
static-analysis:
|
static-analysis:
|
||||||
|
4
.github/workflows/unit-tests.yml
vendored
4
.github/workflows/unit-tests.yml
vendored
@ -1,6 +1,8 @@
|
|||||||
name: "unit tests"
|
name: "unit tests"
|
||||||
|
|
||||||
on: ["pull_request", "push"]
|
on:
|
||||||
|
pull_request: ~
|
||||||
|
push: ~
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
unit-tests:
|
unit-tests:
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
- [algorithms](./../../src/Psl/Hash/algorithms.php#L16)
|
- [algorithms](./../../src/Psl/Hash/algorithms.php#L16)
|
||||||
- [equals](./../../src/Psl/Hash/equals.php#L14)
|
- [equals](./../../src/Psl/Hash/equals.php#L14)
|
||||||
- [hash](./../../src/Psl/Hash/hash.php#L16)
|
- [hash](./../../src/Psl/Hash/hash.php#L17)
|
||||||
|
|
||||||
#### `Classes`
|
#### `Classes`
|
||||||
|
|
||||||
|
21
psalm.xml
21
psalm.xml
@ -1,20 +1,5 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<psalm
|
<psalm totallyTyped="true" resolveFromConfigFile="true" forbidEcho="true" strictBinaryOperands="true" phpVersion="7.4" allowPhpStormGenerics="true" allowStringToStandInForClass="true" rememberPropertyAssignmentsAfterCall="false" skipChecksOnUnresolvableIncludes="false" checkForThrowsDocblock="true" checkForThrowsInGlobalScope="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
|
||||||
totallyTyped="true"
|
|
||||||
resolveFromConfigFile="true"
|
|
||||||
forbidEcho="true"
|
|
||||||
strictBinaryOperands="true"
|
|
||||||
phpVersion="7.4"
|
|
||||||
allowPhpStormGenerics="true"
|
|
||||||
allowStringToStandInForClass="true"
|
|
||||||
rememberPropertyAssignmentsAfterCall="false"
|
|
||||||
skipChecksOnUnresolvableIncludes="false"
|
|
||||||
checkForThrowsDocblock="true"
|
|
||||||
checkForThrowsInGlobalScope="true"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns="https://getpsalm.org/schema/config"
|
|
||||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
|
||||||
>
|
|
||||||
<projectFiles>
|
<projectFiles>
|
||||||
<directory name="src" />
|
<directory name="src" />
|
||||||
<directory name="integration" />
|
<directory name="integration" />
|
||||||
@ -59,10 +44,6 @@
|
|||||||
<RedundantCondition errorLevel="suppress" />
|
<RedundantCondition errorLevel="suppress" />
|
||||||
<RedundantCast errorLevel="suppress" />
|
<RedundantCast errorLevel="suppress" />
|
||||||
<RedundantCastGivenDocblockType errorLevel="suppress" />
|
<RedundantCastGivenDocblockType errorLevel="suppress" />
|
||||||
|
|
||||||
<!-- Not using the result of pure functions is common within PSL -->
|
|
||||||
<!-- e.g: with and Psl\invariant_violations() -->
|
|
||||||
<UnusedFunctionCall errorLevel="suppress" />
|
|
||||||
</issueHandlers>
|
</issueHandlers>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -84,11 +84,18 @@ final class Context
|
|||||||
* Pump data into an active hashing context.
|
* Pump data into an active hashing context.
|
||||||
*
|
*
|
||||||
* @psalm-mutation-free
|
* @psalm-mutation-free
|
||||||
|
*
|
||||||
|
* @throws Exception\RuntimeException If unable to pump data into the active hashing context.
|
||||||
*/
|
*/
|
||||||
public function update(string $data): Context
|
public function update(string $data): Context
|
||||||
{
|
{
|
||||||
$internal_context = hash_copy($this->internalContext);
|
$internal_context = hash_copy($this->internalContext);
|
||||||
hash_update($internal_context, $data);
|
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
|
if (!hash_update($internal_context, $data)) {
|
||||||
|
throw new Exception\RuntimeException('Unable to pump data into the active hashing context.');
|
||||||
|
}
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
return new self($internal_context);
|
return new self($internal_context);
|
||||||
}
|
}
|
||||||
|
11
src/Psl/Hash/Exception/ExceptionInterface.php
Normal file
11
src/Psl/Hash/Exception/ExceptionInterface.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Psl\Hash\Exception;
|
||||||
|
|
||||||
|
use Psl\Exception;
|
||||||
|
|
||||||
|
interface ExceptionInterface extends Exception\ExceptionInterface
|
||||||
|
{
|
||||||
|
}
|
11
src/Psl/Hash/Exception/RuntimeException.php
Normal file
11
src/Psl/Hash/Exception/RuntimeException.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Psl\Hash\Exception;
|
||||||
|
|
||||||
|
use Psl\Exception;
|
||||||
|
|
||||||
|
class RuntimeException extends Exception\RuntimeException implements ExceptionInterface
|
||||||
|
{
|
||||||
|
}
|
@ -11,6 +11,7 @@ use Psl\Hash;
|
|||||||
* Generate a keyed hash value using the HMAC method.
|
* Generate a keyed hash value using the HMAC method.
|
||||||
*
|
*
|
||||||
* @throws Psl\Exception\InvariantViolationException If the given algorithm is unsupported.
|
* @throws Psl\Exception\InvariantViolationException If the given algorithm is unsupported.
|
||||||
|
* @throws Hash\Exception\RuntimeException If unable to pump data into the hashing context.
|
||||||
*
|
*
|
||||||
* @pure
|
* @pure
|
||||||
*/
|
*/
|
||||||
|
@ -10,6 +10,7 @@ use Psl;
|
|||||||
* Generate a hash value (message digest).
|
* Generate a hash value (message digest).
|
||||||
*
|
*
|
||||||
* @throws Psl\Exception\InvariantViolationException If the given algorithm is unsupported.
|
* @throws Psl\Exception\InvariantViolationException If the given algorithm is unsupported.
|
||||||
|
* @throws Exception\RuntimeException If unable to pump data into the hashing context.
|
||||||
*
|
*
|
||||||
* @pure
|
* @pure
|
||||||
*/
|
*/
|
||||||
|
@ -612,6 +612,8 @@ final class Loader
|
|||||||
'Psl\Type\Type',
|
'Psl\Type\Type',
|
||||||
'Psl\Json\Exception\DecodeException',
|
'Psl\Json\Exception\DecodeException',
|
||||||
'Psl\Json\Exception\EncodeException',
|
'Psl\Json\Exception\EncodeException',
|
||||||
|
'Psl\Hash\Exception\ExceptionInterface',
|
||||||
|
'Psl\Hash\Exception\RuntimeException',
|
||||||
'Psl\Hash\Context',
|
'Psl\Hash\Context',
|
||||||
'Psl\Encoding\Exception\IncorrectPaddingException',
|
'Psl\Encoding\Exception\IncorrectPaddingException',
|
||||||
'Psl\Encoding\Exception\RangeException',
|
'Psl\Encoding\Exception\RangeException',
|
||||||
|
@ -17,8 +17,10 @@ use Psl;
|
|||||||
* @throws Psl\Exception\InvariantViolationException If the offset is out-of-bounds.
|
* @throws Psl\Exception\InvariantViolationException If the offset is out-of-bounds.
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
|
* @return ($assert is true ? bool : int)
|
||||||
*/
|
*/
|
||||||
function validate_offset(int $offset, int $length): int
|
function validate_offset(int $offset, int $length, bool $assert = false)
|
||||||
{
|
{
|
||||||
$original_offset = $offset;
|
$original_offset = $offset;
|
||||||
|
|
||||||
@ -28,5 +30,9 @@ function validate_offset(int $offset, int $length): int
|
|||||||
|
|
||||||
Psl\invariant($offset >= 0 && $offset <= $length, 'Offset (%d) was out-of-bounds.', $original_offset);
|
Psl\invariant($offset >= 0 && $offset <= $length, 'Offset (%d) was out-of-bounds.', $original_offset);
|
||||||
|
|
||||||
|
if (!$assert) {
|
||||||
return $offset;
|
return $offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -21,9 +21,7 @@ use Psl;
|
|||||||
function contains(string $haystack, string $needle, int $offset = 0): bool
|
function contains(string $haystack, string $needle, int $offset = 0): bool
|
||||||
{
|
{
|
||||||
if ('' === $needle) {
|
if ('' === $needle) {
|
||||||
Psl\Internal\validate_offset($offset, length($haystack));
|
return Psl\Internal\validate_offset($offset, length($haystack), true);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null !== search($haystack, $needle, $offset);
|
return null !== search($haystack, $needle, $offset);
|
||||||
|
@ -20,10 +20,9 @@ use Psl;
|
|||||||
*/
|
*/
|
||||||
function contains_ci(string $haystack, string $needle, int $offset = 0): bool
|
function contains_ci(string $haystack, string $needle, int $offset = 0): bool
|
||||||
{
|
{
|
||||||
|
$length = length($haystack);
|
||||||
if ('' === $needle) {
|
if ('' === $needle) {
|
||||||
Psl\Internal\validate_offset($offset, length($haystack));
|
return Psl\Internal\validate_offset($offset, $length, true);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null !== search_ci($haystack, $needle, $offset);
|
return null !== search_ci($haystack, $needle, $offset);
|
||||||
|
@ -21,9 +21,7 @@ use Psl;
|
|||||||
function contains(string $haystack, string $needle, int $offset = 0): bool
|
function contains(string $haystack, string $needle, int $offset = 0): bool
|
||||||
{
|
{
|
||||||
if ('' === $needle) {
|
if ('' === $needle) {
|
||||||
Psl\Internal\validate_offset($offset, length($haystack));
|
return Psl\Internal\validate_offset($offset, length($haystack), true);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null !== search($haystack, $needle, $offset);
|
return null !== search($haystack, $needle, $offset);
|
||||||
|
@ -21,9 +21,7 @@ use Psl;
|
|||||||
function contains_ci(string $haystack, string $needle, int $offset = 0): bool
|
function contains_ci(string $haystack, string $needle, int $offset = 0): bool
|
||||||
{
|
{
|
||||||
if ('' === $needle) {
|
if ('' === $needle) {
|
||||||
Psl\Internal\validate_offset($offset, length($haystack));
|
return Psl\Internal\validate_offset($offset, length($haystack), true);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null !== search_ci($haystack, $needle, $offset);
|
return null !== search_ci($haystack, $needle, $offset);
|
||||||
|
@ -42,9 +42,7 @@ use Psl;
|
|||||||
function contains(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): bool
|
function contains(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): bool
|
||||||
{
|
{
|
||||||
if ('' === $needle) {
|
if ('' === $needle) {
|
||||||
Psl\Internal\validate_offset($offset, length($haystack, $encoding));
|
return Psl\Internal\validate_offset($offset, length($haystack, $encoding), true);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null !== search($haystack, $needle, $offset, $encoding);
|
return null !== search($haystack, $needle, $offset, $encoding);
|
||||||
|
@ -42,9 +42,7 @@ use Psl;
|
|||||||
function contains_ci(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): bool
|
function contains_ci(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): bool
|
||||||
{
|
{
|
||||||
if ('' === $needle) {
|
if ('' === $needle) {
|
||||||
Psl\Internal\validate_offset($offset, length($haystack, $encoding));
|
return Psl\Internal\validate_offset($offset, length($haystack, $encoding), true);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null !== search_ci($haystack, $needle, $offset, $encoding);
|
return null !== search_ci($haystack, $needle, $offset, $encoding);
|
||||||
|
Loading…
Reference in New Issue
Block a user