original_string: public function addPlugin($name, $dir)
      {
          Debug::enterScope($name);
          $hasPlugin = $hasZfile = false;
  
          try {
              $this->plugins[$name] = $this->getLocator()->locate($name . '/Plugin.php', $dir, true);
              $this->pluginPaths[$name] = dirname($this->plugins[$name]);
  
              $hasPlugin = true;
              $this->sourceFiles[] = $this->plugins[$name];
          } catch (\InvalidArgumentException $e) {
          }
  
          try {
              $zFileLocation = $this->getLocator()->locate($name . '/z.yml', $dir);
              $this->import($zFileLocation, self::PLUGIN);
              if (!isset($this->pluginPaths[$name])) {
                  $this->pluginPaths[$name] = dirname($zFileLocation);
              } else if ($this->pluginPaths[$name] != dirname($zFileLocation)) {
                  throw new \UnexpectedValueException(
                      "Ambiguous plugin configuration:\n"
                      . "There was a Plugin.php found in {$this->pluginPaths[$name]}, but also a z.yml at $zFileLocation"
                  );
              }
  
              $hasZfile = true;
              $this->sourceFiles[] = $zFileLocation;
          } catch (\InvalidArgumentException $e) {
          }
  
          if (!$hasPlugin && !$hasZfile) {
              throw new \InvalidArgumentException("You need at least either a z.yml or a Plugin.php in the plugin path for '{$name}'");
          }
          Debug::exitScope($name);
      }
code: public function addPlugin($name, $dir)
      {
          Debug::enterScope($name);
          $hasPlugin = $hasZfile = false;
  
          try {
              $this->plugins[$name] = $this->getLocator()->locate($name . '/Plugin.php', $dir, true);
              $this->pluginPaths[$name] = dirname($this->plugins[$name]);
  
              $hasPlugin = true;
              $this->sourceFiles[] = $this->plugins[$name];
          } catch (\InvalidArgumentException $e) {
          }
  
          try {
              $zFileLocation = $this->getLocator()->locate($name . '/z.yml', $dir);
              $this->import($zFileLocation, self::PLUGIN);
              if (!isset($this->pluginPaths[$name])) {
                  $this->pluginPaths[$name] = dirname($zFileLocation);
              } else if ($this->pluginPaths[$name] != dirname($zFileLocation)) {
                  throw new \UnexpectedValueException(
                      "Ambiguous plugin configuration:\n"
                      . "There was a Plugin.php found in {$this->pluginPaths[$name]}, but also a z.yml at $zFileLocation"
                  );
              }
  
              $hasZfile = true;
              $this->sourceFiles[] = $zFileLocation;
          } catch (\InvalidArgumentException $e) {
          }
  
          if (!$hasPlugin && !$hasZfile) {
              throw new \InvalidArgumentException("You need at least either a z.yml or a Plugin.php in the plugin path for '{$name}'");
          }
          Debug::exitScope($name);
      }
code_tokens: public function addPlugin ( $ name , $ dir ) { Debug :: enterScope ( $ name ) ; $ hasPlugin = $ hasZfile = false ; try { $ this -> plugins [ $ name ] = $ this -> getLocator ( ) -> locate ( $ name . '/Plugin.php' , $ dir , true ) ; $ this -> pluginPaths [ $ name ] = dirname ( $ this -> plugins [ $ name ] ) ; $ hasPlugin = true ; $ this -> sourceFiles [ ] = $ this -> plugins [ $ name ] ; } catch ( \ InvalidArgumentException $ e ) { } try { $ zFileLocation = $ this -> getLocator ( ) -> locate ( $ name . '/z.yml' , $ dir ) ; $ this -> import ( $ zFileLocation , self :: PLUGIN ) ; if ( ! isset ( $ this -> pluginPaths [ $ name ] ) ) { $ this -> pluginPaths [ $ name ] = dirname ( $ zFileLocation ) ; } else if ( $ this -> pluginPaths [ $ name ] != dirname ( $ zFileLocation ) ) { throw new \ UnexpectedValueException ( "Ambiguous plugin configuration:\n" . "There was a Plugin.php found in {$this->pluginPaths[$name]}, but also a z.yml at $zFileLocation" ) ; } $ hasZfile = true ; $ this -> sourceFiles [ ] = $ zFileLocation ; } catch ( \ InvalidArgumentException $ e ) { } if ( ! $ hasPlugin && ! $ hasZfile ) { throw new \ InvalidArgumentException ( "You need at least either a z.yml or a Plugin.php in the plugin path for '{$name}'" ) ; } Debug :: exitScope ( $ name ) ; }
docstring: Add a plugin at the passed location
  
  @param string $name
  @param string $dir
  @return void
  
  @throws \InvalidArgumentException
  @throws \UnexpectedValueException
docstring_tokens: Add a plugin at the passed location