Beispiel #1
0
 /**
  * See if paths match satisfactorily
  * @param string $expectedPath an absolute path to target file
  * @param string $actualPath the absolute or relative path that was found
  * @param string $currDir the current directory to calculate relative paths
  * from. If $actualPath is an explicitly relative path (i.e. "../foo"), you
  * <b>must</b> provide this!
  * @return string|bool false if the paths do not match. If they do match,
  * returns the base, if any, that is not explicitly defined by $actualPath.
  * Since this method may return the empty string on success, strict type
  * comparison must be used.
  */
 public static function matchPaths($expectedPath, $actualPath, $currDir = false)
 {
     if (Scisr_File::isExplicitlyRelative($actualPath)) {
         if ($currDir === false) {
             throw new LogicException('You provided a relative path without a current dir!');
         }
         $actualPath = Scisr_File::getAbsolutePath($actualPath, $currDir);
         // Add a trailing slash if it's not there
         if (substr($currDir, -1) != '/') {
             $currDir .= '/';
         }
         return $expectedPath == $actualPath ? $currDir : false;
     }
     // If it's an absolute path, it must match exactly
     if ($actualPath[0] == '/') {
         return $expectedPath == $actualPath ? '' : false;
     }
     // A simple test: see if the actual matches the end of the expected path
     if (strstr($expectedPath, $actualPath) == $actualPath) {
         $base = substr($expectedPath, 0, strpos($expectedPath, $actualPath));
         return $base;
     }
     return false;
 }
Beispiel #2
0
 public static function exposeMergeChanges($c1, $c2)
 {
     return parent::mergeChanges($c1, $c2);
 }
 public function processInclude($phpcsFile, $includedFile, $line, $column, $length, $quote, $tentative)
 {
     $includedFile = Scisr_File::getAbsolutePath($includedFile, dirname($phpcsFile->getFileName()));
     $this->_dbFileIncludes->registerFileInclude($phpcsFile->getFileName(), $includedFile);
 }
Beispiel #4
0
 /**
  * @dataProvider isRelativeProvider
  */
 public function testIsRelative($path, $isRelative)
 {
     $this->assertSame($isRelative, Scisr_File::isExplicitlyRelative($path));
 }
Beispiel #5
0
 /**
  * Add a file or directory to be parsed
  * @param string $filename the path to the file or directory
  */
 public function addFile($filename)
 {
     $filename = Scisr_File::getAbsolutePath($filename);
     $this->files[] = $filename;
 }