Skip to content

Commit c8c033d

Browse files
committed
Revert "Add support for contains, startsWith, startsWithLetter and endsWith"
This reverts commit 19b869e.
1 parent 8b080dc commit c8c033d

File tree

3 files changed

+0
-79
lines changed

3 files changed

+0
-79
lines changed

README.md

-4
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ This extension specifies types of values passed to:
6969
* `Assert::methodExists`
7070
* `Assert::propertyExists`
7171
* `Assert::isArrayAccessible`
72-
* `Assert::contains`
73-
* `Assert::startsWith`
74-
* `Assert::startsWithLetter`
75-
* `Assert::endsWith`
7672
* `Assert::unicodeLetters`
7773
* `Assert::alpha`
7874
* `Assert::digits`

src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php

-33
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class AssertTypeSpecifyingExtension implements StaticMethodTypeSpecifyingExtensi
3030

3131
private const ASSERTIONS_RESULTING_IN_NON_EMPTY_STRING = [
3232
'stringNotEmpty',
33-
'startsWithLetter',
3433
'unicodeLetters',
3534
'alpha',
3635
'digits',
@@ -486,27 +485,6 @@ private static function getExpressionResolvers(): array
486485
)
487486
);
488487
},
489-
'contains' => function (Scope $scope, Arg $value, Arg $subString): \PhpParser\Node\Expr {
490-
if ($scope->getType($subString->value)->isNonEmptyString()->yes()) {
491-
return self::createIsNonEmptyStringExpression([$value]);
492-
}
493-
494-
return self::createIsStringExpression([$value]);
495-
},
496-
'startsWith' => function (Scope $scope, Arg $value, Arg $prefix): \PhpParser\Node\Expr {
497-
if ($scope->getType($prefix->value)->isNonEmptyString()->yes()) {
498-
return self::createIsNonEmptyStringExpression([$value]);
499-
}
500-
501-
return self::createIsStringExpression([$value]);
502-
},
503-
'endsWith' => function (Scope $scope, Arg $value, Arg $suffix): \PhpParser\Node\Expr {
504-
if ($scope->getType($suffix->value)->isNonEmptyString()->yes()) {
505-
return self::createIsNonEmptyStringExpression([$value]);
506-
}
507-
508-
return self::createIsStringExpression([$value]);
509-
},
510488
'length' => function (Scope $scope, Arg $value, Arg $length): \PhpParser\Node\Expr {
511489
return new BooleanAnd(
512490
new \PhpParser\Node\Expr\FuncCall(
@@ -709,17 +687,6 @@ private function arrayOrIterable(
709687
);
710688
}
711689

712-
/**
713-
* @param \PhpParser\Node\Arg[] $args
714-
*/
715-
private static function createIsStringExpression(array $args): \PhpParser\Node\Expr
716-
{
717-
return new \PhpParser\Node\Expr\FuncCall(
718-
new \PhpParser\Node\Name('is_string'),
719-
[$args[0]]
720-
);
721-
}
722-
723690
/**
724691
* @param \PhpParser\Node\Arg[] $args
725692
*/

tests/Type/WebMozartAssert/data/string.php

-42
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,6 @@
77
class TestStrings
88
{
99

10-
/**
11-
* @param non-empty-string $b
12-
*/
13-
public function contains(string $a, string $b): void
14-
{
15-
Assert::contains($a, $a);
16-
\PHPStan\Testing\assertType('string', $a);
17-
18-
Assert::contains($a, $b);
19-
\PHPStan\Testing\assertType('non-empty-string', $a);
20-
}
21-
22-
/**
23-
* @param non-empty-string $b
24-
*/
25-
public function startsWith(string $a, string $b): void
26-
{
27-
Assert::startsWith($a, $a);
28-
\PHPStan\Testing\assertType('string', $a);
29-
30-
Assert::startsWith($a, $b);
31-
\PHPStan\Testing\assertType('non-empty-string', $a);
32-
}
33-
34-
public function startsWithLetter(string $a): void
35-
{
36-
Assert::startsWithLetter($a);
37-
\PHPStan\Testing\assertType('non-empty-string', $a);
38-
}
39-
40-
/**
41-
* @param non-empty-string $b
42-
*/
43-
public function endsWith(string $a, string $b): void
44-
{
45-
Assert::endsWith($a, $a);
46-
\PHPStan\Testing\assertType('string', $a);
47-
48-
Assert::endsWith($a, $b);
49-
\PHPStan\Testing\assertType('non-empty-string', $a);
50-
}
51-
5210
public function length(string $a, string $b): void
5311
{
5412
Assert::length($a, 0);

0 commit comments

Comments
 (0)