Skip to content

Commit

Permalink
Add Pharaoh to Box (#238)
Browse files Browse the repository at this point in the history
Add [Pharaoh](https://github.com/paragonie/pharaoh) to provide a new `diff` command

Closes #209
  • Loading branch information
theofidry authored May 30, 2018
1 parent c4be6de commit 924fa40
Show file tree
Hide file tree
Showing 16 changed files with 752 additions and 30 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ great things:
- ⚙️ Zero configuration by default
- 🚔 [Requirements checker](doc/requirement-checker.md#requirements-checker)
- 🚨 Friendly error logging experience
- 🔍 Retrieve information about the PHAR extension or a PHAR file and its contents (`box info`)
- 🔍 Retrieve information about the PHAR extension or a PHAR file and its contents (`box info` or `box diff`)
- 🕵️‍♀️ Verify the signature of an existing PHAR (`box verify`)
- 📝 Use Git tags and short commit hashes for versioning

Expand Down
11 changes: 0 additions & 11 deletions TODO

This file was deleted.

4 changes: 4 additions & 0 deletions bar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

echo "Hello world!";

1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"humbug/php-scoper": "dev-master#c0384b6",
"justinrainbow/json-schema": "^5.2",
"nikic/iter": "^1.6",
"paragonie/pharaoh": "^0.3.1",
"phpseclib/phpseclib": "~2.0",
"seld/jsonlint": "^1.6",
"symfony/console": "^3.4 || ^4.0",
Expand Down
291 changes: 290 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions fixtures/diff/not-a-phar.phar
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This file is not a real PHAR file! Fake!

Binary file added fixtures/diff/simple-phar
Binary file not shown.
Binary file added fixtures/diff/simple-phar-bar.phar
Binary file not shown.
Binary file added fixtures/diff/simple-phar-foo.phar
Binary file not shown.
Binary file modified fixtures/verify/simple-phar.phar
Binary file not shown.
36 changes: 36 additions & 0 deletions scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,42 @@ function (string $filePath, string $prefix, string $contents): string {
$contents
);
},
function (string $filePath, string $prefix, string $contents): string {
if ('vendor/paragonie/sodium_compat/autoload.php' !== $filePath) {
return $contents;
}

return preg_replace(
'/\'sodiumCompatAutoloader\'/',
sprintf(
'\'%s\\%s\'',
$prefix,
'sodiumCompatAutoloader'
),
preg_replace(
'/\$namespace = \'ParagonIE_Sodium_\';/',
sprintf(
'$namespace = \'%s\\ParagonIE_Sodium_\';',
$prefix
),
$contents
)
);
},
function (string $filePath, string $prefix, string $contents): string {
if ('vendor/paragonie/sodium_compat/lib/php72compat.php' !== $filePath) {
return $contents;
}

return preg_replace(
'/\\\\define\\("SODIUM_{\\$constant}", \\\\constant\\("ParagonIE_Sodium_Compat::{\\$constant}"\\)\\);/',
sprintf(
'\define("SODIUM_{$constant}", \constant("%s\\ParagonIE_Sodium_Compat::{$constant}"));',
$prefix
),
$contents
);
},
],
'whitelist' => [
\Composer\Autoload\ClassLoader::class,
Expand Down
1 change: 1 addition & 0 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ protected function getDefaultCommands(): array

$commands[] = new Command\Build();
$commands[] = new Command\Compile();
$commands[] = new Command\Diff();
$commands[] = new Command\Info();
$commands[] = new Command\Validate();
$commands[] = new Command\Verify();
Expand Down
Loading

0 comments on commit 924fa40

Please sign in to comment.