Skip to content

Commit 62ae901

Browse files
Merge branch '4.4' into 5.2
* 4.4: Leverage str_contains/str_starts_with Leverage str_ends_with
2 parents bcb47bb + 4c21f24 commit 62ae901

26 files changed

+56
-56
lines changed

Alias.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function setDeprecated(/* string $package, string $version, string $messa
112112
throw new InvalidArgumentException('Invalid characters found in deprecation template.');
113113
}
114114

115-
if (false === strpos($message, '%alias_id%')) {
115+
if (!str_contains($message, '%alias_id%')) {
116116
throw new InvalidArgumentException('The deprecation template must contain the "%alias_id%" placeholder.');
117117
}
118118
}

ChildDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function replaceArgument($index, $value)
9393
{
9494
if (\is_int($index)) {
9595
$this->arguments['index_'.$index] = $value;
96-
} elseif (0 === strpos($index, '$')) {
96+
} elseif (str_starts_with($index, '$')) {
9797
$this->arguments[$index] = $value;
9898
} else {
9999
throw new InvalidArgumentException('The argument must be an existing index or the name of a constructor\'s parameter.');

Compiler/AutowirePass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ private function getAutowiredReference(TypedReference $reference): ?TypedReferen
297297

298298
if ($this->container->has($name) && !$this->container->findDefinition($name)->isAbstract()) {
299299
foreach ($this->container->getAliases() as $id => $alias) {
300-
if ($name === (string) $alias && 0 === strpos($id, $type.' $')) {
300+
if ($name === (string) $alias && str_starts_with($id, $type.' $')) {
301301
return new TypedReference($name, $type, $reference->getInvalidBehavior());
302302
}
303303
}

Compiler/CheckDefinitionValidityPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function process(ContainerBuilder $container)
4949
throw new RuntimeException(sprintf('Please add the class to service "%s" even if it is constructed by a factory since we might need to add method calls based on compile-time checks.', $id));
5050
}
5151
if (class_exists($id) || interface_exists($id, false)) {
52-
if (0 === strpos($id, '\\') && 1 < substr_count($id, '\\')) {
52+
if (str_starts_with($id, '\\') && 1 < substr_count($id, '\\')) {
5353
throw new RuntimeException(sprintf('The definition for "%s" has no class attribute, and appears to reference a class or interface. Please specify the class attribute explicitly or remove the leading backslash by renaming the service to "%s" to get rid of this error.', $id, substr($id, 1)));
5454
}
5555

Compiler/CheckTypeDeclarationsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private function checkType(Definition $checkedDefinition, $value, \ReflectionPar
231231
$value = $this->container->getParameter(substr($value, 1, -1));
232232
}
233233

234-
if ($envPlaceholderUniquePrefix && \is_string($value) && false !== strpos($value, 'env_')) {
234+
if ($envPlaceholderUniquePrefix && \is_string($value) && str_contains($value, 'env_')) {
235235
// If the value is an env placeholder that is either mixed with a string or with another env placeholder, then its resolved value will always be a string, so we don't need to resolve it.
236236
// We don't need to change the value because it is already a string.
237237
if ('' === preg_replace('/'.$envPlaceholderUniquePrefix.'_\w+_[a-f0-9]{32}/U', '', $value, -1, $c) && 1 === $c) {

Compiler/Compiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function addPass(CompilerPassInterface $pass, string $type = PassConfig::
6464
*/
6565
public function log(CompilerPassInterface $pass, string $message)
6666
{
67-
if (false !== strpos($message, "\n")) {
67+
if (str_contains($message, "\n")) {
6868
$message = str_replace("\n", "\n".\get_class($pass).': ', trim($message));
6969
}
7070

Compiler/MergeExtensionConfigurationPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs
209209
}
210210

211211
foreach ($bag->getEnvPlaceholders() as $env => $placeholders) {
212-
if (false === strpos($env, ':')) {
212+
if (!str_contains($env, ':')) {
213213
continue;
214214
}
215215
foreach ($placeholders as $placeholder) {

Compiler/RegisterServiceSubscribersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function processValue($value, bool $isRoot = false)
9191
if ($name) {
9292
if (false !== $i = strpos($name, '::get')) {
9393
$name = lcfirst(substr($name, 5 + $i));
94-
} elseif (false !== strpos($name, '::')) {
94+
} elseif (str_contains($name, '::')) {
9595
$name = null;
9696
}
9797
}

Compiler/ResolveBindingsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function process(ContainerBuilder $container)
4444
foreach ($this->unusedBindings as [$key, $serviceId, $bindingType, $file]) {
4545
$argumentType = $argumentName = $message = null;
4646

47-
if (false !== strpos($key, ' ')) {
47+
if (str_contains($key, ' ')) {
4848
[$argumentType, $argumentName] = explode(' ', $key, 2);
4949
} elseif ('$' === $key[0]) {
5050
$argumentName = $key;

Compiler/ResolveChildDefinitionsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private function doResolveDefinition(ChildDefinition $definition): Definition
164164
foreach ($definition->getArguments() as $k => $v) {
165165
if (is_numeric($k)) {
166166
$def->addArgument($v);
167-
} elseif (0 === strpos($k, 'index_')) {
167+
} elseif (str_starts_with($k, 'index_')) {
168168
$def->replaceArgument((int) substr($k, \strlen('index_')), $v);
169169
} else {
170170
$def->setArgument($k, $v);

0 commit comments

Comments
 (0)