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

Cannot build application on HHVM #3320

Closed
danon opened this issue Oct 2, 2018 · 17 comments
Closed

Cannot build application on HHVM #3320

danon opened this issue Oct 2, 2018 · 17 comments

Comments

@danon
Copy link

danon commented Oct 2, 2018

Q A
PHPUnit version ^6.4
PHP version HipHop VM 3.28.3
Installation Method Composer

While running a travis build for hhvm this is an error I get

Fatal error: Uncaught Error: Parameter $constraints is variadic and has a type constraint (Constraint); variadic params with type constraints are not supported in non-Hack files in phar://phpunit-6.5.2.phar/phpunit/Framework/Constraint/LogicalAnd.php:29
Stack trace:
#0 /home/travis/.phpenv/versions/hhvm-stable/bin/phpunit(103): include()
#1 {main}

What can I do to run tests in PhpUnit on hhvm?

@danon
Copy link
Author

danon commented Oct 2, 2018

$ composer info | sort
doctrine/instantiator              1.1.0  A small, lightweight utility to...
guzzlehttp/guzzle                  6.3.3  Guzzle is a PHP HTTP client lib...
guzzlehttp/promises                v1.3.1 Guzzle promises library
guzzlehttp/psr7                    1.4.2  PSR-7 message implementation th...
myclabs/deep-copy                  1.8.1  Create deep copies (clones) of ...
phar-io/manifest                   1.0.1  Component for reading phar.io m...
phar-io/version                    1.0.1  Library for handling version in...
phpdocumentor/reflection-common    1.0.1  Common reflection classes used ...
phpdocumentor/reflection-docblock  4.3.0  With this component, a library ...
phpdocumentor/type-resolver        0.4.0 
phpspec/prophecy                   1.8.0  Highly opinionated mocking fram...
phpunit/php-code-coverage          5.3.2  Library that provides collectio...
phpunit/php-file-iterator          1.4.5  FilterIterator implementation t...
phpunit/php-text-template          1.2.1  Simple template engine.
phpunit/php-timer                  1.0.9  Utility class for timing
phpunit/php-token-stream           2.0.2  Wrapper around PHP's tokenizer ...
phpunit/phpunit                    6.5.13 The PHP Unit Testing framework.
phpunit/phpunit-mock-objects       5.0.10 Mock Object library for PHPUnit
psr/http-message                   1.0.1  Common interface for HTTP messages
psr/log                            1.0.2  Common interface for logging li...
satooshi/php-coveralls             v2.0.0 PHP client library for Coverall...
sebastian/code-unit-reverse-lookup 1.0.1  Looks up which function or meth...
sebastian/comparator               2.1.3  Provides the functionality to c...
sebastian/diff                     2.0.1  Diff implementation
sebastian/environment              3.1.0  Provides functionality to handl...
sebastian/exporter                 3.1.0  Provides the functionality to e...
sebastian/global-state             2.0.0  Snapshotting of global state
sebastian/object-enumerator        3.0.3  Traverses array structures and ...
sebastian/object-reflector         1.1.1  Allows reflection of object att...
sebastian/recursion-context        3.0.0  Provides functionality to recur...
sebastian/resource-operations      1.0.0  Provides a list of PHP built-in...
sebastian/version                  2.0.1  Library that helps with managin...
symfony/config                     v4.1.5 Symfony Config Component
symfony/console                    v4.1.5 Symfony Console Component
symfony/filesystem                 v4.1.5 Symfony Filesystem Component
symfony/polyfill-ctype             v1.9.0 Symfony polyfill for ctype func...
symfony/polyfill-mbstring          v1.9.0 Symfony polyfill for the Mbstri...
symfony/stopwatch                  v4.1.5 Symfony Stopwatch Component
symfony/yaml                       v4.1.5 Symfony Yaml Component
theseer/tokenizer                  1.1.0  A small library for converting ...
webmozart/assert                   1.3.0  Assertions to validate method i...

@sebastianbergmann
Copy link
Owner

HHVM is not supported.

@danon
Copy link
Author

danon commented Oct 2, 2018

