{@inheritdoc}

@throws \InvalidArgumentException If source file does not exist
4328
public function provideName(FileInfo $srcFileInfo)
    {
        if (!$srcFileInfo->isFile()) {
            throw new \InvalidArgumentException(sprintf(
                'The source file does not exist on "%s" specified path.',
                $srcFileInfo->toString()
            ));
        }
        $hash = hash_file($this->algorithm, $srcFileInfo->toString());

        $dstFileInfo = $this->provideNameByHash($srcFileInfo, $hash);

        return $dstFileInfo;
    }
348381
public function loadFile($url)
    {
        //Locate the template
        $locator = $this->getObject('template.locator.factory')->createLocator($url);

        if (!$file = $locator->locate($url)) {
            throw new InvalidArgumentException(sprintf('The template "%s" cannot be located.', $url));
        }

        //Load the template
        if(!$source = file_get_contents($file)) {
            throw new RuntimeException(sprintf('The template "%s" cannot be loaded.', $file));
        }

        $this->_source = $source;

        return $this;
    }
309154
public function load($configurationFile = null)
    {
        $this->hosts = array();
        $this->configuration = array();

        if (isset($configurationFile)) {
            $this->configurationFile = $configurationFile;
        }

        if (file_exists($this->configurationFile) === false) {
            throw new InvalidArgumentException(sprintf('The configuration file "%s" is not valid.', $this->configurationFile));
        }

        $json = file_get_contents($this->configurationFile);

        $this->validateSyntax($json);

        $json = $this->importExtendedConfiguration($json);
        if ($this->validateSchema($json)) {
            $this->configuration = json_decode($json, true);
        }

        $this->processEventSubscribers();
    }
651129
public function load($file, $type = null)
    {
        $path   = $this->locator->locate($file);
        $config = array();

        $result = parse_ini_file($path, true);
        if (false === $result || array() === $result) {
            throw new InvalidArgumentException(sprintf('The "%s" file is not valid.', $file));
        }

        if (isset($result['parameters']) && is_array($result['parameters'])) {
            $config['parameters'] = array();
            foreach ($result['parameters'] as $key => $value) {
                $config['parameters'][$key] = $value;
            }
        }
    }
1352217
public static function load(string $path = null, array $paths = []): self
    {
        if (null === $path) {
            $config = [];
        } else {
            if (false === (new Filesystem())->isAbsolutePath($path)) {
                throw new InvalidArgumentException(
                    sprintf(
                        'Expected the path of the configuration file to load to be an absolute path, got "%s" '
                        .'instead',
                        $path
                    )
                );
            }

            if (false === file_exists($path)) {
                throw new InvalidArgumentException(
                    sprintf(
                        'Expected the path of the configuration file to exists but the file "%s" could not be '
                        .'found',
                        $path
                    )
                );
            }

            if (false === is_file($path) && false === (is_link($path) && is_file(readlink($path)))) {
                throw new InvalidArgumentException(
                    sprintf(
                        'Expected the path of the configuration file to be a file but "%s" appears to be a '
                        .'directory.',
                        $path
                    )
                );
            }

            $config = include $path;

            if (false === is_array($config)) {
                throw new InvalidArgumentException(
                    sprintf(
                        'Expected configuration to be an array, found "%s" instead.',
                        gettype($config)
                    )
                );
            }
        }

        self::validateConfigKeys($config);

        $prefix = self::retrievePrefix($config);

        $whitelistedFiles = null === $path ? [] : self::retrieveWhitelistedFiles(dirname($path), $config);

        $patchers = self::retrievePatchers($config);

        array_unshift($patchers, new SymfonyPatcher());

        $whitelist = self::retrieveWhitelist($config);

        $finders = self::retrieveFinders($config);
        $filesFromPaths = self::retrieveFilesFromPaths($paths);
        $filesWithContents = self::retrieveFilesWithContents(chain($filesFromPaths, ...$finders));

        return new self($path, $prefix, $filesWithContents, $patchers, $whitelist, $whitelistedFiles);
    }
573207
public function setSourceUri( $sourceUri )
	{
		if( !file_exists( $sourceUri ) )
			throw new InvalidArgumentException( 'Image source "'.$sourceUri.'" is not existing' );
		$info = @getimagesize( $sourceUri );
		if( !$info )
			throw new Exception( 'Image source "'.$sourceUri.'" is not of a supported type' );
		$this->sourceUri	= $sourceUri;
		$this->sourceInfo	= $info;
		$this->loadImage();
	}
498274
protected function ensureFileIsReadable()
    {
        $filePath = $this->filePath;
        if (!is_readable($filePath) || !is_file($filePath)) {
            throw new InvalidArgumentException(sprintf(
                'Dotenv: Environment file .env not found or not readable. '.
                'Create file with your environment settings at %s',
                $filePath
            ));
        }
    }
1230607
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $sourceArg = realpath($input->getArgument('source'));
        $ruleSetArg = realpath($input->getArgument('ruleset'));

        if (false === $sourceArg || false === $ruleSetArg) {
            throw new \InvalidArgumentException(
                sprintf(
                    '%s argument is invalid: "%s" is not a path.',
                    $sourceArg ? 'Rule set' : 'Source directory',
                    $sourceArg ? $input->getArgument('ruleset') : $input->getArgument('source')
                )
            );
        }

        $config = new Configuration(
            $input->getArgument('ruleset'),
            $input->getOption('container-cache'),
            $input->getOption('no-cache'),
            $input->getOption('cache-dir'),
            $input->getOption('filter-methods'),
            $input->getOption('fail'),
            $input->getOption('verbose'),
            $input->getOption('log-html'),
            $input->getOption('output')
        );

        $factory = new DetectorFactory();
        $detector = $factory->create($config, $output);
        $violations = $detector->checkForDeprecations($sourceArg, $ruleSetArg);

        if ($config->failOnDeprecation() && !empty($violations)) {
            return 1;
        }

        return 0;
    }
