all files / src/context/ index.js

84.62% Statements 22/26
0% Branches 0/2
50% Functions 1/2
84.62% Lines 22/26
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              1× 1× 1× 1× 1× 1× 1×             1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1×             1×                 1×  
/*!
 * Copyright (C) 2017 Glayzzle (BSD3 License)
 * @authors https://github.com/glayzzle/php-transpiler/graphs/contributors
 * @url http://glayzzle.com
 */
'use strict';
 
var Variables = require('./variables');
var Namespaces = require('./namespaces');
var Traits = require('./traits');
var Functions = require('./functions');
var Interfaces = require('./interfaces');
var Classes = require('./classes');
var Constants = require('./constants');
 
/**
 * Defines the global PHP context that contains
 * a list of informations
 * @constructor Context
 */
var Context = function(php) {
  this.php        = php;
  this.loaders    = [];
  this.includes   = [];
  this.class      = new Classes(this);
  this.interface  = new Interfaces(this);
  this.trait      = new Traits(this);
  this.function   = new Functions(this);
  this.constant   = new Constants(this);
  this.variable   = new Variables(this);
  this.namespace  = new Namespaces(this);
  this.strictTypes    = false;
  this.isCoreLoading  = true;
};
 
/**
 * Declares an autoload function
 * @return {Boolean}
 */
Context.prototype.autoload = function(fn, prepend) {
  if (prepend) {
    this.loaders.unshift(fn);
  } else {
    this.loaders.push(fn);
  }
  return true;
};
 
module.exports = Context;