Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e84efa0
chore: replace SpoonFilter::urlise with Uri::getUrl
tijsverkoyen Jan 27, 2026
1ec9806
chore: replace SpoonFilter::ucfirst with Symfony String->title()
tijsverkoyen Jan 27, 2026
5aee26f
chore: replace SpoonFilter::isValidAgainstRegexp with Symfony validat…
tijsverkoyen Jan 27, 2026
6af3a82
chore: site_domains is not use anywhere
tijsverkoyen Jan 27, 2026
ae0b617
chore: replace SpoonFilter::isURL with Symfony Validator
tijsverkoyen Jan 27, 2026
86dd6b8
chore: fix usages of default arguments for SpoonFilter::toCamelCase
tijsverkoyen Jan 28, 2026
6aaec8e
chore: Replace SpoonFilter::replaceURLsWithAnchors with Symfony Strin…
tijsverkoyen Jan 28, 2026
d9ce04f
chore: replace SpoonFilter::isNumeric with ctype_digit
tijsverkoyen Jan 28, 2026
edf413e
chore: replace SpoonFilter::isInteger with filter_var
tijsverkoyen Jan 28, 2026
7e63a18
chore: replace SpoonFilter::htmlspecialcharsDecode with native htmlsp…
tijsverkoyen Jan 28, 2026
83f74ff
chore: replace SpoonFilter::arrayMapRecursive with array_walk_recursive
tijsverkoyen Jan 28, 2026
39fe877
chore: replace SpoonFilter::htmlspecialchars with native htmlspecialc…
tijsverkoyen Jan 28, 2026
e9d7465
chore: replace SpoonFilter::htmlentitiesDecode with native html_entit…
tijsverkoyen Jan 28, 2026
1c02fbd
chore: replace SpoonFilter::htmlentities with native htmlentities
tijsverkoyen Jan 28, 2026
93b9226
chore: UTF8 is the default
tijsverkoyen Jan 28, 2026
81268b1
chore: replace SpoonFilter::getValue with logic in the code
tijsverkoyen Jan 28, 2026
7d516f7
chore: replace SpoonFilter::toCamelCase with Symfony string implement…
tijsverkoyen Jan 29, 2026
d03f55f
chore: cleanup unused use SpoonFilter statements
tijsverkoyen Jan 29, 2026
6d128c6
fix: run workflow only once
tijsverkoyen Jan 29, 2026
15239ba
fix: fix wrong logic for ucfirst
tijsverkoyen Jan 29, 2026
5ea6649
fix: fix wrong logic for camelcase
tijsverkoyen Jan 29, 2026
7056de5
fix: some fixes, based on Sourcery and CoPilot feedback
tijsverkoyen Jan 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: CI

on:
push: ~
push:
branches:
- master
pull_request: ~
workflow_dispatch: ~

Expand Down
5 changes: 3 additions & 2 deletions src/Backend/Core/Engine/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use DateTime;
use DateTimeZone;
use RuntimeException;
use function Symfony\Component\String\s;

