@param string $localPatchFile
@param string $baseDirectory
@param string $patchLevel
@param bool $dryRun

@return string
353381
private function buildCommand($localPatchFile, $baseDirectory, $patchLevel, $dryRun)
    {
        $chunks = array(
            $this->command,
            $this->escape($patchLevel),
            // Back up mismatches only if otherwise requested
            '--no-backup-if-mismatch',
            // Ignore patches where the differences have already been applied to the file (aka --forward)
            '-N',
            // Change the working directory (aka --directory)
            '-d', $this->escape(str_replace('/', DIRECTORY_SEPARATOR, $baseDirectory)),
            // Read patch from PATCHFILE instead of stdin (aka --input)
            '-i', $this->escape(str_replace('/', DIRECTORY_SEPARATOR, $localPatchFile)),
            // Output rejects to FILE (aka --reject-file)
            '-r', $this->escape(str_replace('/', DIRECTORY_SEPARATOR, $this->volatileDirectory->getNewPath('.rej'))),
        );
        if ($dryRun) {
            // Do not actually change any files; just print what would happen.
            $chunks[] = '--dry-run';
        }

        return implode(' ', $chunks);
    }
230377
public function buildIndex($basedir, OutputInterface $output, array $options = array())
    {
        $target = $this->ensureBuildDir($basedir, $output);

        $built_iterator = new DirectoryIterator($target);
        $index = $target . DIRECTORY_SEPARATOR . 'index.rst';

        $title = str_replace('\\', '\\\\', $this->reflection->getName());
        if (isset($options['title'])) {
            $title = $options['title'];
        }

        $depth = substr_count($this->reflection->getName(), '\\');

        $template = str_repeat($this->titles[$depth], strlen($title)) . "\n";
        $template .= $title . "\n";
        $template .= str_repeat($this->titles[$depth], strlen($title)) . "\n\n";
        $template .= $this->getNamespaceElement();

        $template .= ".. toctree::\n\n";

        foreach ($built_iterator as $file) {
            if ($file->isDot()) continue;
            if ($file->isFile() && !$file->getExtension() == 'rst') continue;
            if ($file->isFile() && substr($file->getBaseName(), 0, 1) == '.') continue;
            if ($file->getBaseName() == 'index.rst') continue;

            $template .= '   ' . pathinfo($file->getPathName(), PATHINFO_FILENAME);

            if ($file->isDir()) {
                $template .= '/index';
            }

            $template .= "\n";
        }

        file_put_contents($index, $template);
    }
667963
function patchArray(original, newA, basePath) {
  let patches = [];
  const oldA = original.slice();
  let tmpIdx = -1;

  function findIndex(a, id, idx) {
    if (a[idx] && isUndef(a[idx].qInfo)) {
      return null;
    } if (a[idx] && a[idx].qInfo.qId === id) {
      // shortcut if identical
      return idx;
    }
    for (let ii = 0, ll = a.length; ii < ll; ii += 1) {
      if (a[ii] && a[ii].qInfo.qId === id) {
        return ii;
      }
    }
    return -1;
  }

  if (compare(newA, oldA)) {
    // array is unchanged
    return patches;
  }

  if (!isUndef(newA[0]) && isUndef(newA[0].qInfo)) {
    // we cannot create patches without unique identifiers, replace array...
    patches.push({
      op: 'replace',
      path: basePath,
      value: newA,
    });
    return patches;
  }

  for (let i = oldA.length - 1; i >= 0; i -= 1) {
    tmpIdx = findIndex(newA, oldA[i].qInfo && oldA[i].qInfo.qId, i);
    if (tmpIdx === -1) {
      patches.push({
        op: 'remove',
        path: `${basePath}/${i}`,
      });
      oldA.splice(i, 1);
    } else {
      patches = patches.concat(JSONPatch.generate(oldA[i], newA[tmpIdx], `${basePath}/${i}`));
    }
  }

  for (let i = 0, l = newA.length; i < l; i += 1) {
    tmpIdx = findIndex(oldA, newA[i].qInfo && newA[i].qInfo.qId);
    if (tmpIdx === -1) {
      patches.push({
        op: 'add',
        path: `${basePath}/${i}`,
        value: newA[i],
      });
      oldA.splice(i, 0, newA[i]);
    } else if (tmpIdx !== i) {
      patches.push({
        op: 'move',
        path: `${basePath}/${i}`,
        from: `${basePath}/${tmpIdx}`,
      });
      oldA.splice(i, 0, oldA.splice(tmpIdx, 1)[0]);
    }
  }
  return patches;
}
486058
private function saveToCache($basedir)
    {
        if (true === $this->debug) {
            return false;
        }

        if (null !== $this->cache) {
            return $this->cache->save($this->getCacheId($basedir), serialize($this->raw_parameters), null, null, true);
        }

        return false;
    }
