Skip to content
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

Code cleanup in bootstrap.php #19834

Merged
merged 1 commit into from
Mar 19, 2021
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
"ext-intl": "*",
"pear/mail_mime": "~1.10",
"pear/db": "1.10",
"civicrm/composer-compile-lib": "~0.3 || ~1.0"
"civicrm/composer-compile-lib": "~0.3 || ~1.0",
"ext-json": "*"
Copy link
Contributor

Choose a reason for hiding this comment

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

@eileenmcnaughton was this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@seamuslee001 yep - per pr template - it communicates to the IDE that it is present. No impact on anything else

},
"scripts": {
"post-install-cmd": [
Expand Down
12 changes: 6 additions & 6 deletions ext/sequentialcreditnotes/tests/phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
* The rest of the command to send.
* @param string $decode
* Ex: 'json' or 'phpcode'.
*
* @return string
* Response output (if the command executed normally).
* @throws \RuntimeException
* If the command terminates abnormally.
* @throws \RuntimeException If the command terminates abnormally.
*/
function cv($cmd, $decode = 'json') {
function cv(string $cmd, $decode = 'json'): string {
$cmd = 'cv ' . $cmd;
$descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
$descriptorSpec = [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => STDERR];
$oldOutput = getenv('CV_OUTPUT');
putenv("CV_OUTPUT=json");
putenv('CV_OUTPUT=json');

// Execute `cv` in the original folder. This is a work-around for
// phpunit/codeception, which seem to manipulate PWD.
Expand All @@ -49,7 +49,7 @@ function cv($cmd, $decode = 'json') {

case 'phpcode':
// If the last output is /*PHPCODE*/, then we managed to complete execution.
if (substr(trim($result), 0, 12) !== "/*BEGINPHP*/" || substr(trim($result), -10) !== "/*ENDPHP*/") {
if (strpos(trim($result), '/*BEGINPHP*/') !== 0 || substr(trim($result), -10) !== '/*ENDPHP*/') {
throw new \RuntimeException("Command failed ($cmd):\n$result");
}
return $result;
Expand Down