Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Commit

Permalink
require call-time pass-by-reference
Browse files Browse the repository at this point in the history
Summary: Will cherry pick to 3.24.

Reviewed By: dlreeves

Differential Revision: D6657922

fbshipit-source-id: ff2d60fe41e7506b1463c300471e42d15b6bb4bd
  • Loading branch information
fredemmott authored and facebook-github-bot committed Jan 8, 2018
1 parent d92daf6 commit c242594
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion fb-examples/bin/shipit_buck.php-example
Expand Up @@ -155,7 +155,7 @@ class ShipItBuck
if (preg_match('/(^|\n)GitHub Author: (.*?)(\n|$)/si',
$changeset->getMessage()) &&
preg_match('/<([^@]*)@fb\.com>/',
$changeset->getAuthor(), $matches) &&
$changeset->getAuthor(), &$matches) &&
is_array($matches) &&
isset($matches[1])) {
if ($matches[1] === 'svcscm') {
Expand Down
2 changes: 1 addition & 1 deletion fb-examples/bin/shipit_fbshipit.php-example
Expand Up @@ -150,7 +150,7 @@ final class ShipItFBShipIt extends FBShipItCLI {

foreach (self::getProjectFilePatterns() as $pattern) {
$matches = [];
if (preg_match($pattern, $path, $matches)) {
if (preg_match($pattern, $path, &$matches)) {
return !$public_projects->contains(strtolower($matches['project']));
}
}
Expand Down
2 changes: 1 addition & 1 deletion fb-examples/lib/config/FBShipItConfig.php-example
Expand Up @@ -126,7 +126,7 @@ abstract class FBShipItConfig implements IHasFBShipItCLIStaticConfig {
}
$paths = $paths->toArray();
// Sort least specific to most specific.
sort($paths);
sort(&$paths);
$roots = Set {};
foreach ($paths as $path) {
// If this path starts with any elements in the set of roots we have
Expand Down
4 changes: 2 additions & 2 deletions fb-examples/lib/shipit/BuckEnvironmentCheckPhase.php-example
Expand Up @@ -31,7 +31,7 @@ final class BuckEnvironmentCheckPhase extends EnvironmentCheckPhase {
'ant', '-version',
);
$match = array();
if (!preg_match('@version ([0-9\.]+)@', $ant_v, $match)) {
if (!preg_match('@version ([0-9\.]+)@', $ant_v, &$match)) {
fprintf(STDERR, "Couldn't identify ant version: %s\n", $ant_v);
exit(1);
}
Expand All @@ -45,7 +45,7 @@ final class BuckEnvironmentCheckPhase extends EnvironmentCheckPhase {
'java', '-version',
);
$match = array();
if (!preg_match('@version "([0-9\.]+)@', $java_v, $match)) {
if (!preg_match('@version "([0-9\.]+)@', $java_v, &$match)) {
fprintf(STDERR, "Couldn't identify java version: %s\n", $java_v);
exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion fb-examples/lib/shipit/BuckGenerateDocsPhase.php-example
Expand Up @@ -82,7 +82,7 @@ final class BuckGenerateDocsPhase extends ShipItPhase {
1 => array('file', '/dev/null', 'w'),
2 => array('file', '/dev/null', 'w'),
),
$pipes,
&$pipes,
$sourcePath
);
fclose($pipes[0]);
Expand Down
2 changes: 1 addition & 1 deletion fb-examples/lib/shipit/FBCommonFilters.php-example
Expand Up @@ -300,7 +300,7 @@ final class FBCommonFilters {
preg_match(
'/<(?<author>[^@]*)@fb\.com>/',
$changeset->getAuthor(),
$matches,
&$matches,
) && !self::isBotUser($matches['author'])
) {
$pulled_by_unixname = $matches['author'];
Expand Down
2 changes: 1 addition & 1 deletion fb-examples/lib/shipit/FBShipItCLI.php-example
Expand Up @@ -69,7 +69,7 @@ abstract class FBShipItCLI
}
$paths = $paths->toArray();
// Sort least specific to most specific.
sort($paths);
sort(&$paths);
$roots = Set {};
foreach ($paths as $path) {
// If this path starts with any elements in the set of roots we have
Expand Down
Expand Up @@ -16,7 +16,7 @@ final class HHVMEnvironmentCheckPhase extends EnvironmentCheckPhase {
public function runImpl(ShipItBaseConfig $config): void {
$gcc_check_cmd = "gcc --version";
$gcc_check_output = array();
exec($gcc_check_cmd, $gcc_check_output);
exec($gcc_check_cmd, &$gcc_check_output);
if (
strpos(
implode("", $gcc_check_output),
Expand Down
2 changes: 1 addition & 1 deletion src/importit/filter/ImportItPathFilters.php
Expand Up @@ -55,7 +55,7 @@ public static function invertShipIt(
// that if two src path entries exist such that one of them is a prefix of
// the other, the prefix always appears last. This ensures that mappings
// for subdirectories always take precedence over less-specific mappings.
krsort($reverse_mapping);
krsort(&$reverse_mapping);

return $reverse_mapping->toImmMap();
}
Expand Down
2 changes: 1 addition & 1 deletion src/shipit/ShipItGitHubUtils.php
Expand Up @@ -179,7 +179,7 @@ private static function cloneAndVerifyRepo(
preg_match(
'@<(?<next>https://api.github.com[^>]+)>; rel="next"@',
$header_line,
$matches,
&$matches,
)
) {
$url = $matches['next'];
Expand Down
8 changes: 4 additions & 4 deletions src/shipit/ShipItShellCommand.php
Expand Up @@ -117,7 +117,7 @@ private function runOnceSynchronously(): ShipItShellCommandResult {
$fp = proc_open(
$command,
$fds,
$pipes,
&$pipes,
$this->path,
$env_vars->toArray(),
);
Expand Down Expand Up @@ -155,9 +155,9 @@ private function runOnceSynchronously(): ShipItShellCommandResult {
$ready_streams = [$stdout_stream, $stderr_stream];
$null_byref = null;
$result = stream_select(
$ready_streams,
/* write streams = */ $null_byref,
/* exception streams = */ $null_byref,
&$ready_streams,
/* write streams = */ &$null_byref,
/* exception streams = */ &$null_byref,
/* timeout = */ null,
);
if ($result === false) {
Expand Down
2 changes: 1 addition & 1 deletion src/shipit/ShipItUtil.php
Expand Up @@ -50,7 +50,7 @@ public static function parsePatch(string $patch): Iterator<string> {
preg_match(
'/^@@ -\d+(,(?<minus_lines>\d+))? \+\d+(,(?<plus_lines>\d+))? @@/',
$line,
$matches,
&$matches,
)
) {
$minus_lines = $matches['minus_lines'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/shipit/filter/ShipItMentions.php
Expand Up @@ -51,7 +51,7 @@ public static function getMentions(
preg_match_all(
self::MENTIONS_PATTERN,
$changeset->getMessage(),
$matches,
&$matches,
PREG_SET_ORDER,
);
return (new ImmSet(array_map($match ==> $match[1], $matches)));
Expand Down
4 changes: 2 additions & 2 deletions src/shipit/filter/ShipItUserFilters.php
Expand Up @@ -24,7 +24,7 @@ classname<ShipItUserInfo> $user_info,
preg_match(
$pattern,
$changeset->getAuthor(),
$matches,
&$matches,
)
&& array_key_exists('user', $matches)
) {
Expand Down Expand Up @@ -85,7 +85,7 @@ public static function rewriteAuthorFromMessagePattern(
string $pattern,
): ShipItChangeset {
$matches = [];
if (preg_match($pattern, $changeset->getMessage(), $matches)) {
if (preg_match($pattern, $changeset->getMessage(), &$matches)) {
return $changeset->withAuthor($matches['author']);
}
return $changeset;
Expand Down
2 changes: 1 addition & 1 deletion src/shipit/phase/ShipItPhaseRunner.php
Expand Up @@ -249,7 +249,7 @@ protected static function printHelp(

$rows[$long] = tuple($left, $description);
}
ksort($rows);
ksort(&$rows);

$help = $rows['help'];
$rows->removeKey('help');
Expand Down
6 changes: 5 additions & 1 deletion src/shipit/repo/ShipItRepo.php
Expand Up @@ -142,7 +142,11 @@ public static function open(
protected static function parseDiffHunk(string $hunk): ?ShipItDiff {
list($header, $body) = explode("\n", $hunk, 2);
$matches = array();
preg_match('@^diff --git [ab]/(.*?) [ab]/(.*?)$@', trim($header), $matches);
preg_match(
'@^diff --git [ab]/(.*?) [ab]/(.*?)$@',
trim($header),
&$matches,
);
if (count($matches) === 0) {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/shipit/repo/ShipItRepoGIT.php
Expand Up @@ -82,7 +82,7 @@ public function findLastSourceCommit(
!preg_match(
'/^ *(fb)?shipit-source-id: (?<commit>[a-z0-9]+)$/m',
$log,
$matches,
&$matches,
)
) {
return null;
Expand Down Expand Up @@ -114,7 +114,7 @@ public function findNextCommit(
return null;
}
$revs = explode("\n", trim($log));
list($rev) = explode(' ', array_pop($revs), 2);
list($rev) = explode(' ', array_pop(&$revs), 2);
return $rev;
}

Expand Down
4 changes: 2 additions & 2 deletions src/shipit/repo/ShipItRepoHG.php
Expand Up @@ -124,7 +124,7 @@ public function findLastSourceCommit(
!preg_match(
'/^ *fbshipit-source-id: (?<commit>[a-z0-9]+)$/m',
$log,
$matches,
&$matches,
)
) {
return null;
Expand Down Expand Up @@ -297,7 +297,7 @@ private function getChangesetFromNativePatch(
preg_match_all(
'/^(?:rename|copy) (?:from|to) (?<files>.+)$/m',
$patch,
$matches,
&$matches,
PREG_PATTERN_ORDER,
);
$has_rename_or_copy = new ImmSet($matches['files']);
Expand Down

0 comments on commit c242594

Please sign in to comment.