Skip to content

Commit

Permalink
Merge branch 'release/0.1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Mar 11, 2014
2 parents 8e69a26 + 4aafe55 commit c88d6ab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 26 deletions.
2 changes: 2 additions & 0 deletions bin/psysh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* file that was distributed with this source code.
*/

/* <<< */
if (is_file(__DIR__ . '/../vendor/autoload.php')) {
require(__DIR__ . '/../vendor/autoload.php');
} elseif (is_file(__DIR__ . '/../../../autoload.php')) {
Expand All @@ -21,6 +22,7 @@ if (is_file(__DIR__ . '/../vendor/autoload.php')) {
'php composer.phar install' . PHP_EOL
);
}
/* >>> */

use Psy\Shell;
use Symfony\Component\Console\Input\ArgvInput;
Expand Down
34 changes: 9 additions & 25 deletions src/Psy/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public function compile($pharFile = 'psysh.phar')
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/composer/autoload_namespaces.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/composer/autoload_classmap.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/composer/ClassLoader.php'));
$this->addPsyshBin($phar);

// Stubs
$phar->setStub($this->getStub());
Expand Down Expand Up @@ -101,18 +100,6 @@ private function addFile($phar, $file, $strip = true)
$phar->addFromString($path, $content);
}

/**
* Add the psysh bin file.
*
* @param Phar $phar
*/
private function addPsyshBin($phar)
{
$content = file_get_contents(__DIR__.'/../../bin/psysh');
$content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content);
$phar->addFromString('bin/psysh', $content);
}

/**
* Removes whitespace from a PHP source string while preserving line numbers.
*
Expand Down Expand Up @@ -151,24 +138,21 @@ private function stripWhitespace($source)
/**
* Get a Phar stub for psysh
*
* This is basically the psysh bin, with the autoload require statements swapped out.
*
* @return string
*/
private function getStub()
{
return <<<'EOS'
#!/usr/bin/env php
<?php
$autoload = <<<'EOS'
Phar::mapPhar('psysh.phar');
require 'phar://psysh.phar/vendor/autoload.php';
EOS;

// Allow running phar directly, or including.
if ('cli' === php_sapi_name() && in_array(basename(__FILE__), array(basename($_SERVER['argv'][0]), basename(realpath($_SERVER['argv'][0]))))) {
require 'phar://psysh.phar/bin/psysh';
} else {
require 'phar://psysh.phar/vendor/autoload.php';
}
$content = file_get_contents(__DIR__.'/../../bin/psysh');
$content = preg_replace('{/\* <<<.*?>>> \*/}sm', $autoload, $content);
$content .= "__HALT_COMPILER();";

__HALT_COMPILER();
EOS;
return $content;
}
}
2 changes: 1 addition & 1 deletion src/Psy/Shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
class Shell extends Application
{
const VERSION = 'v0.1.3';
const VERSION = 'v0.1.4';

const PROMPT = '>>> ';
const BUFF_PROMPT = '... ';
Expand Down

0 comments on commit c88d6ab

Please sign in to comment.