Skip to content

Commit

Permalink
Adding const and default variables capabilities.
Browse files Browse the repository at this point in the history
  • Loading branch information
nahakiole committed Mar 29, 2019
1 parent c4567f0 commit 80ff72c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions code-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,16 @@ class PHPCodeGenerator {
this.writeDoc(codeWriter, elem.documentation, options);
// modifiers
var _modifiers = this.getModifiers(elem);
if (_modifiers.length > 0) {
if (_modifiers.length > 0 && !elem.isReadOnly) {
terms.push(_modifiers.join(' '))
}
// name
terms.push('$' + elem.name);

if (elem.isReadOnly) {
terms.push("const");
terms.push(elem.name);
} else {
terms.push('$' + elem.name);
}
// initial value
if (elem.defaultValue && elem.defaultValue.length > 0) {
terms.push('= ' + elem.defaultValue)
Expand Down Expand Up @@ -367,8 +372,9 @@ class PHPCodeGenerator {
for (i = 0, len = params.length; i < len; i++) {
var p = params[i];
var s = '$' + p.name;
if (p.isReadOnly === true) {
s = 'final ' + s

if (p.defaultValue && p.defaultValue.length > 0) {
s = s + (' = ' + p.defaultValue)
}
paramTerms.push(s)
}
Expand Down

0 comments on commit 80ff72c

Please sign in to comment.