public function testScopeIncludeDoesNotHaveAccessToCurrentClass() { $results = scope_include(getFixturePath('Support/unsafe_scoped_include.php')); // Results will be true when included normally. $this->assertNull($results); }
/** * Gets the package class. * * @return null|string * @throws \NewUp\Exceptions\InvalidPackageTemplateException * @throws \NewUp\Exceptions\TemplatePackageMissingException */ private function getPackageClass() { if ($this->packageClass !== null) { return $this->packageClass; } $includePath = $this->getPackageClassPath(); if (!file_exists($includePath)) { Application::getOutput()->writeln("<comment>{$this->getTemplateName()} is not installed. Attempting to install it now...</comment>"); $result = app(Kernel::class)->getApplication()->callWithSharedOutput('template:install', ['name' => $this->getTemplateName(), '--confirm' => true]); if ($result === Install::INSTALL_FAIL) { // Fail angrily. throw new TemplatePackageMissingException("The package template {$this->getTemplateName()} is not installed or it cannot be found. The package template must be installed before it can be built."); } else { Application::getOutput()->writeln('<comment>It looks like everything went well. We will continue building the package template...</comment>'); } } scope_include($includePath); $this->packageClass = $packageClass = $this->getNamespacedPackageName(); if (!class_exists($packageClass)) { throw new InvalidPackageTemplateException("{$packageClass} class does not exist."); } return $packageClass; }