8000 scope isolation for user includes by nicolas-grekas · Pull Request #2667 · composer/composer · GitHub
[go: up one dir, main page]

Skip to content

scope isolation for user includes #2667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
scope isolation for user includes
  • Loading branch information
nicolas-grekas committed Feb 5, 2014
commit 6d7b9afc4b6bd1bc640b4c2b803c7a87f5a59dd9
2 changes: 1 addition & 1 deletion src/Composer/Autoload/AutoloadGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public static function getLoader()
$file .= <<<'INCLUDE_FILES'
$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
require $file;
\Composer\Autoload\includeFile($file);
}


Expand Down
12 changes: 11 additions & 1 deletion src/Composer/Autoload/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public function unregister()
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
include $file;
includeFile($file);

return true;
}
Expand Down Expand Up @@ -352,3 +352,13 @@ public function findFile($class)
return $this->classMap[$class] = false;
}
}

/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile()
{
include func_get_arg(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err now that I think about it, i forgot to comment on this, why doesn't this function just have a proper parameter?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess I can answer that myself, to keep the scope empty :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function getLoader()

$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
require $file;
\Composer\Autoload\includeFile($file);
}

return $loader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function getLoader()

$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
require $file;
\Composer\Autoload\includeFile($file);
}

return $loader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function getLoader()

$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
require $file;
\Composer\Autoload\includeFile($file);
}

return $loader;
Expand Down
0