Yes, I found that out, but is there anything I can do to run the tests on HHVM? Can I downgrade it to some version or something?

Is there no way to run it, other than to rewrite my tests to other testing framework?

@ayg
Copy link

ayg commented Oct 9, 2018

HHVM has announced that they no longer intend to maintain compatibility with PHP, so if you want to stay on HHVM, you should not expect to be able to use anything that's written for PHP. You should commit your app to either PHP 7 without HHVM compatibility, or pure Hack without PHP compatibility. Trying to work with both is going to cause a lot of headaches for you, and will eventually be impossible.

@danon
Copy link
Author

danon commented Oct 9, 2018

@ayg Yes, I'm aware of that. However, my applications still work under HHVM, so I see no reason to stop building it on HHVM.

The only thing, that's stopping me is PhpUnit, which can't be run on hhvm. If I were to rewrite all my tests to other Php testing frameworks, everything would work as expected

@epdenouden
Copy link
Contributor

@danon In that case your choices are simple:

  • keep using an older version of PHPUnit that works with HHVM
  • port your tests to a testing framework that is fine with the HHVM
  • port your tests to PHPUnit (or other newer frameworks) that are based on PHP v7

Many of the improvements brought by the HHVM are now part of the latest versions of PHP: performance, stability and language features. From a maintainability standpoint I'd suggest upgrading your test collection to a newer version of PHPUnit.

If for no other reason that new functionality is being added and major refactoring efforts are underway. Come to us, join ussssss... 👾

@danon
Copy link
Author

danon commented Oct 9, 2018

@epdenouden I wanted to do it! Really! but:

  • I can't find and older version of PhpUnit, they all use variadic arguments which aren't compatible with HHVM
  • I couldn't find a single test framework for HHVM, maybe you know one?
  • Isn't PhpUnit 7.4 supposed to work on PHPv7? Cause it still doesn't work with hhvm.

Sorry, but the project I'm maintaining has to work for Php v7 and it would be nice if it worked on HHVM and it does! But phpunit doesn't.

@epdenouden
Copy link
Contributor

epdenouden commented Oct 9, 2018

Hello @danon!

Yes, PHPUnit in fact requires PHP 7.1 or higher. Because we want to use every bit of performance we can get and the new language features are nice, too. Since PHP7 is the way forward HHVM support has actually been removed from PHPUnit a while ago.

I do not know of any other frameworks that keep support for either PHP5 or HHVM alive. Keep in mind that both those technologies are almost at their end-of-life.

I am wondering, is it really that much work to update your tests to work with PHPUnit 7.x?

@danon
Copy link
Author

danon commented Oct 9, 2018

@epdenouden

  • My tests are already running on PhpUnit 7.4 :) (on php 7.1)
  • I'm ok with running the tests on whatever php version (including the latests)
  • I'm ok with running the tests on whatever hhvm version (including the latests)

Please, tell me. How can I run phpunit tests on hhvm?

@epdenouden
Copy link
Contributor

@danon The short answer is: you cannot run your PHPUnit tests on the HHVM

I understand you want your project to run both on PHP v7 and the HHVM. The closest you can come to a 'solution' would be: write extensive tests for your library (the regular expression one?) and make sure it's 100% coverage and green, so you are pretty sure everything works as expected.

Then cover the HHVM runtime context with a list of integration tests along the lines of: yourRegExTest($input) !== $expectedOutput.

That way you make sure

  • the business logic and flow of your project has maximum coverage under normal PHP
  • when running the HHVM the output at least is the same as the PHP-only version

I hope this helps.

@epdenouden
Copy link
Contributor

BTW, keep in mind that this will complicate your CI: now you will have to run your project through two testing unit test passes, each with a slightly different PHP version+config.

@danon
Copy link
Author

danon commented Oct 9, 2018

@epdenouden But you, in your answer suggested three options:

  • keep using an older version of PHPUnit that works with HHVM
  • port your tests to a testing framework that is fine with the HHVM
  • port your tests to PHPUnit (or other newer frameworks) that are based on PHP v7

So I have questions:

  • What version of phpunit keeps working with hhvm?
  • Please, tell me what testing framework is fine with hhvm?
  • My tests are already phpunit 7.4 and are running on php7.1 and php7.2 - what now?

