src/Files/FileLoader.php
private function tryLoadFile($fileName, $extension)
	{
		$this->output->writelnIfDebug("<info>Attempting to load $fileName with extension $extension</info>");
		$this->loadError = false;

		switch (strtolower($extension))
		{
			case 'php':
				// First, check if this file is a lang file.
				$file = basename($fileName);
				$dir  = str_replace($file, '', $fileName);
				$dir  = str_replace($this->basedir, '', $dir);
				$dir  = explode('/', trim($dir, '/'));
				$dir  = array_map('strtolower', $dir);

				if (in_array('language', $dir))
				{
					return new LangFile($this->debug, $fileName, $this->rundir);
				}

				if (in_array('migrations', $dir))
				{
					return new MigrationFile($this->debug, $fileName, $this->rundir);
				}

				return new PHPFile($this->debug, $fileName, $this->rundir);

			case 'html':
			case 'htm':
				return new HTMLFile($this->debug, $fileName, $this->rundir);

			case 'json':
				if (strtolower(basename($fileName)) == 'composer.json')
				{
					return new ComposerFile($this->debug, $fileName, $this->rundir);
				}
				else
				{
					return new JsonFile($this->debug, $fileName, $this->rundir);
				}

			case 'yml':
				if (strtolower(basename($fileName)) == 'services.yml')
				{
					return new ServiceFile($this->debug, $fileName, $this->rundir);
				}
				if (strtolower(basename($fileName)) == 'routing.yml')
				{
					return new RoutingFile($this->debug, $fileName, $this->rundir);
				}

				return new YmlFile($this->debug, $fileName, $this->rundir);

			case 'txt':
			case 'md':
			case 'htaccess':
			case 'gitattributes':
			case 'gitignore':
			case 'map':
			case 'sh': // Decide if we want a special file type for shell files!
				return new PlainFile($this->debug, $fileName, $this->rundir);

			case 'xml':
				return new XmlFile($this->debug, $fileName, $this->rundir);

			case 'js':
				return new JavascriptFile($this->debug, $fileName, $this->rundir);

			case 'css':
				return new CssFile($this->debug, $fileName, $this->rundir);

			case 'gif':
			case 'png':
			case 'jpg':
			case 'jpeg':
			case 'svg':
				return new ImageFile($this->debug, $fileName, $this->rundir);

			case 'swf':
				$this->output->addMessage(Output::NOTICE, sprintf("Found an SWF file (%s), please make sure to include the source files for it, as required by the GPL.", basename($fileName)));

				return new BinaryFile($this->debug, $fileName, $this->rundir);
			case 'ds_store':
				$this->output->addMessage(Output::ERROR, sprintf("Found an OS X specific file at %s, please make sure to remove it prior to submission.", $fileName));

				return new BinaryFile($this->debug, $fileName, $this->rundir);

			case 'lock':
				return new LockFile($this->debug, $fileName, $this->rundir);

			default:

				$file = basename($fileName);
				$this->output->addMessage(Output::WARNING, "Can't detect the file type for $file, handling it as a binary file.");

				return new BinaryFile($this->debug, $fileName, $this->rundir);
		}
	}
private function tryLoadFile($fileName, $extension)
	{
		$this->output->writelnIfDebug("<info>Attempting to load $fileName with extension $extension</info>");
		$this->loadError = false;

		switch (strtolower($extension))
		{
			case 'php':
				// First, check if this file is a lang file.
				$file = basename($fileName);
				$dir  = str_replace($file, '', $fileName);
				$dir  = str_replace($this->basedir, '', $dir);
				$dir  = explode('/', trim($dir, '/'));
				$dir  = array_map('strtolower', $dir);

				if (in_array('language', $dir))
				{
					return new LangFile($this->debug, $fileName, $this->rundir);
				}

				if (in_array('migrations', $dir))
				{
					return new MigrationFile($this->debug, $fileName, $this->rundir);
				}

				return new PHPFile($this->debug, $fileName, $this->rundir);

			case 'html':
			case 'htm':
				return new HTMLFile($this->debug, $fileName, $this->rundir);

			case 'json':
				if (strtolower(basename($fileName)) == 'composer.json')
				{
					return new ComposerFile($this->debug, $fileName, $this->rundir);
				}
				else
				{
					return new JsonFile($this->debug, $fileName, $this->rundir);
				}

			case 'yml':
				if (strtolower(basename($fileName)) == 'services.yml')
				{
					return new ServiceFile($this->debug, $fileName, $this->rundir);
				}
				if (strtolower(basename($fileName)) == 'routing.yml')
				{
					return new RoutingFile($this->debug, $fileName, $this->rundir);
				}

				return new YmlFile($this->debug, $fileName, $this->rundir);

			case 'txt':
			case 'md':
			case 'htaccess':
			case 'gitattributes':
			case 'gitignore':
			case 'map':
			case 'sh': // Decide if we want a special file type for shell files!
				return new PlainFile($this->debug, $fileName, $this->rundir);

			case 'xml':
				return new XmlFile($this->debug, $fileName, $this->rundir);

			case 'js':
				return new JavascriptFile($this->debug, $fileName, $this->rundir);

			case 'css':
				return new CssFile($this->debug, $fileName, $this->rundir);

			case 'gif':
			case 'png':
			case 'jpg':
			case 'jpeg':
			case 'svg':
				return new ImageFile($this->debug, $fileName, $this->rundir);

			case 'swf':
				$this->output->addMessage(Output::NOTICE, sprintf("Found an SWF file (%s), please make sure to include the source files for it, as required by the GPL.", basename($fileName)));

				return new BinaryFile($this->debug, $fileName, $this->rundir);
			case 'ds_store':
				$this->output->addMessage(Output::ERROR, sprintf("Found an OS X specific file at %s, please make sure to remove it prior to submission.", $fileName));

				return new BinaryFile($this->debug, $fileName, $this->rundir);

			case 'lock':
				return new LockFile($this->debug, $fileName, $this->rundir);

			default:

				$file = basename($fileName);
				$this->output->addMessage(Output::WARNING, "Can't detect the file type for $file, handling it as a binary file.");

				return new BinaryFile($this->debug, $fileName, $this->rundir);
		}
	}
Attempts to load a file based on extension.

In case of plaintext files, contents are also checked to see if it isn't a php file.

@param $fileName
@param $extension

@return BinaryFile|ComposerFile|CssFile|HTMLFile|JavascriptFile|JsonFile|PHPFile|PlainFile|XmlFile|YmlFile|ImageFile|null