ether-code 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/ether.js +1 -1
- package/generators/php-generator.js +20 -4
- package/package.json +1 -1
- package/parsers/ether-parser-php.js +3 -0
package/cli/ether.js
CHANGED
|
@@ -308,6 +308,11 @@ class PHPGenerator {
|
|
|
308
308
|
extractTypeName(typeNode) {
|
|
309
309
|
if (!typeNode) return ''
|
|
310
310
|
if (typeof typeNode === 'string') return this.translateKeyword(typeNode)
|
|
311
|
+
if (typeNode.type === 'TypeHint') {
|
|
312
|
+
const types = (typeNode.types || []).map(t => this.translateKeyword(t))
|
|
313
|
+
const result = types.join('|')
|
|
314
|
+
return typeNode.nullable ? '?' + result : result
|
|
315
|
+
}
|
|
311
316
|
if (typeNode.name) return this.translateKeyword(typeNode.name)
|
|
312
317
|
if (typeNode.type === 'Identifier') return this.translateKeyword(typeNode.name || typeNode.value || '')
|
|
313
318
|
if (typeNode.value) return this.translateKeyword(typeNode.value)
|
|
@@ -474,9 +479,19 @@ class PHPGenerator {
|
|
|
474
479
|
}
|
|
475
480
|
|
|
476
481
|
generateUseStatement(node) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
482
|
+
if (node.imports && node.imports.length > 0) {
|
|
483
|
+
for (const imp of node.imports) {
|
|
484
|
+
const name = imp.path || imp.name
|
|
485
|
+
const alias = imp.alias ? ` as ${imp.alias}` : ''
|
|
486
|
+
const useType = node.useType ? `${node.useType} ` : ''
|
|
487
|
+
this.writeLine(`use ${useType}${name}${alias};`)
|
|
488
|
+
}
|
|
489
|
+
} else {
|
|
490
|
+
const name = node.name || node.source
|
|
491
|
+
const alias = node.alias ? ` as ${node.alias}` : ''
|
|
492
|
+
const useType = node.useType ? `${node.useType} ` : ''
|
|
493
|
+
this.writeLine(`use ${useType}${name}${alias};`)
|
|
494
|
+
}
|
|
480
495
|
return ''
|
|
481
496
|
}
|
|
482
497
|
|
|
@@ -705,7 +720,8 @@ class PHPGenerator {
|
|
|
705
720
|
let declaration = 'enum ' + (node.name || '')
|
|
706
721
|
|
|
707
722
|
if (node.backingType) {
|
|
708
|
-
|
|
723
|
+
const type = this.extractTypeName(node.backingType)
|
|
724
|
+
if (type) declaration += ': ' + type
|
|
709
725
|
}
|
|
710
726
|
|
|
711
727
|
this.writeLine(declaration + ' {')
|
package/package.json
CHANGED
|
@@ -635,6 +635,9 @@ class EtherParserPHP extends EtherParserBase {
|
|
|
635
635
|
type: 'ClassDeclaration',
|
|
636
636
|
name: name,
|
|
637
637
|
modifiers: modifiers,
|
|
638
|
+
abstract: modifiers.includes('abstract'),
|
|
639
|
+
final: modifiers.includes('final'),
|
|
640
|
+
readonly: modifiers.includes('readonly'),
|
|
638
641
|
superClass: superClass,
|
|
639
642
|
interfaces: interfaces,
|
|
640
643
|
body: body
|