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"
|
||||
|
||||
on: ["pull_request", "push"]
|
||||
on:
|
||||
pull_request: ~
|
||||
push: ~
|
||||
|
||||
jobs:
|
||||
code-coverage:
|
||||
|
4
.github/workflows/coding-standards.yml
vendored
4
.github/workflows/coding-standards.yml
vendored
@ -1,6 +1,8 @@
|
||||
name: "coding standards"
|
||||
|
||||
on: ["pull_request", "push"]
|
||||
on:
|
||||
pull_request: ~
|
||||
push: ~
|
||||
|
||||
jobs:
|
||||
coding-standards:
|
||||
|
4
.github/workflows/documentation-check.yml
vendored
4
.github/workflows/documentation-check.yml
vendored
@ -1,6 +1,8 @@
|
||||
name: "documentation check"
|
||||
|
||||
on: ["pull_request", "push"]
|
||||
on:
|
||||
pull_request: ~
|
||||
push: ~
|
||||
|
||||
jobs:
|
||||
doc-check:
|
||||
|
4
.github/workflows/security-analysis.yml
vendored
4
.github/workflows/security-analysis.yml
vendored
@ -1,6 +1,8 @@
|
||||
name: "security analysis"
|
||||
|
||||
on: ["pull_request", "push"]
|
||||
on:
|
||||
pull_request: ~
|
||||
push: ~
|
||||
|
||||
jobs:
|
||||
security-analysis:
|
||||
|
6
.github/workflows/static-analysis.yml
vendored
6
.github/workflows/static-analysis.yml
vendored
@ -1,6 +1,10 @@
|
||||
name: "static analysis"
|
||||
|
||||
on: ["pull_request", "push"]
|
||||
on:
|
||||
pull_request: ~
|
||||
push: ~
|
||||
schedule:
|
||||
- cron: '0 */3 * * *'
|
||||
|
||||
jobs:
|
||||
static-analysis:
|
||||
|
4
.github/workflows/unit-tests.yml
vendored
4
.github/workflows/unit-tests.yml
vendored
@ -1,6 +1,8 @@
|
||||
name: "unit tests"
|
||||
|
||||
on: ["pull_request", "push"]
|
||||
on:
|
||||
pull_request: ~
|
||||
push: ~
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
- [algorithms](./../../src/Psl/Hash/algorithms.php#L16)
|
||||
- [equals](./../../src/Psl/Hash/equals.php#L14)
|
||||
- [hash](./../../src/Psl/Hash/hash.php#L16)
|
||||
- [hash](./../../src/Psl/Hash/hash.php#L17)
|
||||
|
||||
#### `Classes`
|
||||
|
||||
|
21
psalm.xml
21
psalm.xml
@ -1,20 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<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"
|
||||
>
|
||||
<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">
|
||||
<projectFiles>
|
||||
<directory name="src" />
|
||||
<directory name="integration" />
|
||||
@ -59,10 +44,6 @@
|
||||
<RedundantCondition errorLevel="suppress" />
|
||||
<RedundantCast 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>
|
||||
|
||||
<plugins>
|
||||
|
@ -84,11 +84,18 @@ final class Context
|
||||
* Pump data into an active hashing context.
|
||||
*
|
||||
* @psalm-mutation-free
|
||||
*
|
||||
* @throws Exception\RuntimeException If unable to pump data into the active hashing context.
|
||||
*/
|
||||
public function update(string $data): Context
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
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.
|
||||
*
|
||||
* @throws Psl\Exception\InvariantViolationException If the given algorithm is unsupported.
|
||||
* @throws Hash\Exception\RuntimeException If unable to pump data into the hashing context.
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
|
@ -10,6 +10,7 @@ use Psl;
|
||||
* Generate a hash value (message digest).
|
||||
*
|
||||
* @throws Psl\Exception\InvariantViolationException If the given algorithm is unsupported.
|
||||
* @throws Exception\RuntimeException If unable to pump data into the hashing context.
|
||||
*
|
||||
* @pure
|
||||
*/
|
||||
|
@ -612,6 +612,8 @@ final class Loader
|
||||
'Psl\Type\Type',
|
||||
'Psl\Json\Exception\DecodeException',
|
||||
'Psl\Json\Exception\EncodeException',
|
||||
'Psl\Hash\Exception\ExceptionInterface',
|
||||
'Psl\Hash\Exception\RuntimeException',
|
||||
'Psl\Hash\Context',
|
||||
'Psl\Encoding\Exception\IncorrectPaddingException',
|
||||
'Psl\Encoding\Exception\RangeException',
|
||||
|
@ -17,8 +17,10 @@ use Psl;
|
||||
* @throws Psl\Exception\InvariantViolationException If the offset is out-of-bounds.
|
||||
*
|
||||
* @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;
|
||||
|
||||
@ -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);
|
||||
|
||||
if (!$assert) {
|
||||
return $offset;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -21,9 +21,7 @@ use Psl;
|
||||
function contains(string $haystack, string $needle, int $offset = 0): bool
|
||||
{
|
||||
if ('' === $needle) {
|
||||
Psl\Internal\validate_offset($offset, length($haystack));
|
||||
|
||||
return true;
|
||||
return Psl\Internal\validate_offset($offset, length($haystack), true);
|
||||
}
|
||||
|
||||
return null !== search($haystack, $needle, $offset);
|
||||
|
@ -20,10 +20,9 @@ use Psl;
|
||||
*/
|
||||
function contains_ci(string $haystack, string $needle, int $offset = 0): bool
|
||||
{
|
||||
$length = length($haystack);
|
||||
if ('' === $needle) {
|
||||
Psl\Internal\validate_offset($offset, length($haystack));
|
||||
|
||||
return true;
|
||||
return Psl\Internal\validate_offset($offset, $length, true);
|
||||
}
|
||||
|
||||
return null !== search_ci($haystack, $needle, $offset);
|
||||
|
@ -21,9 +21,7 @@ use Psl;
|
||||
function contains(string $haystack, string $needle, int $offset = 0): bool
|
||||
{
|
||||
if ('' === $needle) {
|
||||
Psl\Internal\validate_offset($offset, length($haystack));
|
||||
|
||||
return true;
|
||||
return Psl\Internal\validate_offset($offset, length($haystack), true);
|
||||
}
|
||||
|
||||
return null !== search($haystack, $needle, $offset);
|
||||
|
@ -21,9 +21,7 @@ use Psl;
|
||||
function contains_ci(string $haystack, string $needle, int $offset = 0): bool
|
||||
{
|
||||
if ('' === $needle) {
|
||||
Psl\Internal\validate_offset($offset, length($haystack));
|
||||
|
||||
return true;
|
||||
return Psl\Internal\validate_offset($offset, length($haystack), true);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
if ('' === $needle) {
|
||||
Psl\Internal\validate_offset($offset, length($haystack, $encoding));
|
||||
|
||||
return true;
|
||||
return Psl\Internal\validate_offset($offset, length($haystack, $encoding), true);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
if ('' === $needle) {
|
||||
Psl\Internal\validate_offset($offset, length($haystack, $encoding));
|
||||
|
||||
return true;
|
||||
return Psl\Internal\validate_offset($offset, length($haystack, $encoding), true);
|
||||
}
|
||||
|
||||
return null !== search_ci($haystack, $needle, $offset, $encoding);
|
||||
|
Loading…
Reference in New Issue
Block a user