예제 #1
0
  /**
   * Initializes autoloader (currently PSR-4 and PSR-0 are supported)
   *
   * @param composerSchemaJson configuration from composer.json
   */
  private void initAutoLoader(ComposerSchemaJson composerSchemaJson) {
    Autoload autoload = composerSchemaJson.getAutoload();
    if (autoload == null) {
      return;
    }

    Map<String, List<String>> psr4 = autoload.getPsr4();
    if (psr4 != null) {
      PSR4ClassFileResolver psr4ClassFileResolver = new PSR4ClassFileResolver();
      for (Map.Entry<String, List<String>> entry : psr4.entrySet()) {
        for (String directory : entry.getValue()) {
          psr4ClassFileResolver.addNamespace(entry.getKey(), directory);
        }
      }
      classFileResolver.addResolver(psr4ClassFileResolver);
    }

    Map<String, List<String>> psr0 = autoload.getPsr0();
    if (psr0 != null) {
      PSR0ClassFileResolver psr0ClassFileResolver = new PSR0ClassFileResolver();
      for (Map.Entry<String, List<String>> entry : psr0.entrySet()) {
        for (String directory : entry.getValue()) {
          psr0ClassFileResolver.addNamespace(entry.getKey(), directory);
        }
      }
      classFileResolver.addResolver(psr0ClassFileResolver);
    }
    // TODO: classmap?

  }
예제 #2
0
 /**
  * Invoked by PHP parse tree listener to "touch" class. PHP language support tries to resolve
  * class file using registered class resolver(s) and if file is found, we are trying to parse it
  * before processing current class
  *
  * @param fullyQualifiedClassName FQCN
  */
 protected void resolveClass(String fullyQualifiedClassName) {
   if (!seenClasses.add(fullyQualifiedClassName)) {
     return;
   }
   File file = classFileResolver.resolve(fullyQualifiedClassName);
   if (file != null) {
     process(file);
   }
 }