Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
fix: Fix signatures and types in template related classes
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Mar 6, 2025
commit 1725d6382069daf5f9e66848f3fe3d2f6a5e7dee
6 changes: 2 additions & 4 deletions lib/private/Template/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,18 @@ protected function getCoreTemplateDirs(string $theme, string $serverRoot): array
*
* If the key existed before, it will be overwritten
*/
public function assign(string $key, float|array|bool|int|string|\Throwable|null $value): void {
public function assign(string $key, mixed $value): void {
$this->vars[$key] = $value;
}

/**
* Appends a variable
* @param string $key key
* @param mixed $value value
*
* This function assigns a variable in an array context. If the key already
* exists, the value will be appended. It can be accessed via
* $_[$key][$position] in the template.
*/
public function append($key, $value) {
public function append(string $key, mixed $value): void {
if (array_key_exists($key, $this->vars)) {
$this->vars[$key][] = $value;
} else {
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Template/TemplateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
use OCP\IRequest;
use OCP\Server;
use OCP\Template\ITemplate;
use OCP\Template\ITemplateManager;
use Psr\Log\LoggerInterface;

class TemplateManager {
class TemplateManager implements ITemplateManager {
public function __construct(
private IAppManager $appManager,
private IEventDispatcher $eventDispatcher,
Expand Down
11 changes: 10 additions & 1 deletion lib/public/Template/ITemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,14 @@ public function printPage(): void;
* If the key existed before, it will be overwritten
* @since 32.0.0
*/
public function assign(string $key, float|array|bool|int|string|\Throwable|null $value): void;
public function assign(string $key, mixed $value): void;

/**
* Appends a variable
*
* This function assigns a variable in an array context. If the key already
* exists, the value will be appended. It can be accessed via
* $_[$key][$position] in the template.
*/
public function append(string $key, mixed $value): void;
}
2 changes: 1 addition & 1 deletion lib/public/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static function getL10N(string $application, ?string $language = null): I
* @param string $file
* @since 4.0.0
*/
public static function addStyle($application, $file = null) {
public static function addStyle($application, $file = null): void {
\OC_Util::addStyle($application, $file);
}

Expand Down