ether-code 0.8.6 → 0.8.7

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 CHANGED
@@ -6,7 +6,7 @@ const http = require('http')
6
6
  const { EtherCompiler } = require('./compiler')
7
7
  const { Watcher } = require('./watcher')
8
8
 
9
- const VERSION = '0.8.6'
9
+ const VERSION = '0.8.7'
10
10
 
11
11
  const COLORS = {
12
12
  reset: '\x1b[0m',
@@ -761,9 +761,11 @@ class PHPGenerator {
761
761
  let property
762
762
 
763
763
  if (typeof node.property === 'string') {
764
- property = node.property
764
+ property = this.translateMethodName(node.property)
765
765
  } else if (node.property && node.property.name) {
766
- property = node.property.name
766
+ property = this.translateMethodName(node.property.name)
767
+ } else if (node.property && node.property.type === 'Identifier') {
768
+ property = this.translateMethodName(node.property.name || node.property.value)
767
769
  } else {
768
770
  property = this.generateNode(node.property)
769
771
  }
@@ -780,6 +782,20 @@ class PHPGenerator {
780
782
  return `${object}->${property}`
781
783
  }
782
784
 
785
+ translateMethodName(name) {
786
+ if (!name) return name
787
+ const translated = this.translate(name)
788
+ if (translated.includes('->')) {
789
+ const parts = translated.split('->')
790
+ return parts[parts.length - 1].replace(/\(\)$/, '')
791
+ }
792
+ if (translated.includes('::')) {
793
+ const parts = translated.split('::')
794
+ return parts[parts.length - 1].replace(/\(\)$/, '')
795
+ }
796
+ return translated.replace(/\(\)$/, '')
797
+ }
798
+
783
799
  generateStaticMemberExpression(node) {
784
800
  const cls = this.generateNode(node.class)
785
801
  let member
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ether-code",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
4
4
  "description": "Ether - Le langage intentionnel",
5
5
  "main": "cli/compiler.js",
6
6
  "bin": {