CI is not a problem for me.

@epdenouden
Copy link
Contributor

Ok, I will rephrase and answer your exact questions:

  • I personally do not know what the last version of PHPUnit was that supports the HHVM. To find out, search for the phrase 'HHVM' in the README files of previous versions. Myself I only started contributing starting with PHPUnit v7 and as far as I know HHVM is looooong ago.
  • I never researched HHVM compatibility of other testing frameworks. However, there aren't many such frameworks for PHP in use today, so Google is your friend here.
  • If your tests are running on PHPUnit 7.4 already, you could write a quick'n'dirty integration tests for the HHVM very easily! Just capture the input and actual values for the asserts and you have a basic set. Taa-daa :)

For more context, search for HHVM in the issues here on Github. For example: #3207

@siraic
Copy link

siraic commented Oct 9, 2018

  • HHVM never aimed to support PHP7, only PHP5. Any support for PHP 7 code is purely coincidental. They are now on a path to remove PHP support altogether and fully focus on Hack in future versions.
  • PHPUnit 6 and up only supports PHP7, PHPUnit 5 supported both 5.6 and 7, but since typed variadic function arguments (introduced in 5.6) were never supported in HHVM, I'm not sure that version is going to work. PHPUnit 4 supported PHP5.5 (so no variadic arguments can be used), but officially didn't support PHP7, though you might find a version working with it.

If you are set on keeping support for HHVM, I suggest you branch off from your master branch now, lock your PHP version to 5.5^ in your composer file, use (unsupported) PHPUnit 4 and keep supporting PHP 5.5 and HHVM in this separate version of your code. Maybe right now only PHPUnit is preventing HHVM compatibility (or it might just be the first fatal error to pop up, while there are way more incompatibilities hidden behind it), but many more libraries are going be unsupported soon enough. It is not going to be worth the headaches trying to juggle dependencies that accidentally supported HHVM as well as recent PHP versions.

@clue
Copy link

clue commented Jan 9, 2019

@danon So I have questions:

  • What version of phpunit keeps working with hhvm?

  • Please, tell me what testing framework is fine with hhvm?

  • My tests are already phpunit 7.4 and are running on php7.1 and php7.2 - what now?

While I agree with the above objections that HHVM decided to drop PHP support in the future and I do not expect PHPUnit to keep supporting HHVM, just to answer your question, here's how you can run an outdated and unsupported PHPUnit version with HHVM: Outdated PHPUnit 5 appears to be the last version that I could get to run on outdated HHVM on Travis CI. You can also explicitly install another PHPUnit version just for HHVM using Travis CI, for example see also clue/socket-raw#42.

@danon
Copy link
Author

danon commented Jan 9, 2019

So there is no testing framework for PHP for HHVM?

@filips123
Copy link

What is the latest version that supported HHVM? Does it support namespaced test syntax (available after PHPUnit 4.8.36)?

ybelenko added a commit to ybelenko/openapi-generator that referenced this issue May 7, 2020
PHPUnit dropped support of hhvm, so build unlikely will pass tests.
sebastianbergmann/phpunit#3320 (comment)
wing328 pushed a commit to OpenAPITools/openapi-generator that referenced this issue May 8, 2020
* Bump PHP version to 7.1 in readme

* Bump PHP version to 7.1 in class templates

* Remove HHVM from Travis CI config

PHPUnit dropped support of hhvm, so build unlikely will pass tests.
sebastianbergmann/phpunit#3320 (comment)

* Remove sudo: false from Travis-CI config

Official doc recommendation:
https://docs.travis-ci.com/user/reference/trusty/#container-based-infrastructure

* Change tested versions to 7.1, 7.2 in Travis-CI

* Remove PHP_CodeSniffer from dev dependencies

There is another linter(PHP CS Fixer) which is fully configured while
CodeSniffer isn't configured at all.

* Use caret instead of tilde in dependencies

^2.12 equals (>= 2.12.0 && <3.0.0) while ~2.12 is (>=2.12.0 && <2.13.0)

* Refresh samples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants