-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #152 handle readable enums that contain values which need escapin…
…g in javascript (bendavies) This PR was merged into the 1.x-dev branch. Discussion ---------- handle readable enums that contain values which need escaping in javascript Fixes #151, and see discussion there. Commits ------- fea6c0d handle readable enums that contain values which need escaping in javascript
- Loading branch information
Showing
7 changed files
with
80 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the "elao/enum" package. | ||
* | ||
* Copyright (C) Elao | ||
* | ||
* @author Elao <contact@elao.com> | ||
*/ | ||
|
||
namespace Elao\Enum\Tests\Fixtures\Enum; | ||
|
||
use Elao\Enum\ReadableEnum; | ||
|
||
/** | ||
* @method static NeedsEscapingEnum APOSTROPHE() | ||
* @method static NeedsEscapingEnum FORWARD_SLASH() | ||
*/ | ||
class NeedsEscapingEnum extends ReadableEnum | ||
{ | ||
public const APOSTROPHE = 'apostrophe'; | ||
public const FORWARD_SLASH = 'forward_slash'; | ||
|
||
public static function values(): array | ||
{ | ||
return [ | ||
self::APOSTROPHE, | ||
self::FORWARD_SLASH, | ||
]; | ||
} | ||
|
||
public static function readables(): array | ||
{ | ||
return [ | ||
self::APOSTROPHE => '\'', | ||
self::FORWARD_SLASH => '/', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/Fixtures/JsDumper/expected/needs_escaping_readable_enum.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class NeedsEscapingEnum extends ReadableEnum { | ||
static APOSTROPHE = 'apostrophe' | ||
static FORWARD_SLASH = 'forward_slash' | ||
|
||
static get readables() { | ||
return { | ||
[NeedsEscapingEnum.APOSTROPHE]: "'", | ||
[NeedsEscapingEnum.FORWARD_SLASH]: "/", | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters