Require a file

@access private
@param string $path
545606
private function require_file($path) {
		$path = realpath($path);
		if (file_exists($path)) {
			require_once $path;

			// Opcache compilation
			$opcache_enabled = ini_get('opcache.enable');
			$opcache_cli_enabled = ini_get('opcache.enable_cli');
			if ( (php_sapi_name() == 'cli' and $opcache_cli_enabled) or (php_sapi_name() != 'cli' and $opcache_enabled)) {
				if (function_exists('opcache_is_script_cached') and function_exists('opcache_compile_file')) {
					if (!opcache_is_script_cached($path)) {
						// We have noticed OPcache sometimes yields a warning when compiling a file,
						// while that exact same file compiled just fine moments earlier. Worse, it
						// seems the OPcache for said file becomes corrupt somehow. This might
						// be a bug somewhere. We'll try to work around this issue by suppressing the
						// warning and explicitly invalidate the cache for the file if compilation fails.
						if (@opcache_compile_file($path) === false) {
							opcache_invalidate($path, true);
						}
					}
				}
			}

			return true;
		} else {
			throw new \Exception('File not found');
		}
	}
926435
public static function createFileDir($path)
    {
        if (!file_exists($path)) {
            self::createFileDir(dirname($path));
            mkdir($path, 0777);
        }
    }
751827
private function includeFormatIfNeeded(&$path, &$requirements)
    {
        if (true === $this->includeFormat) {
            $path .= '.{_format}';

            if (!isset($requirements['_format']) && !empty($this->formats)) {
                $requirements['_format'] = implode('|', array_keys($this->formats));
            }
        }
    }
887922
public function setStdinFile(string $path): Process
    {
        if (!is_readable($path)) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'path'; ".
                "'$path' is not a readable file"
            );
        }
        $this->spec[self::STDIN] = ["file", $path, "r"];
        $this->stdin = "";
        return $this;
    }
200025
public function createFile(string $path): File {
    $localFile = $this->instantiateFile($path);
    $localFile->create();
    return $localFile;
  }
498336
public function setPath(string $path)
    {
        $this->path = $path;
        
        // update path to templates and preload list of templates.
        $this->contentPath = $this->path . DIR_CONTENT_BASENAME;
        $this->templatesPath = $this->contentPath . DIR_TEMPLATES_BASENAME;
        
        $this->templates = File::listFilesRecursively($this->templatesPath, false, EXT_PART, EXT_PAGE);
    }
1125052
public function setPrivateKey($path)
    {
        if(!file_exists($path)) {
            throw new \InvalidArgumentException('the private key file does\'t exist');
        }

        $this->privateKey = file_get_contents($path);

        return $this;
    }
184698
public static function loadFromPath($path)
	{
		// on test do not load plugins
		if(self::isUnableToRunPlugins())
		{
			return;
		}

		if (!file_exists($path))
		{
			throw new InvalidArgumentException("The path [{$path}] doesn't exist to load plugins.");
		}

		$plugins = require $path;

		foreach ($plugins as $plugin)
		{
			if (array_key_exists($plugin, self::$lookup))
			{
				$plugin = __DIR__ . DS . self::$lookup[$plugin];
			}

			if (file_exists($plugin))
			{
				require_once $plugin;
			}
		}

	}
724699
public static function fromUnReadableFile($path)
    {
        if (! file_exists($path)) {
            return new self(sprintf('Invalid path provided, the path "%s" does not seem to exist', $path));
        }

        if (is_dir($path)) {
            return new self(sprintf('The provided path "%s" is a directory, and it cannot be read as a file', $path));
        }

        return new self(sprintf('The provided path "%s" is invalid', $path));
    }
1041844
public function setPath($path)
    {
        if (!file_exists($path))
        {
            mkdir($path, 0777, true);
        }

        $this->path = $path;
    }
526587
public function loadIniFile($path)
    {

        $this->iniSettings = (array)parse_ini_string(
            $this->pool->fileService->getFileContents($path, false),
            true
        );

        return $this;
    }
287831
public function load($path)
    {
        $factory = $this;

        if (is_dir($path)) {
            foreach (Finder::create()->files()->name('*.php')->in($path) as $file) {
                require $file->getRealPath();
            }
        }

        return $factory;
    }
438966
public function requireDirectory($path = null)
    {
        if ( ! is_null($path))
        {
            return $this->directory($path)->requireDirectory();
        }

        if ($iterator = $this->iterateDirectory($this->path))
        {
            return $this->processRequire($iterator);
        }

        return $this;
    }
263320
public function setPath($path)
    {
        $uri = $this->guzzleRequest->getUri()->withPath($path);
        $this->guzzleRequest = new Request($this->guzzleRequest->getMethod(), $uri);
    }
1111071
private function load(string $path): self
    {
        return $this
            ->setExtensionFromPath($path)
            ->loadFromPath($path)
            ->updateDimensions();
    }
1169902
protected function loadDefinitions($path)
    {
        if (file_exists($path)) {

            include $path;

            if (!empty($config['notification_definitions'])) {
                $this->notifications = array_merge($this->notifications, $config['notification_definitions']);
            }
        }
    }
616679
public function requireFile($file)
    {
        if (PHP_EOL !== "\n" && strpos($file, 'phar://') !== 0) {
            $realPath = strtr(realpath($file), '\\', '/');
            if ($realPath !== $file) {
                trigger_error("File name ($realPath) case mismatch for .$file", E_USER_ERROR);
            }
        }
        /** @noinspection PhpIncludeInspection */
        require $file;
    }