307356
public function syncLocalFromStripe(StripeLocalResourceInterface $localResource, ApiResource $stripeResource)
    {
        /** @var StripeLocalCard $localResource */
        if ( ! $localResource instanceof StripeLocalCard) {
            throw new \InvalidArgumentException('CardSyncer::hydrateLocal() accepts only StripeLocalCard objects as first parameter');
        }

        /** @var Card $stripeResource */
        if ( ! $stripeResource instanceof Card) {
            throw new \InvalidArgumentException('CardSyncer::hydrateLocal() accepts only Stripe\Card objects as second parameter.');
        }

        $reflect = new \ReflectionClass($localResource);

        foreach ($reflect->getProperties() as $reflectedProperty) {
            // Set the property as accessible
            $reflectedProperty->setAccessible(true);

            /*
             * Guess the kind and set its value (Customer has to be StripeLocalCustomerObject set before the Card
             * $localResource is passed to this hydration method!)
             */
            switch ($reflectedProperty->getName()) {
                case 'id':
                    $reflectedProperty->setValue($localResource, $stripeResource->id);
                    break;

                case 'addressCity':
                    $reflectedProperty->setValue($localResource, $stripeResource->address_city);
                    break;

                case 'addressCountry':
                    $reflectedProperty->setValue($localResource, $stripeResource->address_country);
                    break;

                case 'addressLine1':
                    $reflectedProperty->setValue($localResource, $stripeResource->address_line1);
                    break;

                case 'addressLine1Check':
                    $reflectedProperty->setValue($localResource, $stripeResource->address_line1_check);
                    break;

                case 'addressLine2':
                    $reflectedProperty->setValue($localResource, $stripeResource->address_line2);
                    break;

                case 'addressState':
                    $reflectedProperty->setValue($localResource, $stripeResource->address_state);
                    break;

                case 'addressZip':
                    $reflectedProperty->setValue($localResource, $stripeResource->address_zip);
                    break;

                case 'addressZipCheck':
                    $reflectedProperty->setValue($localResource, $stripeResource->address_zip_check);
                    break;

                case 'brand':
                    $reflectedProperty->setValue($localResource, $stripeResource->brand);
                    break;

                case 'country':
                    $reflectedProperty->setValue($localResource, $stripeResource->country);
                    break;

                case 'customer':
                    $localCustomer = $this->getLocalCustomer($stripeResource->customer);

                    if (false !== $localCustomer) {
                        $reflectedProperty->setValue($localResource, $localCustomer);
                    }
                    break;

                case 'cvcCheck':
                    $reflectedProperty->setValue($localResource, $stripeResource->cvc_check);
                    break;

                case 'dynamicLast4':
                    $reflectedProperty->setValue($localResource, $stripeResource->dynamic_last4);
                    break;

                case 'expMonth':
                    $reflectedProperty->setValue($localResource, $stripeResource->exp_month);
                    break;

                case 'expYear':
                    $reflectedProperty->setValue($localResource, $stripeResource->exp_year);
                    break;

                case 'fingerprint':
                    $reflectedProperty->setValue($localResource, $stripeResource->fingerprint);
                    break;

                case 'funding':
                    $reflectedProperty->setValue($localResource, $stripeResource->funding);
                    break;

                case 'last4':
                    $reflectedProperty->setValue($localResource, $stripeResource->last4);
                    break;

                case 'metadata':
                    $reflectedProperty->setValue($localResource, $stripeResource->metadata->__toArray());
                    break;

                case 'name':
                    $reflectedProperty->setValue($localResource, $stripeResource->name);
                    break;

                case 'tokenizationMethod':
                    $reflectedProperty->setValue($localResource, $stripeResource->tokenization_method);
                    break;
            }
        }
    }
