mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Transformations must return transformable renderables
This commit is contained in:
parent
05a47e7083
commit
7b0a9cda04
@ -51,10 +51,10 @@ final class Container implements TransformableRenderable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Closure(string):Renderable $Transform
|
||||
* @return Renderable
|
||||
* @param \Closure(string):TransformableRenderable $Transform
|
||||
* @return TransformableRenderable
|
||||
*/
|
||||
public function transformingContent(\Closure $Transform): Renderable
|
||||
public function transformingContent(\Closure $Transform): TransformableRenderable
|
||||
{
|
||||
return new Container(\array_map(
|
||||
function (Renderable $R) use ($Transform): Renderable {
|
||||
@ -68,7 +68,7 @@ final class Container implements TransformableRenderable
|
||||
));
|
||||
}
|
||||
|
||||
public function replacingAll(string $search, Renderable $Replacement): Renderable
|
||||
public function replacingAll(string $search, TransformableRenderable $Replacement): TransformableRenderable
|
||||
{
|
||||
return new Container(\array_map(
|
||||
function (Renderable $R) use ($search, $Replacement): Renderable {
|
||||
|
@ -194,10 +194,10 @@ final class Element implements TransformableRenderable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Closure(string):Renderable $Transform
|
||||
* @return Renderable
|
||||
* @param \Closure(string):TransformableRenderable $Transform
|
||||
* @return TransformableRenderable
|
||||
*/
|
||||
public function transformingContent(\Closure $Transform): Renderable
|
||||
public function transformingContent(\Closure $Transform): TransformableRenderable
|
||||
{
|
||||
if (! isset($this->Contents)) {
|
||||
return $this;
|
||||
@ -215,7 +215,7 @@ final class Element implements TransformableRenderable
|
||||
));
|
||||
}
|
||||
|
||||
public function replacingAll(string $search, Renderable $Replacement): Renderable
|
||||
public function replacingAll(string $search, TransformableRenderable $Replacement): TransformableRenderable
|
||||
{
|
||||
if (! isset($this->Contents)) {
|
||||
return $this;
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Erusev\Parsedown\Html\Renderables;
|
||||
|
||||
use Erusev\Parsedown\Html\Renderable;
|
||||
use Erusev\Parsedown\Html\Sanitisation\Escaper;
|
||||
use Erusev\Parsedown\Html\TransformableRenderable;
|
||||
|
||||
@ -34,15 +33,15 @@ final class Text implements TransformableRenderable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Closure(string):Renderable $Transform
|
||||
* @return Renderable
|
||||
* @param \Closure(string):TransformableRenderable $Transform
|
||||
* @return TransformableRenderable
|
||||
*/
|
||||
public function transformingContent(\Closure $Transform): Renderable
|
||||
public function transformingContent(\Closure $Transform): TransformableRenderable
|
||||
{
|
||||
return $Transform($this->text);
|
||||
}
|
||||
|
||||
public function replacingAll(string $search, Renderable $Replacement): Renderable
|
||||
public function replacingAll(string $search, TransformableRenderable $Replacement): TransformableRenderable
|
||||
{
|
||||
$searchLen = \strlen($search);
|
||||
|
||||
|
@ -18,17 +18,17 @@ interface TransformableRenderable extends Renderable
|
||||
*
|
||||
* It is acceptable to only partially transform "contained text".
|
||||
*
|
||||
* @param \Closure(string):Renderable $Transform
|
||||
* @return Renderable
|
||||
* @param \Closure(string):TransformableRenderable $Transform
|
||||
* @return TransformableRenderable
|
||||
*/
|
||||
public function transformingContent(\Closure $Transform): Renderable;
|
||||
public function transformingContent(\Closure $Transform): TransformableRenderable;
|
||||
|
||||
/**
|
||||
* Similar to transformingContent, but replace the string $search in text content
|
||||
* with the renderable $Replacement and return the result.
|
||||
*
|
||||
* @param string $search
|
||||
* @return Renderable
|
||||
* @return TransformableRenderable
|
||||
*/
|
||||
public function replacingAll(string $search, Renderable $Replacement): Renderable;
|
||||
public function replacingAll(string $search, TransformableRenderable $Replacement): TransformableRenderable;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user