mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat: toUseStrictTypes
This commit is contained in:
@ -13,6 +13,7 @@ use Pest\Arch\Expectations\ToOnlyBeUsedIn;
|
|||||||
use Pest\Arch\Expectations\ToOnlyUse;
|
use Pest\Arch\Expectations\ToOnlyUse;
|
||||||
use Pest\Arch\Expectations\ToUse;
|
use Pest\Arch\Expectations\ToUse;
|
||||||
use Pest\Arch\Expectations\ToUseNothing;
|
use Pest\Arch\Expectations\ToUseNothing;
|
||||||
|
use Pest\Arch\Expectations\ToUseStrictTypes;
|
||||||
use Pest\Concerns\Extendable;
|
use Pest\Concerns\Extendable;
|
||||||
use Pest\Concerns\Pipeable;
|
use Pest\Concerns\Pipeable;
|
||||||
use Pest\Concerns\Retrievable;
|
use Pest\Concerns\Retrievable;
|
||||||
@ -369,6 +370,16 @@ final class Expectation
|
|||||||
return ToUse::make($this, $targets);
|
return ToUse::make($this, $targets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the given expectation target use the "declare(strict_types=1)" declaration.
|
||||||
|
*
|
||||||
|
* @param array<int, string>|string $targets
|
||||||
|
*/
|
||||||
|
public function toUseStrictTypes(): ArchExpectation
|
||||||
|
{
|
||||||
|
return ToUseStrictTypes::make($this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that the given expectation target "only" use on the given dependencies.
|
* Asserts that the given expectation target "only" use on the given dependencies.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -5,15 +5,19 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Expectations;
|
namespace Pest\Expectations;
|
||||||
|
|
||||||
use Pest\Arch\Contracts\ArchExpectation;
|
use Pest\Arch\Contracts\ArchExpectation;
|
||||||
|
use Pest\Arch\Exceptions\ArchExpectationFailedException;
|
||||||
|
use Pest\Arch\Expectations\NotToUseStrictTypes;
|
||||||
use Pest\Arch\Expectations\ToBeUsedIn;
|
use Pest\Arch\Expectations\ToBeUsedIn;
|
||||||
use Pest\Arch\Expectations\ToBeUsedInNothing;
|
use Pest\Arch\Expectations\ToBeUsedInNothing;
|
||||||
use Pest\Arch\Expectations\ToUse;
|
use Pest\Arch\Expectations\ToUse;
|
||||||
|
use Pest\Arch\Expectations\ToUseStrictTypes;
|
||||||
use Pest\Arch\GroupArchExpectation;
|
use Pest\Arch\GroupArchExpectation;
|
||||||
use Pest\Arch\SingleArchExpectation;
|
use Pest\Arch\SingleArchExpectation;
|
||||||
use Pest\Exceptions\InvalidExpectation;
|
use Pest\Exceptions\InvalidExpectation;
|
||||||
use Pest\Expectation;
|
use Pest\Expectation;
|
||||||
use Pest\Support\Arr;
|
use Pest\Support\Arr;
|
||||||
use Pest\Support\Exporter;
|
use Pest\Support\Exporter;
|
||||||
|
use PHPUnit\Framework\AssertionFailedError;
|
||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,6 +75,14 @@ final class OppositeExpectation
|
|||||||
), is_string($targets) ? [$targets] : $targets));
|
), is_string($targets) ? [$targets] : $targets));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the given expectation target does not use the "declare(strict_types=1)" declaration.
|
||||||
|
*/
|
||||||
|
public function toUseStrictTypes(): ArchExpectation
|
||||||
|
{
|
||||||
|
return ToUseStrictTypes::make($this->original, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<int, string>|string $targets
|
* @param array<int, string>|string $targets
|
||||||
*/
|
*/
|
||||||
@ -128,7 +140,7 @@ final class OppositeExpectation
|
|||||||
try {
|
try {
|
||||||
/* @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
$this->original->{$name}(...$arguments);
|
$this->original->{$name}(...$arguments);
|
||||||
} catch (ExpectationFailedException) {
|
} catch (ExpectationFailedException|AssertionFailedError) {
|
||||||
return $this->original;
|
return $this->original;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user