Skip to content

Commit

Permalink
PHP 8 optimalization
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek committed Feb 11, 2021
1 parent 511c7a6 commit 0110e62
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 39 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
],
"require": {
"php": "^8.0",
"nette/utils": "^3.0",
"nette/caching": "^3.0",
"nette/utils": "^3.2",
"nette/caching": "^3.1",
"nette/di": "^3.0",
"nette/http": "^3.0",
"tracy/tracy": "^2.8",
"baraja-core/service-method-invoker": "^1.0"
"baraja-core/service-method-invoker": "^2.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12.74",
Expand Down
2 changes: 1 addition & 1 deletion src/Component/VueComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function getPosition(): int
*/
protected function escapeHtmlAttr(string $s, bool $double = true): string
{
if (strpos($s, '`') !== false && strpbrk($s, ' <>"\'') === false) {
if (str_contains($s, '`') === true && strpbrk($s, ' <>"\'') === false) {
$s .= ' '; // protection against innerHTML mXSS vulnerability nette/nette#1496
}

Expand Down
5 changes: 2 additions & 3 deletions src/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ public function setPluginServices(array $pluginServices): void


/**
* @param Plugin|PluginInfoEntity|string $plugin
* @param string|null $view (string => filter by specific view, null => return all components for plugin)
* @return PluginComponent[]
*/
public function getComponents($plugin, ?string $view): array
public function getComponents(Plugin|PluginInfoEntity|string $plugin, ?string $view): array
{
if (\is_string($plugin)) {
$plugin = $this->getPluginByType($plugin);
Expand All @@ -104,7 +103,7 @@ public function getComponents($plugin, ?string $view): array
foreach ((new \ReflectionClass($baseEntity))->getInterfaces() as $interface) {
$implements[$interface->getName()] = true;
}
} catch (\ReflectionException $e) {
} catch (\ReflectionException) {
}
}

Expand Down
38 changes: 15 additions & 23 deletions src/SimpleComponent/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,21 @@

final class Button implements SimpleComponent
{
public const VARIANT_PRIMARY = 'primary';

public const VARIANT_SECONDARY = 'secondary';

public const VARIANT_SUCCESS = 'success';

public const VARIANT_DANGER = 'danger';

public const VARIANT_WARNING = 'warning';

public const VARIANT_INFO = 'info';

public const ACTION_DIVIDER = 'divider';

public const ACTION_LINK = 'link';

public const ACTION_LINK_TARGET = 'linkTarget';

public const ACTION_LINK_TAB = 'linkTab';

public const ACTION_MODAL = 'modal';

public const ACTION_METHOD = 'method';
public const
VARIANT_PRIMARY = 'primary',
VARIANT_SECONDARY = 'secondary',
VARIANT_SUCCESS = 'success',
VARIANT_DANGER = 'danger',
VARIANT_WARNING = 'warning',
VARIANT_INFO = 'info';

public const
ACTION_DIVIDER = 'divider',
ACTION_LINK = 'link',
ACTION_LINK_TARGET = 'linkTarget',
ACTION_LINK_TAB = 'linkTab',
ACTION_MODAL = 'modal',
ACTION_METHOD = 'method';

private string $variant;

Expand Down
15 changes: 6 additions & 9 deletions src/SimpleComponent/ContextMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@

final class ContextMenu implements SimpleComponent
{
public const ACTION_DIVIDER = 'divider';

public const ACTION_LINK = 'link';

public const ACTION_LINK_TAB = 'linkTab';

public const ACTION_MODAL = 'modal';

public const ACTION_METHOD = 'method';
public const
ACTION_DIVIDER = 'divider',
ACTION_LINK = 'link',
ACTION_LINK_TAB = 'linkTab',
ACTION_MODAL = 'modal',
ACTION_METHOD = 'method';

private bool $active;

Expand Down

0 comments on commit 0110e62

Please sign in to comment.