oops - previously adjusted spacing breaks the grep
[civicrm-core.git] / tools / scripts / composer / guzzle-mockhandler-fix.sh
CommitLineData
9584d5d5
SL
1#!/bin/bash
2
3## Cleanup the vendor tree. The main issue here is that civi Civi is
4## deployed as a module inside a CMS, so all its source-code gets published.
5## Some libraries distribute admin tools and sample files which should not
6## be published.
7##
8## This script should be idempotent -- if you rerun it several times, it
9## should always produce the same post-condition.
10
11## Replace a line in a file
12## This is a bit like 'sed -i', but dumber and more cross-platform.
13function simple_replace() {
14 php -r 'file_put_contents($argv[1], preg_replace($argv[2], $argv[3], file_get_contents($argv[1])));' "$@"
15}
16
17
5c986de9 18# php 8.1 compatibility
ecab1e43 19if ! grep -q ': int' vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php; then
5c986de9 20 simple_replace vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php '#public function count\(\)$#m' 'public function count(): int'
9584d5d5 21fi