Skip to content
Permalink
Browse files

removed prefix I from ILoader, IHtmlString, ISnipperDriver

  • Loading branch information
dg committed Jan 10, 2020
1 parent a3febe2 commit b3679f8d811e7300b86f7fe6de2956439a0002ca
@@ -39,7 +39,7 @@ class Engine
/** @var Compiler|null */
private $compiler;

/** @var ILoader|null */
/** @var Loader|null */
private $loader;

/** @var Runtime\FilterExecutor */
@@ -364,14 +364,14 @@ public function getCompiler(): Compiler


/** @return static */
public function setLoader(ILoader $loader)
public function setLoader(Loader $loader)
{
$this->loader = $loader;
return $this;
}


public function getLoader(): ILoader
public function getLoader(): Loader
{
if (!$this->loader) {
$this->loader = new Loaders\FileLoader;
@@ -13,7 +13,7 @@
/**
* Template loader.
*/
interface ILoader
interface Loader
{
/**
* Returns template source code.
@@ -35,3 +35,6 @@ function getReferredName($name, $referringName);
*/
function getUniqueId($name);
}


class_exists(ILoader::class);
@@ -15,7 +15,7 @@
/**
* Template loader.
*/
class FileLoader implements Latte\ILoader
class FileLoader implements Latte\Loader
{
use Latte\Strict;

@@ -15,7 +15,7 @@
/**
* Template loader.
*/
class StringLoader implements Latte\ILoader
class StringLoader implements Latte\Loader
{
use Latte\Strict;

@@ -101,7 +101,7 @@ public function __get($name): callable
if ($aware) { // FilterInfo aware filter
return $this->$lname = function (...$args) use ($callback) {
array_unshift($args, $info = new FilterInfo);
if ($args[1] instanceof IHtmlString) {
if ($args[1] instanceof HtmlString) {
$args[1] = $args[1]->__toString();
$info->contentType = Engine::CONTENT_HTML;
}
@@ -155,7 +155,7 @@ public function filterContent(string $name, FilterInfo $info, ...$args)
. ($info->contentType === Engine::CONTENT_HTML ? ', try to prepend |stripHtml.' : '.'), E_USER_WARNING);
}
$res = ($this->$name)(...$args);
if ($res instanceof IHtmlString) {
if ($res instanceof HtmlString) {
trigger_error("Filter |$name should be changed to content-aware filter.");
$info->contentType = Engine::CONTENT_HTML;
$res = $res->__toString();
@@ -39,12 +39,12 @@ public static function escapeHtml($s): string

/**
* Escapes string for use inside HTML.
* @param mixed $s plain text or IHtmlString
* @param mixed $s plain text or HtmlString
* @return string HTML
*/
public static function escapeHtmlText($s): string
{
return $s instanceof IHtmlString || $s instanceof \Nette\Utils\IHtmlString
return $s instanceof HtmlString || $s instanceof \Nette\Utils\HtmlString
? $s->__toString(true)
: htmlspecialchars((string) $s, ENT_NOQUOTES, 'UTF-8');
}
@@ -57,7 +57,7 @@ public static function escapeHtmlText($s): string
*/
public static function escapeHtmlAttr($s, bool $double = true): string
{
$double = $double && $s instanceof IHtmlString ? false : $double;
$double = $double && $s instanceof HtmlString ? false : $double;
$s = (string) $s;
if (strpos($s, '`') !== false && strpbrk($s, ' <>"\'') === false) {
$s .= ' '; // protection against innerHTML mXSS vulnerability nette/nette#1496
@@ -157,7 +157,7 @@ public static function escapeCss($s): string
*/
public static function escapeJs($s): string
{
if ($s instanceof IHtmlString || $s instanceof \Nette\Utils\IHtmlString) {
if ($s instanceof HtmlString || $s instanceof \Nette\Utils\HtmlString) {
$s = $s->__toString(true);
}

@@ -15,7 +15,7 @@
/**
* HTML literal.
*/
class Html implements IHtmlString
class Html implements HtmlString
{
use Latte\Strict;

@@ -10,9 +10,12 @@
namespace Latte\Runtime;


interface IHtmlString
interface HtmlString
{

/** @return string in HTML format */
function __toString(): string;
}


class_exists(IHtmlString::class);
@@ -14,7 +14,7 @@
* Snippet bridge
* @internal
*/
interface ISnippetBridge
interface SnippetBridge
{
function isSnippetMode(): bool;

@@ -30,3 +30,6 @@ function addSnippet(string $name, string $content): void;

function renderChildren(): void;
}


class_exists(ISnippetBridge::class);
@@ -34,11 +34,11 @@ class SnippetDriver
/** @var bool */
private $renderingSnippets = false;

/** @var ISnippetBridge */
/** @var SnippetBridge */
private $bridge;


public function __construct(ISnippetBridge $bridge)
public function __construct(SnippetBridge $bridge)
{
$this->bridge = $bridge;
}
@@ -0,0 +1,39 @@
<?php

/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/

declare(strict_types=1);

namespace Latte {
if (false) {
/** @deprecated use Latte\Loader */
interface ILoader
{
}
} elseif (!interface_exists(ILoader::class)) {
class_alias(Loader::class, ILoader::class);
}
}

namespace Latte\Runtime {
if (false) {
/** @deprecated use Latte\Runtime\HtmlString */
interface IHtmlString
{
}
} elseif (!interface_exists(IHtmlString::class)) {
class_alias(HtmlString::class, IHtmlString::class);
}

if (false) {
/** @deprecated use Latte\Runtime\SnippetBridge */
interface ISnippetBridge
{
}
} elseif (!interface_exists(ISnippetBridge::class)) {
class_alias(SnippetBridge::class, ISnippetBridge::class);
}
}
@@ -13,7 +13,7 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';


class Test implements Latte\Runtime\IHtmlString
class Test implements Latte\Runtime\HtmlString
{
public function __toString(): string
{
@@ -13,7 +13,7 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';


class Test implements Latte\Runtime\IHtmlString
class Test implements Latte\Runtime\HtmlString
{
public function __toString(): string
{
@@ -13,7 +13,7 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';


class Test implements Latte\Runtime\IHtmlString
class Test implements Latte\Runtime\HtmlString
{
public function __toString(): string
{
@@ -3,7 +3,7 @@
declare(strict_types=1);


class SnippetBridgeMock implements Latte\Runtime\ISnippetBridge
class SnippetBridgeMock implements Latte\Runtime\SnippetBridge
{
public $snippetMode = true;

0 comments on commit b3679f8

Please sign in to comment.
You can’t perform that action at this time.