/**
* The class below will handle all authentication stuff. It will handle module-access, action-access, ...
Expand Down Expand Up @@ -170,7 +171,7 @@ public static function isAllowedAction(?string $action = null, ?string $module =
// The url should only be taken from the container if the action and or module isn't set
// This way we can use the command also in the a console command
$action = $action ?: BackendModel::get('url')->getAction();
$module = \SpoonFilter::toCamelCase($module ?: BackendModel::get('url')->getModule());
$module = s($module ?: BackendModel::get('url')->getModule())->camel()->title()->toString();

// is this action an action that doesn't require authentication?
if (isset($alwaysAllowed[$module][$action])) {
Expand Down Expand Up @@ -220,7 +221,7 @@ public static function isAllowedModule(string $module): bool
{
$modules = BackendModel::getModules();
$alwaysAllowed = array_keys(self::getAlwaysAllowed());
$module = \SpoonFilter::toCamelCase($module);
$module = s($module)->camel()->title()->toString();

// is this module a module that doesn't require user level authentication?
if (in_array($module, $alwaysAllowed, true)) {
Expand Down
17 changes: 11 additions & 6 deletions src/Backend/Core/Engine/Base/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

namespace Backend\Core\Engine\Base;

use Backend\Core\Engine\Header;
use Backend\Core\Engine\Model as BackendModel;
use Backend\Core\Engine\Url;
use Backend\Core\Engine\TwigTemplate;
use Backend\Core\Language\Language as BL;
use Common\Exception\RedirectException;
use ForkCMS\App\KernelLoader;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Backend\Core\Engine\Header;
use Backend\Core\Language\Language as BL;
use Backend\Core\Engine\Model as BackendModel;
use Backend\Core\Engine\Url;
use function Symfony\Component\String\s;

/**
* This class implements a lot of functionality that can be extended by a specific action
Expand Down Expand Up @@ -171,7 +172,9 @@ public function execute(): void
$this->template->assign('report', true);

// camelcase the string
$messageName = strip_tags(\SpoonFilter::toCamelCase($this->getRequest()->query->get('report'), '-'));
$messageName = strip_tags(
s($this->getRequest()->query->get('report'))->replace('-', ' ')->camel()->title()->toString()
);

// if we have data to use it will be passed as the var parameter
if (!empty($var)) {
Expand All @@ -189,7 +192,9 @@ public function execute(): void
// is there an error to show?
if ($this->getRequest()->query->get('error', '') !== '') {
// camelcase the string
$errorName = strip_tags(\SpoonFilter::toCamelCase($this->getRequest()->query->get('error'), '-'));
$errorName = strip_tags(
s($this->getRequest()->query->get('error'))->replace('-', ' ')->camel()->title()->toString()
);

// if we have data to use it will be passed as the var parameter
if (!empty($var)) {
Expand Down
3 changes: 1 addition & 2 deletions src/Backend/Core/Engine/Base/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ public function isAllowed(): bool
*/
protected function setColumn(string $column): void
{
$allowedColumns = ['left', 'middle', 'right'];
$this->column = \SpoonFilter::getValue($column, $allowedColumns, 'left');
$this->column = in_array($column, ['left', 'middle', 'right'], true) ? $column : 'left';
}

protected function setPosition(int $position): void
Expand Down
18 changes: 9 additions & 9 deletions src/Backend/Core/Engine/DataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Backend\Core\Engine\Model as BackendModel;
use Backend\Core\Language\Language as BackendLanguage;
use SpoonDatagridSource;
use SpoonFilter;
use SpoonFormDropdown;
use function Symfony\Component\String\s;

