forked from glayzzle/php-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassconstant.js
More file actions
52 lines (47 loc) · 1.22 KB
/
classconstant.js
File metadata and controls
52 lines (47 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Copyright (C) 2018 Glayzzle (BSD3 License)
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
* @url http://glayzzle.com
*/
"use strict";
const ConstantStatement = require("./constantstatement");
const KIND = "classconstant";
const IS_UNDEFINED = "";
const IS_PUBLIC = "public";
const IS_PROTECTED = "protected";
const IS_PRIVATE = "private";
/**
* Defines a class/interface/trait constant
* @constructor ClassConstant
* @extends {ConstantStatement}
* @property {string} visibility
*/
const ClassConstant = ConstantStatement.extends(KIND, function ClassConstant(
kind,
constants,
flags,
docs,
location
) {
ConstantStatement.apply(this, [kind || KIND, constants, docs, location]);
this.parseFlags(flags);
});
/**
* Generic flags parser
* @param {Integer[]} flags
* @return {void}
*/
ClassConstant.prototype.parseFlags = function(flags) {
if (flags[0] === -1) {
this.visibility = IS_UNDEFINED;
} else if (flags[0] === null) {
this.visibility = null;
} else if (flags[0] === 0) {
this.visibility = IS_PUBLIC;
} else if (flags[0] === 1) {
this.visibility = IS_PROTECTED;
} else if (flags[0] === 2) {
this.visibility = IS_PRIVATE;
}
};
module.exports = ClassConstant;