Skip to content

Commit 8334fea

Browse files
authored
A few unimportant code-style consistency changes (glayzzle#1137)
* Use consistent declaration format for function exports. Change "read_types() {" to "read_types: function () {" Change "read_promoted() {" to "read_promoted: function () {" * parser/class.js -- tiny simplification Set nullable directly and use result for comparison. * Use strict equality tests for consistency
1 parent 7a82704 commit 8334fea

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/parser/class.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,11 @@ module.exports = {
312312
break;
313313
}
314314
if (asInterface) {
315-
if (idx == 0 && val == 2) {
315+
if (idx === 0 && val === 2) {
316316
// an interface can't be private
317317
this.expect([this.tok.T_PUBLIC, this.tok.T_PROTECTED]);
318318
val = -1;
319-
} else if (idx == 2 && val == 1) {
319+
} else if (idx === 2 && val === 1) {
320320
// an interface cant be abstract
321321
this.error();
322322
val = -1;
@@ -331,8 +331,8 @@ module.exports = {
331331
} while (this.next().is("T_MEMBER_FLAGS"));
332332
}
333333

334-
if (result[1] == -1) result[1] = 0;
335-
if (result[2] == -1) result[2] = 0;
334+
if (result[1] === -1) result[1] = 0;
335+
if (result[2] === -1) result[2] = 0;
336336
return result;
337337
},
338338

@@ -360,9 +360,8 @@ module.exports = {
360360
* ;
361361
*/
362362
read_optional_type: function () {
363-
let nullable = false;
364-
if (this.token === "?") {
365-
nullable = true;
363+
const nullable = this.token === "?";
364+
if (nullable) {
366365
this.next();
367366
}
368367
let type = this.read_types();
@@ -440,7 +439,7 @@ module.exports = {
440439
const flags = this.read_member_flags(true);
441440

442441
// check constant
443-
if (this.token == this.tok.T_CONST) {
442+
if (this.token === this.tok.T_CONST) {
444443
const constants = this.read_constant_list(flags, attrs);
445444
if (this.expect(";")) {
446445
this.next();

src/parser/function.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ module.exports = {
320320
if (attrs) result.attrGroups = attrs;
321321
return result;
322322
},
323-
read_types() {
323+
read_types: function () {
324324
const MODE_UNSET = "unset";
325325
const MODE_UNION = "union";
326326
const MODE_INTERSECTION = "intersection";
@@ -374,7 +374,7 @@ module.exports = {
374374
: this.node("uniontype")(types);
375375
}
376376
},
377-
read_promoted() {
377+
read_promoted: function () {
378378
const MODIFIER_PUBLIC = 1;
379379
const MODIFIER_PROTECTED = 2;
380380
const MODIFIER_PRIVATE = 4;

0 commit comments

Comments
 (0)