diff --git a/fb-examples/bin/shipit_buck.php-example b/fb-examples/bin/shipit_buck.php-example index d6932253..c38ea8b9 100644 --- a/fb-examples/bin/shipit_buck.php-example +++ b/fb-examples/bin/shipit_buck.php-example @@ -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') { diff --git a/fb-examples/bin/shipit_fbshipit.php-example b/fb-examples/bin/shipit_fbshipit.php-example index df843bca..16f00f85 100644 --- a/fb-examples/bin/shipit_fbshipit.php-example +++ b/fb-examples/bin/shipit_fbshipit.php-example @@ -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'])); } } diff --git a/fb-examples/lib/config/FBShipItConfig.php-example b/fb-examples/lib/config/FBShipItConfig.php-example index 94f12e93..55de3c2e 100644 --- a/fb-examples/lib/config/FBShipItConfig.php-example +++ b/fb-examples/lib/config/FBShipItConfig.php-example @@ -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 diff --git a/fb-examples/lib/shipit/BuckEnvironmentCheckPhase.php-example b/fb-examples/lib/shipit/BuckEnvironmentCheckPhase.php-example index 13ff8a1e..0ac0c8bf 100644 --- a/fb-examples/lib/shipit/BuckEnvironmentCheckPhase.php-example +++ b/fb-examples/lib/shipit/BuckEnvironmentCheckPhase.php-example @@ -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); } @@ -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); } diff --git a/fb-examples/lib/shipit/BuckGenerateDocsPhase.php-example b/fb-examples/lib/shipit/BuckGenerateDocsPhase.php-example index c44855d4..c2e9f6d7 100644 --- a/fb-examples/lib/shipit/BuckGenerateDocsPhase.php-example +++ b/fb-examples/lib/shipit/BuckGenerateDocsPhase.php-example @@ -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]); diff --git a/fb-examples/lib/shipit/FBCommonFilters.php-example b/fb-examples/lib/shipit/FBCommonFilters.php-example index f0f70f00..ca0d8fa0 100644 --- a/fb-examples/lib/shipit/FBCommonFilters.php-example +++ b/fb-examples/lib/shipit/FBCommonFilters.php-example @@ -300,7 +300,7 @@ final class FBCommonFilters { preg_match( '/<(?[^@]*)@fb\.com>/', $changeset->getAuthor(), - $matches, + &$matches, ) && !self::isBotUser($matches['author']) ) { $pulled_by_unixname = $matches['author']; diff --git a/fb-examples/lib/shipit/FBShipItCLI.php-example b/fb-examples/lib/shipit/FBShipItCLI.php-example index ec68a38f..daa147cb 100644 --- a/fb-examples/lib/shipit/FBShipItCLI.php-example +++ b/fb-examples/lib/shipit/FBShipItCLI.php-example @@ -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 diff --git a/fb-examples/lib/shipit/HHVMEnvironmentCheckPhase.php-example b/fb-examples/lib/shipit/HHVMEnvironmentCheckPhase.php-example index fbc81584..625f9c79 100644 --- a/fb-examples/lib/shipit/HHVMEnvironmentCheckPhase.php-example +++ b/fb-examples/lib/shipit/HHVMEnvironmentCheckPhase.php-example @@ -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), diff --git a/src/importit/filter/ImportItPathFilters.php b/src/importit/filter/ImportItPathFilters.php index 1233262a..5322ad58 100644 --- a/src/importit/filter/ImportItPathFilters.php +++ b/src/importit/filter/ImportItPathFilters.php @@ -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(); } diff --git a/src/shipit/ShipItGitHubUtils.php b/src/shipit/ShipItGitHubUtils.php index 8d7d8bdd..06c936ea 100644 --- a/src/shipit/ShipItGitHubUtils.php +++ b/src/shipit/ShipItGitHubUtils.php @@ -179,7 +179,7 @@ private static function cloneAndVerifyRepo( preg_match( '@<(?https://api.github.com[^>]+)>; rel="next"@', $header_line, - $matches, + &$matches, ) ) { $url = $matches['next']; diff --git a/src/shipit/ShipItShellCommand.php b/src/shipit/ShipItShellCommand.php index 56c99783..79f8305d 100644 --- a/src/shipit/ShipItShellCommand.php +++ b/src/shipit/ShipItShellCommand.php @@ -117,7 +117,7 @@ private function runOnceSynchronously(): ShipItShellCommandResult { $fp = proc_open( $command, $fds, - $pipes, + &$pipes, $this->path, $env_vars->toArray(), ); @@ -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) { diff --git a/src/shipit/ShipItUtil.php b/src/shipit/ShipItUtil.php index 579be305..c3ea2324 100644 --- a/src/shipit/ShipItUtil.php +++ b/src/shipit/ShipItUtil.php @@ -50,7 +50,7 @@ public static function parsePatch(string $patch): Iterator { preg_match( '/^@@ -\d+(,(?\d+))? \+\d+(,(?\d+))? @@/', $line, - $matches, + &$matches, ) ) { $minus_lines = $matches['minus_lines'] ?? ''; diff --git a/src/shipit/filter/ShipItMentions.php b/src/shipit/filter/ShipItMentions.php index 3779ef17..5cae5060 100644 --- a/src/shipit/filter/ShipItMentions.php +++ b/src/shipit/filter/ShipItMentions.php @@ -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))); diff --git a/src/shipit/filter/ShipItUserFilters.php b/src/shipit/filter/ShipItUserFilters.php index a21522b2..5560da12 100644 --- a/src/shipit/filter/ShipItUserFilters.php +++ b/src/shipit/filter/ShipItUserFilters.php @@ -24,7 +24,7 @@ classname $user_info, preg_match( $pattern, $changeset->getAuthor(), - $matches, + &$matches, ) && array_key_exists('user', $matches) ) { @@ -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; diff --git a/src/shipit/phase/ShipItPhaseRunner.php b/src/shipit/phase/ShipItPhaseRunner.php index 99d22b90..d90d6788 100644 --- a/src/shipit/phase/ShipItPhaseRunner.php +++ b/src/shipit/phase/ShipItPhaseRunner.php @@ -249,7 +249,7 @@ protected static function printHelp( $rows[$long] = tuple($left, $description); } - ksort($rows); + ksort(&$rows); $help = $rows['help']; $rows->removeKey('help'); diff --git a/src/shipit/repo/ShipItRepo.php b/src/shipit/repo/ShipItRepo.php index cf363e25..a11f9b3d 100644 --- a/src/shipit/repo/ShipItRepo.php +++ b/src/shipit/repo/ShipItRepo.php @@ -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; } diff --git a/src/shipit/repo/ShipItRepoGIT.php b/src/shipit/repo/ShipItRepoGIT.php index a5092531..b088cd1a 100644 --- a/src/shipit/repo/ShipItRepoGIT.php +++ b/src/shipit/repo/ShipItRepoGIT.php @@ -82,7 +82,7 @@ public function findLastSourceCommit( !preg_match( '/^ *(fb)?shipit-source-id: (?[a-z0-9]+)$/m', $log, - $matches, + &$matches, ) ) { return null; @@ -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; } diff --git a/src/shipit/repo/ShipItRepoHG.php b/src/shipit/repo/ShipItRepoHG.php index 4307eac2..1529f2bd 100644 --- a/src/shipit/repo/ShipItRepoHG.php +++ b/src/shipit/repo/ShipItRepoHG.php @@ -124,7 +124,7 @@ public function findLastSourceCommit( !preg_match( '/^ *fbshipit-source-id: (?[a-z0-9]+)$/m', $log, - $matches, + &$matches, ) ) { return null; @@ -297,7 +297,7 @@ private function getChangesetFromNativePatch( preg_match_all( '/^(?:rename|copy) (?:from|to) (?.+)$/m', $patch, - $matches, + &$matches, PREG_PATTERN_ORDER, ); $has_rename_or_copy = new ImmSet($matches['files']);