Skip to content

Commit

Permalink
!!! TASK: Document and add types to dls interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Mar 11, 2024
1 parent fe98c8c commit 50bda4e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Neos.Fusion.Afx/Classes/Dsl/AfxDslImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AfxDslImplementation implements DslInterface
* @return string
* @throws Fusion\Exception
*/
public function transpile($code)
public function transpile(string $code): string
{
try {
return AfxService::convertAfxToFusion($code);
Expand Down
22 changes: 21 additions & 1 deletion Neos.Fusion/Classes/Core/DslInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@
/**
* Contract for a Fusion DSL parser
*
* A dsl can be registered like:
*
* Neos:
* Fusion:
* dsl:
* afx: Neos\Fusion\Afx\Dsl\AfxDslImplementation
*
* And will be available via its identifier in Fusion:
*
* root = afx`
* <div>Hello World</div>
* `
* The returned string must be a valid fusion string,
* which is parsed again:
*
* Neos.Fusion:Tag {
* tagName = 'div'
* content = 'Hello World'
* }
*
* @api
*/
interface DslInterface
Expand All @@ -27,5 +47,5 @@ interface DslInterface
* @return string
* @throws Fusion\Exception
*/
public function transpile($code);
public function transpile(string $code): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class FusionObjectExpressionTestDslImplementation implements DslInterface
{
public function transpile($code)
public function transpile(string $code): string
{
$config = json_decode($code, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class PassthroughTestDslImplementation implements DslInterface
{
public function transpile($code)
public function transpile(string $code): string
{
return $code;
}
Expand Down

0 comments on commit 50bda4e

Please sign in to comment.