12958
static function delete_generated_files( $local_file ) {
		if ( URLHelper::is_absolute($local_file) ) {
			$local_file = URLHelper::url_to_file_system($local_file);
		}
		$info = pathinfo($local_file);
		$dir = $info['dirname'];
		$ext = $info['extension'];
		$filename = $info['filename'];
		self::process_delete_generated_files($filename, $ext, $dir, '-[0-9999999]*', '-[0-9]*x[0-9]*-c-[a-z]*.');
		self::process_delete_generated_files($filename, $ext, $dir, '-lbox-[0-9999999]*', '-lbox-[0-9]*x[0-9]*-[a-zA-Z0-9]*.');
		self::process_delete_generated_files($filename, 'jpg', $dir, '-tojpg.*');
		self::process_delete_generated_files($filename, 'jpg', $dir, '-tojpg-[0-9999999]*');
	}
816216
static function base($url = '', $cacheBuster = false) {
        $cacheb = $cacheBuster ? ('?' . (Config::get('app.version', '1.0.0'))) : ''; 
        $servern = $_SERVER['SERVER_NAME']; 
        $serverp = $_SERVER['SERVER_PORT'];
        $server = $serverp == '8080' || $serverp == '80' || $serverp == '443' ? $servern : "$servern:$serverp";

        return (((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ||
                (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on'))
                    ? 'https://' : 'http://') . str_replace('//', '/', ($server . '/' . $url)) . $cacheb;
    }
151472
def match_local(self, prefix, includes, excludes):
        
        includes_pattern = r"|".join([fnmatch.translate(x) for x in includes])
        excludes_pattern = r"|".join([fnmatch.translate(x) for x in excludes]) or r"$."
        matches = []
        for root, dirs, files in os.walk(prefix, topdown=True):
            # exclude dirs
            dirs[:] = [os.path.join(root, d) for d in dirs]
            dirs[:] = [d for d in dirs if not re.match(excludes_pattern,
                                                       d.split(root)[1])]
            # exclude/include files
            files = [os.path.join(root, f) for f in files]
            files = [os.path.join(root, f) for f in files
                     if not re.match(excludes_pattern, f)]
            files = [os.path.join(root, f) for f in files
                     if re.match(includes_pattern, f.split(prefix)[1])]
            for fname in files:
                matches.append(fname)
        return matches
330196
public static void createFileBatchesLocal(File inputDirectory, boolean recursive, File outputDirectory, int batchSize) throws IOException {
        createFileBatchesLocal(inputDirectory, null, recursive, outputDirectory, batchSize);
    }
628111
public function compile($lessFile, $basePath = null)
    {
        try {
            $basePath = $this->_prepareBasepath($basePath, dirname($lessFile));

            $cache = new Cache($this->_options);
            $cache->setFile($lessFile, $basePath);

            $isExpired = $cache->isExpired();
            $isForce   = $this->_options->get('force', false, 'bool');

            if ($isForce || $cache->isExpired()) {
                $result = $this->_driver->compile($lessFile, $basePath);
                $cache->save($result);
            }

            $isExpired = ($isForce) ? true : $isExpired;
            $return = [FS::clean($cache->getFile(), '/'), $isExpired];

        } catch (\Exception $e) {
            $message = 'Less error: ' . $e->getMessage();
            throw new Exception($message);
        }

        return $return;
    }
898552
static void writePatch(final Patch rollbackPatch, final File file) throws IOException {
        final File parent = file.getParentFile();
        if (!parent.isDirectory()) {
            if (!parent.mkdirs() && !parent.exists()) {
                throw PatchLogger.ROOT_LOGGER.cannotCreateDirectory(file.getAbsolutePath());
            }
        }
        try {
            try (final OutputStream os = new FileOutputStream(file)){
                PatchXml.marshal(os, rollbackPatch);
            }
        } catch (XMLStreamException e) {
            throw new IOException(e);
        }
    }
1147142
function(inDir, outDir, relativePath, newCache) {
    var ext = this._matchingFileExtension(relativePath);
    var moduleName = relativePath.slice(0, relativePath.length - (ext.length + 1));
    var fullInputPath = path.join(inDir, relativePath);
    var fullOutputPath = path.join(outDir, moduleName + '.' + this.targetExtension);

    var entry = this._transpileThroughCache(
      moduleName,
      fs.readFileSync(fullInputPath, 'utf-8'),
      newCache
    );

    mkdirp.sync(path.dirname(fullOutputPath));
    fs.writeFileSync(fullOutputPath, entry.output);
  }
542101
public function findPatchesInJson($patches)
    {
        // Given an array of patch data (pulled directly from the root composer.json
        // or a patches file), figure out what patch format each package is using and
        // marshall everything into Patch objects.
        foreach ($patches as $package => $patch_defs) {
            if (isset($patch_defs[0]) && is_array($patch_defs[0])) {
                $this->io->write("<info>Using expanded definition format for package {$package}</info>");

                foreach ($patch_defs as $index => $def) {
                    $patch = new Patch();
                    $patch->package = $package;
                    $patch->url = $def["url"];
                    $patch->description = $def["description"];

                    $patches[$package][$index] = $patch;
                }
            } else {
                $this->io->write("<info>Using compact definition format for package {$package}</info>");

                $temporary_patch_list = [];

                foreach ($patch_defs as $description => $url) {
                    $patch = new Patch();
                    $patch->package = $package;
                    $patch->url = $url;
                    $patch->description = $description;

                    $temporary_patch_list[] = $patch;
                }

                $patches[$package] = $temporary_patch_list;
            }
        }

        return $patches;
    }
1101942
private JsonObject patch(String fileName, String code, JsonObject root) {
    for (Map.Entry<String, JsonObject> entry : patches.entrySet()) {
      JsonObject patch = entry.getValue();
      if (!patch.get("filename").getAsString().equals(fileName)) {
        continue;
      }
      
      // Check if this patch should be applied to the locale we're processing/
      JsonArray locales = patch.getAsJsonArray("locales");
      boolean shouldPatch = false;
      if (code == null) {
        shouldPatch = true;
      } else {
        // Only patch if the locale matches.
        for (JsonElement locale : locales) {
          if (locale.getAsString().equals(code)) {
            shouldPatch = true;
            break;
          }
        }
      }
      
      if (!shouldPatch) {
        return root;
      }
  
      JsonObject src = resolve(patch, "patch");
      JsonObject dst = root;
      if (patch.get("type").getAsString().equals("main")) {
        dst = resolve(root, "main", code);
      }
      
      System.out.printf("Applying patch %s to %s\n", entry.getKey(), code);
      patchObject(src, dst);
    }
    
    return root;
  }
105840
protected function getBaseDir(DOMElement $root, $pathWorkflowFile)
    {
        if (!$root->hasAttribute('basedir')) {
            return null;
        }
        $basedirAtr = XmlUtil::getRequiredAttributeValue($root, 'basedir');


        $basedir = $basedirAtr;
        if (0 === strpos($basedir, '.')) {
            $basedir = dirname($pathWorkflowFile) .  substr($basedir, 1);
        }

        if (file_exists($basedir)) {
            $absolutePath = realpath($basedir);
        } else {
            $errMsg = sprintf('Отсутствует ресурс %s', $basedirAtr);
            throw new RuntimeException($errMsg);
        }

        return $absolutePath;
    }
819210
private function process($srcFiles, $basedir)
    {
        // Log
        $this->log("Processing files with base directory ($basedir) ", $this->loglevel);
        $targets = [];
        if ($this->targetFilePos !== null) {
            $addedFiles = [];
            foreach ($srcFiles as $count => $file) {
                if ($this->mapper !== null) {
                    $subTargets = $this->mapper->main($file);
                    if ($subTargets !== null) {
                        foreach ($subTargets as $subTarget) {
                            if ($this->relative) {
                                $name = $subTarget;
                            } else {
                                $name = (new PhingFile($this->destDir, $subTarget))->getAbsolutePath();
                            }
                            if ($this->forwardslash && PhingFile::$separator !== '/') {
                                $name = str_replace(PhingFile::$separator, '/', $name);
                            }
                            if (!isset($addedFiles[$name])) {
                                $targets[] = $name;
                                $addedFiles[] = $name;
                            }
                        }
                    }
                }
            }
        }
        $targetFiles = $targets;

        if (!$this->addsourcefile) {
            $srcFiles = [];
        }
        $orig = $this->commandline->getCommandline();
        $result = []; // range(0,count($orig) + count($srcFiles) + count($targetFiles));

        $srcIndex = count($orig);
        if ($this->srcFilePos !== null) {
            $srcIndex = $this->srcFilePos->getPosition();
        }
        if ($this->targetFilePos !== null) {
            $targetIndex = $this->targetFilePos->getPosition();

            if ($srcIndex < $targetIndex || ($srcIndex === $targetIndex && $this->srcIsFirst)) {
                // 0 --> srcIndex
                $result[] = $orig;

                // srcIndex --> targetIndex
                $result += array_slice($orig, $srcIndex + count($srcFiles), $targetIndex - $srcIndex, true);

                $result[] = $orig;
                $result[] = $targetFiles;
                $result = array_merge(... $result);

                // targetIndex --> end
                $result = array_merge(
                    array_slice(
                        $orig,
                        $targetIndex + count($srcFiles) + count($targetFiles),
                        count($orig) - $targetIndex,
                        true
                    ),
                    $result
                );
            } else {
                // 0 --> targetIndex
                $result[] = $orig;
                $result[] = $targetFiles;
                $result = array_merge(... $result);

                // targetIndex --> srcIndex
                $result = array_merge(
                    array_slice(
                        $orig,
                        $targetIndex + count($targetFiles),
                        $srcIndex - $targetIndex,
                        true
                    ),
                    $result
                );

                // srcIndex --> end
                $result = array_merge(
                    array_slice(
                        $orig,
                        $srcIndex + count($srcFiles) + count($targetFiles),
                        count($orig) - $srcIndex,
                        true
                    ),
                    $result
                );
                $srcIndex += count($targetFiles);
            }
        } else { // no targetFilePos

            // 0 --> srcIndex
            $result = array_merge(array_slice($orig, 0, $srcIndex, true), $result);
            // srcIndex --> end
            $result = array_merge(
                array_slice($orig, $srcIndex + count($srcFiles), count($orig) - $srcIndex, true),
                $result
            );
        }
        // fill in source file names
        foreach ($srcFiles as $i => $file) {
            if ($this->relative) {
                $src = $file;
            } else {
                $src = (new PhingFile($basedir, $file))->getAbsolutePath();
            }
            if ($this->forwardslash && PhingFile::$separator !== '/') {
                $src = str_replace(PhingFile::$separator, '/', $src);
            }
            if ($this->srcFilePos !== null && ($this->srcFilePos->getPrefix() !== ''
                    || $this->srcFilePos->getSuffix() !== '')
            ) {
                $src = $this->srcFilePos->getPrefix() . $src . $this->srcFilePos->getSuffix();
            }
            $result[$srcIndex + $i] = $src;
        }

        $this->commandline = new Commandline(implode(' ', $result));
        $this->commandline->setEscape($this->escape);
        $this->realCommand = (string) $this->commandline . $this->additionalCmds;

        [$returncode, $output] = $this->executeCommand();

        $this->maybeSetReturnPropertyValue($returncode);

        // Sets the output property
        if ($this->outputProperty) {
            $previousValue = $this->project->getProperty($this->outputProperty);
            if (!empty($previousValue)) {
                $previousValue .= "\n";
            }
            $this->project->setProperty($this->outputProperty, $previousValue . implode("\n", $output));
        }

        // Validating the 'return-code'
        if ($this->checkreturn && ($returncode !== 0)) {
            $this->throwBuildException("Task exited with code ($returncode)");
        }
    }
554709
function(what) {
    var mainData = what;
    var localData = {};
    if (typeof what == 'string') {
      // main
      var mainFile = path.resolve(process.cwd(), what);
      delete require.cache[mainFile];
      mainData = require(mainFile);
      // local
      var localFile = mainFile.substr(0, mainFile.lastIndexOf('.'))+'.local'+path.extname(mainFile);
      if (fs.existsSync(localFile)) {
        delete require.cache[localFile];
        localData = require(localFile);
      }
    }
    // main and local merged
    return _.merge({},
      _.merge({}, mainData.default, mainData[this.env]),
      _.merge({}, localData.default, localData[this.env])
    );
  }