/**
* This is our extended version of \SpoonDataGrid
Expand Down Expand Up @@ -74,7 +74,7 @@ public function __construct(SpoonDatagridSource $source)

// set default label
$this->setHeaderLabels(
[$column => SpoonFilter::ucfirst(BackendLanguage::lbl(SpoonFilter::toCamelCase($column)))]
[$column => s(BackendLanguage::lbl(s($column)->replace('_', ' ')->camel()->title()->toString()))->title()->toString()]
);
}

Expand Down Expand Up @@ -120,7 +120,7 @@ public function addColumn(
$value =
'<a href="' . $url . '" class="btn btn-default btn-xs pull-right">' .
($icon ? '<span class="fa ' . $icon . '" aria-hidden="true"></span>&nbsp;' : '') .
SpoonFilter::ucfirst($value) .
s($value)->title() .
'</a>';

// reset URL
Expand All @@ -132,7 +132,7 @@ public function addColumn(
$value =
'<a href="' . $url . '" class="btn btn-default btn-xs">' .
($icon ? '<span class="fa ' . $icon . '"></span>&nbsp;' : '') .
SpoonFilter::ucfirst($value) .
s($value)->title() .
'</a>';

// reset URL
Expand Down Expand Up @@ -162,7 +162,7 @@ public function addColumn(
// add special attributes for actions we know
$this->setColumnAttributes(
$name,
['class' => 'fork-data-grid-action action' . SpoonFilter::toCamelCase($name)]
['class' => 'fork-data-grid-action action' . s($name)->replace('_', ' ')->camel()->title()]
);
}

Expand Down Expand Up @@ -221,7 +221,7 @@ public function addColumnAction(
$this->setColumnAttributes(
$name,
[
'class' => 'fork-data-grid-action action' . SpoonFilter::toCamelCase($name),
'class' => 'fork-data-grid-action action' . s($name)->replace('_', ' ')->camel()->title(),
'style' => 'width: 10%;',
]
);
Expand Down Expand Up @@ -404,7 +404,7 @@ public function setColumnConfirm($column, $message, $custom = null, $title = nul

// set title if there wasn't one provided
if ($title === null) {
$title = SpoonFilter::ucfirst(BackendLanguage::lbl('Delete') . '?');
$title = s(BackendLanguage::lbl('Delete') . '?')->title()->toString();
}

// grab current value
Expand Down Expand Up @@ -492,11 +492,11 @@ public function setMassAction(SpoonFormDropdown $actionDropDown): void
// build HTML
$HTML =
'<label for="' . $actionDropDown->getAttribute('id') . '">' .
SpoonFilter::ucfirst(BackendLanguage::lbl('WithSelected')) .
s(BackendLanguage::lbl('WithSelected'))->title() .
'</label>' .
$actionDropDown->parse() .
'<button type="button" class="btn btn-default jsMassActionSubmit">' .
' <span>' . SpoonFilter::ucfirst(BackendLanguage::lbl('Execute')) . '</span>' .
' <span>' . s(BackendLanguage::lbl('Execute'))->title() . '</span>' .
'</button>';

// assign parsed html
Expand Down
13 changes: 8 additions & 5 deletions src/Backend/Core/Engine/DataGridFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Backend\Core\Engine\Model as BackendModel;
use Backend\Core\Language\Language as BackendLanguage;
use SpoonDate;
use SpoonFilter;
use function Symfony\Component\String\s;

/**
* A set of commonly used functions that will be applied on rows or columns
Expand All @@ -23,8 +23,11 @@ class DataGridFunctions
*/
public static function cleanupPlainText(string $var): string
{
// detect links
$var = SpoonFilter::replaceURLsWithAnchors($var);
// replace links with a tags
$var = s($var)->replaceMatches(
'~(https?://[^\s]+)~',
'<a href="$1" rel="nofollow noopener">$1</a>'
)->toString();

// replace newlines
$var = str_replace("\r", '', $var);
Expand Down Expand Up @@ -295,7 +298,7 @@ public static function truncate(string $string, int $length, bool $useHellip = t

// less characters
if (mb_strlen($string) <= $length) {
return SpoonFilter::htmlspecialchars($string);
return htmlspecialchars($string);
}

// more characters
Expand All @@ -312,7 +315,7 @@ public static function truncate(string $string, int $length, bool $useHellip = t
$string .= '…';
}

return SpoonFilter::htmlspecialchars($string);
return htmlspecialchars($string);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Backend/Core/Engine/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use SpoonFormFile;
use SpoonFormTextarea;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use function Symfony\Component\String\s;

/**
* This is our extended version of \SpoonForm
Expand All @@ -31,7 +32,7 @@ public function __construct(
$url = BackendModel::getContainer()->get('url');

parent::__construct(
$name ?? \SpoonFilter::toCamelCase($url->getModule() . '_' . $url->getAction(), '_', true),
$name ?? s($url->getModule() . ' ' . $url->getAction())->camel()->toString(),
$action,
$method ?? 'post',
null,
Expand Down
8 changes: 4 additions & 4 deletions src/Backend/Core/Engine/FormFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Backend\Core\Engine;

use SpoonFilter;
use Backend\Core\Language\Language as BackendLanguage;
use function Symfony\Component\String\s;

/**
* This is our extended version of \SpoonFormFile
Expand Down Expand Up @@ -72,9 +72,9 @@ public function parse($template = null): string

// parse to template
if ($template !== null) {
$template->assign('file' . SpoonFilter::toCamelCase($this->attributes['name']), $output);
$template->assign('file' . s($this->attributes['name'])->replace('_', ' ')->camel()->title(), $output);
$template->assign(
'file' . SpoonFilter::toCamelCase($this->attributes['name']) . 'Error',
'file' . s($this->attributes['name'])->replace('_', ' ')->camel()->title() . 'Error',
($this->errors != '') ? '<span class="formError text-danger">' . $this->errors . '</span>' : ''
);
}
Expand All @@ -95,7 +95,7 @@ public function getErrors(): ?string
$imageError = $_FILES[$this->getName()]['error'];
if ($imageError === UPLOAD_ERR_INI_SIZE && empty($this->errors)) {
$this->addError(
SpoonFilter::ucfirst(sprintf(BackendLanguage::err('FileTooBig'), Form::getUploadMaxFileSize()))
s(sprintf(BackendLanguage::err('FileTooBig'), Form::getUploadMaxFileSize()))->title()->toString()
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Backend/Core/Engine/FormImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Backend\Core\Engine;

use ForkCMS\Utility\Thumbnails;
use SpoonFilter;
use SpoonFormImage;
use Symfony\Component\Filesystem\Filesystem;
use Backend\Core\Language\Language as BackendLanguage;
use function Symfony\Component\String\s;

/**
* This is our extended version of \SpoonFormFile
Expand Down Expand Up @@ -82,7 +82,7 @@ public function getErrors(): ?string
$imageError = $_FILES[$this->getName()]['error'];
if ($imageError === UPLOAD_ERR_INI_SIZE && empty($this->errors)) {
$this->addError(
SpoonFilter::ucfirst(sprintf(BackendLanguage::err('FileTooBig'), Form::getUploadMaxFileSize()))
s(sprintf(BackendLanguage::err('FileTooBig'), Form::getUploadMaxFileSize()))->title()->toString()
);
}
}
Expand Down Expand Up @@ -137,9 +137,9 @@ public function parse($template = null): string

// parse to template
if ($template !== null) {
$template->assign('file' . SpoonFilter::toCamelCase($this->attributes['name']), $output);
$template->assign('file' . s($this->attributes['name'])->replace('_', ' ')->camel()->title(), $output);
$template->assign(
'file' . SpoonFilter::toCamelCase($this->attributes['name']) . 'Error',
'file' . s($this->attributes['name'])->replace('_', ' ')->camel()->title() . 'Error',
($this->errors != '') ? '<span class="formError text-danger">' . $this->errors . '</span>' : ''
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Backend/Core/Engine/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ protected function loadForm(): void
$this->form->addHidden('custom', $this->custom);
$this->form->addHidden('class_name', $this->callback['class']);
$this->form->addHidden('method_name', $this->callback['method']);
$this->form->addHidden('parameters', \SpoonFilter::htmlspecialchars(serialize($this->callback['parameters'])));
$this->form->addHidden('parameters', htmlspecialchars(serialize($this->callback['parameters'])));

if (!empty($this->hreflangCallback)) {
foreach (BackendLanguage::getActiveLanguages() as $language) {
Expand Down Expand Up @@ -545,7 +545,7 @@ public function validate(): void
// URL overwrite is checked
if ($this->form->getField('url_overwrite')->isChecked()) {
$this->form->getField('url')->isFilled(BackendLanguage::err('FieldIsRequired'));
$url = \SpoonFilter::htmlspecialcharsDecode($this->form->getField('url')->getValue());
$url = htmlspecialchars_decode((string) $this->form->getField('url')->getValue());
$generatedUrl = $this->generateUrl($url);

// check if urls are different
Expand Down Expand Up @@ -583,15 +583,15 @@ public function validate(): void
$this->data['title_overwrite'] = $this->form->getField('page_title_overwrite')->isChecked();
$this->data['url'] = $this->generateUrl(
$this->form->getField('url_overwrite')->getActualValue(
\SpoonFilter::htmlspecialcharsDecode($this->form->getField('url')->getValue()),
\SpoonFilter::htmlspecialcharsDecode($this->form->getField($this->baseFieldName)->getValue())
htmlspecialchars_decode((string) $this->form->getField('url')->getValue()),
htmlspecialchars_decode((string) $this->form->getField($this->baseFieldName)->getValue())
)
);
$this->data['url_overwrite'] = $this->form->getField('url_overwrite')->isChecked();

if ($this->form->getField('canonical_url_overwrite')->isChecked()) {
$this->data['data']['canonical_url'] = $this->form->getField('canonical_url_overwrite')->getActualValue(
\SpoonFilter::htmlspecialcharsDecode($this->form->getField('canonical_url')->getValue()),
htmlspecialchars_decode((string) $this->form->getField('canonical_url')->getValue()),
null
);
$this->data['data']['canonical_url_overwrite'] = true;
Expand Down
7 changes: 4 additions & 3 deletions src/Backend/Core/Engine/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Backend\Core\Engine\Model as BackendModel;
use Frontend\Core\Language\Language as FrontendLanguage;
use Backend\Core\Language\Language as BackendLanguage;
use function Symfony\Component\String\s;

/**
* In this file we store all generic functions that we will be using in the backend.
Expand Down Expand Up @@ -418,7 +419,7 @@ public static function getModulesForDropDown(): array

// loop and add into the return-array (with correct label)
foreach ($modules as $module) {
$dropDown[$module] = \SpoonFilter::ucfirst(BackendLanguage::lbl(\SpoonFilter::toCamelCase($module)));
$dropDown[$module] = s(BackendLanguage::lbl(s($module)->camel()->title()->toString()))->title()->toString();
}

return $dropDown;
Expand Down Expand Up @@ -606,7 +607,7 @@ public static function getUrlForBlock(

// append action
if ($action !== null) {
$url .= '/' . urldecode(FrontendLanguage::act(\SpoonFilter::toCamelCase($action)));
$url .= '/' . urldecode(FrontendLanguage::act(s($action)->camel()->title()->toString()));
}

// return the unique URL!
Expand All @@ -628,7 +629,7 @@ public static function imageDelete(
?array $fileSizes = null
): void {
if (empty($fileSizes)) {
$model = get_class_vars('Backend' . \SpoonFilter::toCamelCase($module) . 'Model');
$model = get_class_vars('Backend' . s($module)->camel()->title() . 'Model');
$fileSizes = $model['fileSizes'];
}

Expand Down
5 changes: 3 additions & 2 deletions src/Backend/Core/Engine/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Backend\Core\Engine\Model as BackendModel;
use Backend\Modules\Pages\Engine\Model as BackendPagesModel;
use Backend\Core\Language\Language as BackendLanguage;
use function Symfony\Component\String\s;

final class Navigation extends KernelLoader
{
Expand Down Expand Up @@ -69,8 +70,8 @@ private function getNavigationItemForCurrentlyAuthenticatedUser(array $navigatio
}

[$module, $action] = explode('/', (string) $navigationItem['url']);
$module = \SpoonFilter::toCamelCase($module);
$action = \SpoonFilter::toCamelCase($action);
$module = s($module)->camel()->title()->toString();
$action = s($action)->camel()->title()->toString();

if (Authentication::isAllowedModule($module) && Authentication::isAllowedAction($action, $module)) {
return $navigationItem;
Expand Down
3 changes: 2 additions & 1 deletion src/Backend/Core/Engine/TemplateModifiers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Common\Core\Twig\Extensions\BaseTwigModifiers;
use Backend\Core\Language\Language as BackendLanguage;
use SpoonDate;
use function Symfony\Component\String\s;

/**
* This is our class with custom modifiers.
Expand Down Expand Up @@ -166,7 +167,7 @@ public static function getUrl(
*/
public static function toLabel($value): string
{
return \SpoonFilter::ucfirst(BackendLanguage::lbl(\SpoonFilter::toCamelCase($value, '_', false)));
return s(BackendLanguage::lbl(s($value)->replace('_', ' ')->camel()->title()))->title()->toString();
}

/**
Expand Down
Loading
Loading