Skip to content

Commit 953000a

Browse files
committed
used native PHP 8 functions
1 parent 622f006 commit 953000a

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/Application/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function createInitialRequest(): Request
110110
throw new BadRequestException('No route for HTTP request.');
111111
} elseif (!is_string($presenter)) {
112112
throw new Nette\InvalidStateException('Missing presenter in route definition.');
113-
} elseif (Nette\Utils\Strings::startsWith($presenter, 'Nette:') && $presenter !== 'Nette:Micro') {
113+
} elseif (str_starts_with($presenter, 'Nette:') && $presenter !== 'Nette:Micro') {
114114
throw new BadRequestException('Invalid request. Presenter is not achievable.');
115115
}
116116

src/Application/UI/Component.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function checkRequirements($element): void
120120
{
121121
if (
122122
$element instanceof \ReflectionMethod
123-
&& substr($element->getName(), 0, 6) === 'handle'
123+
&& str_starts_with($element->getName(), 'handle')
124124
&& !ComponentReflection::parseAnnotation($element, 'crossOrigin')
125125
&& !$element->getAttributes(Nette\Application\Attributes\CrossOrigin::class)
126126
&& !$this->getPresenter()->getHttpRequest()->isSameSite()

src/Application/UI/Presenter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function getUniqueId(): string
154154
public function isModuleCurrent(string $module): bool
155155
{
156156
$current = Helpers::splitName($this->getName())[0];
157-
return Nette\Utils\Strings::startsWith($current . ':', ltrim($module . ':', ':'));
157+
return str_starts_with($current . ':', ltrim($module . ':', ':'));
158158
}
159159

160160

@@ -781,7 +781,7 @@ protected function createRequest(
781781
throw new InvalidLinkException("Unable to pass parameters to 'this!' signal.");
782782
}
783783

784-
} elseif (strpos($signal, self::NAME_SEPARATOR) === false) {
784+
} elseif (!str_contains($signal, self::NAME_SEPARATOR)) {
785785
// counterpart of signalReceived() & tryCall()
786786
$method = $component->formatSignalMethod($signal);
787787
if (!$reflection->hasCallableMethod($method)) {

src/Bridges/ApplicationDI/LatteExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ public function addMacro(string $macro): void
120120
$definition = $builder->getDefinition($this->prefix('latteFactory'))->getResultDefinition();
121121

122122
if (($macro[0] ?? null) === '@') {
123-
if (strpos($macro, '::') === false) {
124-
$method = 'install';
125-
} else {
123+
if (str_contains($macro, '::')) {
126124
[$macro, $method] = explode('::', $macro);
125+
} else {
126+
$method = 'install';
127127
}
128128
$definition->addSetup('?->onCompile[] = function ($engine) { ?->' . $method . '($engine->getCompiler()); }', ['@self', $macro]);
129129

130130
} else {
131-
if (strpos($macro, '::') === false && class_exists($macro)) {
131+
if (!str_contains($macro, '::') && class_exists($macro)) {
132132
$macro .= '::install';
133133
}
134134
$definition->addSetup('?->onCompile[] = function ($engine) { ' . $macro . '($engine->getCompiler()); }', ['@self']);

0 commit comments

Comments
 (0)