Skip to content

Commit

Permalink
Backport Ref<T> to 3.29 (#112)
Browse files Browse the repository at this point in the history
* Backport Ref<T> to 3.29

* Remove hhvm nightly from as test hhvm

HHVM 4.41-dev laughs at your `instanceof`. 😆

* (Re)target 3.29 in tests

* Update .travis.yml

* Run tests using Docker

* Remove the orginal test code

I had two shell scripts stacked on top of eachother
  • Loading branch information
lexidor authored and fredemmott committed Jan 27, 2020
1 parent 46d7de3 commit c2a576e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 14 deletions.
27 changes: 21 additions & 6 deletions .travis.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
#!/bin/sh
set -ex
apt update -y
DEBIAN_FRONTEND=noninteractive apt install -y php-cli zip unzip
hhvm --version
php --version
if [ ! -e .git/refs/heads/master ]; then
# - Travis clones with `--branch`, then moves to a detached HEAD state
# - if we're on a detached HEAD, Composer uses master to resolve branch
# aliases.
# So, create the master branch :p
git branch master HEAD
fi

composer install
(
cd $(mktemp -d)
curl https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
)
if (hhvm --version | grep -q -- -dev); then
# Doesn't exist in master, but keep it here so that we can test release
# branches on nightlies too
rm -f composer.lock
fi
hhvm /usr/local/bin/composer install

hh_client

vendor/bin/hacktest tests/

echo > .hhconfig
hh_server --check $(pwd)
vendor/bin/hacktest tests/
18 changes: 10 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
language: php
php:
- hhvm
- hhvm-nightly
matrix:
allow_failures:
- php: hhvm
sudo: required
language: generic
services: docker
env:
- HHVM_VERSION=3.29.1
install:
- docker pull hhvm/hhvm:$HHVM_VERSION
script:
- ./.travis.sh
- docker run --rm -w /var/source -v $(pwd):/var/source hhvm/hhvm:$HHVM_VERSION ./.travis.sh
notifications:
webhooks: https://code.facebook.com/travis/webhook/
slack:
secure: LH2n9tQoW3/OUO/ppXLnGIVAbYtl07avQne/gkcal/csGc18BSly15/bNZvGTlC65aac+yjbGHlcWuBm8Qyl5l2oWZADqoRN7+HeOYw1qSx2eRA5BzVcdKd9eHjl5xobxLC2NXZL/NSiN+Ku/YDuzzkwpGqIcC4EiwvFsab6B2rigdazFaNRceAxnyYwNs3VdzFj9vBDqbfUDFV7lgjZJxbKos26O/Z4F58a2tsV2hbT+tF8W3hfPrMaYuxWVv2+Irc0uGoNc5EG+2eRT5AzMtp6YKzQ5LzEkC/lNwojUg/dr9xV+3vZu+IARy7HsBuX5KZo3IBGHL18q8srgEM4NBQy8IUmVAlGGw7vw1cInIoqUTOvHBqVvDAs2RNr5f7u+2Li0Sw9vuGhoeNtLVvTjZ9r5XmEzdEx9pUFrsO16YdJLnpiYiyWlWAeAkDljXD/d5L/i0sZgaeY/eubYADJr/ZA+M78aiLuw5eEWqu5s9a4xhrGEBkUHyPRpXU1AxVAPr1L6/PK47QKYu1h45QfMQL8TmrNw9VPLUIm5P4k3RFz9CC5C35u5HfFTubErcDl1CZUSoGUuW4foTbkWSJGlgvQquS824mL2VIO5Ut6J6+/2iqsK/HfKOiToDpiiwpe2KoQsyy5QHVWMVNTuKPou1yYH+6Z3DIx8/wEAkvCA+U=
28 changes: 28 additions & 0 deletions src/Ref.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?hh // strict
/*
* Copyright (c) 2004-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

namespace HH\Lib;

/** Wrapper class for getting object (byref) semantics for a value type.
*
* This is especially useful for mutating values outside of a lambda's scope.
*
* In general, it's preferable to refactor to use return values or `inout`
* parameters instead of using this class - however, a `Ref` of a Hack array
* is generally preferable to a Hack collection - e.g. prefer `Ref<vec<T>>`
* over `Vector<T>`.
*
* `C\reduce()` and `C\reduce_with_key()` can also be used in some situations
* to avoid this class.
*/
final class Ref<T> {
<<__RxShallow>>
public function __construct(public T $value) {}
}

0 comments on commit c2a576e

Please sign in to comment.