kitetail / zttp

A developer-experience focused HTTP client, optimized for most common use cases.
MIT License
1.68k stars 120 forks source link

PHP Parse error 7.1 unexpected 'new' (T_NEW) #55

Closed andyliuonline closed 6 years ago

andyliuonline commented 6 years ago

PHP Parse error: syntax error, unexpected 'new' (T_NEW) in

vendor/kitetail/zttp/src/Zttp.php on line 9

Use PHP7.1

adamwathan commented 6 years ago

Hmm my guess is you aren't actually using PHP 7+ like you think; support for methods named new was added in PHP 7.0 so maybe there are multiple versions installed in your environment and the wrong one is being used?

Everything runs on PHP 7.1.8 fine here:

image

Can you share a screenshot of what you see when you output phpversion() in your environment?

OwenMelbz commented 6 years ago

@adamwathan

I think its to do with the new reserved keywords, that are especially present in 7.2

If you run it through php7cc the usage of the ::new gets flagged up

e.g if i try use it from within my project

illumipress____sites_hitachi-erd_vendor_owenmelbz_illumipress__-_____src_helpers_php__illumipress_

then check it with php7cc

owen_mac-n-cheese____sites_hitachi-erd_vendor_owenmelbz_illumipress__zsh_

Hopefully that helps shed some light :)

simonhamp commented 6 years ago

As of PHP 7.0.0 these keywords are allowed as property, constant, and method names of classes, interfaces and traits, except that class may not be used as constant name.

The PHP Manual (emphasis mine)

OwenMelbz commented 6 years ago

@simonhamp They are allowed yeah :) but I don't think that's what the problem is about.

I believe its more about a tool that is being used, such as an IDE or linter is throwing up the error - otherwise IF the version being mentioned is actually the one being used in the browser, it would not fail

adamwathan commented 6 years ago

This is totally valid in PHP 7+ and our tests all run without issue on PHP 7.2 so closing this.

byrdacov commented 4 years ago

It fixes easily, check out the solution