1359586
public function loadFromDirectory($dir)
    {
        if (!is_dir($dir)) {
            throw new \InvalidArgumentException(sprintf('"%s" does not exist', $dir));
        }

        $installers = [];
        $includedFiles = [];

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($dir),
            \RecursiveIteratorIterator::LEAVES_ONLY
        );

        foreach ($iterator as $file) {
            if (($fileName = $file->getBasename($this->fileExtension)) == $file->getBasename()) {
                continue;
            }
            $sourceFile = realpath($file->getPathName());
            require_once $sourceFile;
            $includedFiles[] = $sourceFile;
        }
        $declared = get_declared_classes();

        foreach ($declared as $className) {
            $refClass = new \ReflectionClass($className);
            $sourceFile = $refClass->getFileName();

            if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) {
                $installer = new $className;
                $installers[] = $installer;
                $this->addInstaller($installer);
            }
        }

        return $installers;
    }
143311
public function lint($file)
    {
        $template = $this->app['twig.loader.viewfinder']->getSourceContext($file);

        if (!$template) {
            throw new InvalidArgumentException('Unable to find file: '.$file);
        }

        try {
            $this->parse($this->tokenize($template, $file));
        } catch (Error $e) {
            return false;
        }

        return true;
    }
850333
protected function loadFile($file)
    {
        if (!stream_is_local($file)) {
            throw new InvalidArgumentException(sprintf('This is not a local file "%s".', $file));
        }

        if (!file_exists($file)) {
            throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file));
        }

        return Toml::Parse($file);
    }
625412
public function loadFromFile($fileName)
    {
        if (!is_readable($fileName)) {
            throw new \InvalidArgumentException(sprintf('"%s" does not exist or is not readable', $fileName));
        }

        $iterator = new \ArrayIterator([new \SplFileInfo($fileName)]);
        return $this->loadFromIterator($iterator);
    }
700997
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $path = $input->getOption('path') ?: $this->paths[$input->getOption('type')];

        $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);

        if (file_exists($path) === true) {
            $source = $this->package($input->getArgument('name'));

            $this->migrate($output, $source, $path, $input->getOption('type'));

            $message = ucfirst($this->type) . ' created successfully!';

            return $output->writeln('<info>' . $message . '</info>');
        }

        $message = 'Folder "' . $path . '" does not exists!';

        throw new \InvalidArgumentException((string) $message);
    }
290418
protected function assertFile($name)
    {
        if (strpos($name, '..') !== false) {
            throw new \InvalidArgumentException("File name '$name' isn't valid");
        }
        
        $file = $this->getFilePath($name);
        
        if (!file_exists($file)) {
            throw new \RuntimeException("View file '$file' doesn't exist");
        }
    }
1088964
public function copy($destination) {
    
    if (!$this->exists()) {
      throw new Exception('Source from copy does not exist: '.$this);
    }
    
    if ($destination instanceof Dir) {
      $destination = $destination->getFile($this->getName());
    } elseif (!($destination instanceof File)) {
      throw new InvalidArgumentException('Invalid Argument. $destination must be file or dir');
    }

    if (!$destination->getDirectory()->exists()) {
      throw new Exception('The directory from the destination file does not exist: '.$destination);
    }

    $ret = @copy((string) $this, (string) $destination);

    if (!$ret) {
      throw new Exception('PHP Error while copying '.$this.' onto '.$destination);
    }
    
    return $this;
  }
1194352
public function process()
    {
        // Find files
        $files = $this->finder->find();
        if (0 === count($files)) {
            throw new \InvalidArgumentException('No files found for format: *.' . $this->getFormat());
        }

        foreach ($files as $file) {
            $valuesSet = 0;
            $configurations = $this->getConfigurationsFromFile($file);
            foreach ($configurations as $configPath => $configValues) {
                $scopeConfigValues = $this->transformConfigToScopeConfig($configPath, $configValues);
                foreach ($scopeConfigValues as $scopeConfigValue) {
                    $this->configWriter->save(
                        $configPath,
                        $scopeConfigValue['value'],
                        $scopeConfigValue['scope'],
                        $this->scopeConverter->convert($scopeConfigValue['scope_id'], $scopeConfigValue['scope'])
                    );

                    $this->getOutput()->writeln(sprintf('<comment>%s => %s</comment>', $configPath, $scopeConfigValue['value']));
                    $valuesSet++;
                }
            }

            $this->getOutput()->writeln(sprintf('<info>Processed: %s with %s value(s).</info>', $file, $valuesSet));
        }
    }
1312188
public function setSource( $source )
	{
		if( !file_exists( $source ) )
			throw new InvalidArgumentException( 'Image File "'.$source.'" is not existing.' );
		$size = @getimagesize( $source );
		if( !$size )
			throw new Exception( 'Source File "'.$source.'" is not a supported Image.' );
		$this->size		= $size;
		$this->source	= $source;
	}