str_contains

Supported Versions: PHP 8
Determine if a string contains a given substring
<?php str_contains(string $haystack, string $needle): bool
<?php                 }



                if ($class->isAbstract() || ($suiteClassFile !== $class->getFileName())) {

                    if (! str_contains($class->getFileName(), 'TestCaseFactory.php')) {

                        continue;

                    }

                }
<?php     public function notify(Skipped $event): void

    {

        if (str_contains($event->message(), '__TODO__')) {

            $this->printTodoItem();

        }
<?php             preg_match('/\((.*?)\)/', $description, $matches);



            if (count($matches) > 1) {

                if (str_contains($description, 'with '.$matches[0].' /')) {

                    $description = str_replace('with '.$matches[0].' /', '', $description);

                } else {

                    $description = str_replace('with '.$matches[0], '', $description);
<?php     {

        return Targeted::make(

            $this,

            fn (ObjectDescription $object): bool => str_contains((string) file_get_contents($object->path), 'declare(strict_types=1);'),

            'to use strict types',

            FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')),

        );
<?php             $this,

            fn (ObjectDescription $object): bool => str_contains((string) file_get_contents($object->path), 'declare(strict_types=1);'),

            'to use strict types',

            FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')),

        );

    }
<?php             $this,

            fn (ObjectDescription $object): bool => ! enum_exists($object->name) && $object->reflectionClass->isFinal(),

            'to be final',

            FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),

        );

    }
<?php             $this,

            fn (ObjectDescription $object): bool => ! enum_exists($object->name) && $object->reflectionClass->isReadOnly() && assert(true), // @phpstan-ignore-line

            'to be readonly',

            FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),

        );

    }
<?php             $this,

            fn (ObjectDescription $object): bool => $object->reflectionClass->isTrait(),

            'to be trait',

            FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),

        );

    }
<?php             $this,

            fn (ObjectDescription $object): bool => $object->reflectionClass->isAbstract(),

            'to be abstract',

            FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),

        );

    }
<?php             $this,

            fn (ObjectDescription $object): bool => $object->reflectionClass->hasMethod($method),

            'to have method',

            FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),

        );

    }
<?php             $this,

            fn (ObjectDescription $object): bool => $object->reflectionClass->isEnum(),

            'to be enum',

            FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),

        );

    }
<?php             $this,

            fn (ObjectDescription $object): bool => $object->reflectionClass->isInterface(),

            'to be interface',

            FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),

        );

    }
<?php             $this,

            fn (ObjectDescription $object): bool => $class === $object->reflectionClass->getName() || $object->reflectionClass->isSubclassOf($class),

            sprintf("to extend '%s'", $class),

            FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),

        );

    }
<?php             $this,

            fn (ObjectDescription $object): bool => $object->reflectionClass->getParentClass() === false,

            'to extend nothing',

            FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),

        );

    }
<?php             $this,

            fn (ObjectDescription $object): bool => $object->reflectionClass->getInterfaceNames() === [],

            'to implement nothing',

            FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),

        );

    }