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

[PHP 8.0] [Meta] #3127

Closed
TomasVotruba opened this issue Apr 2, 2020 · 5 comments
Closed

[PHP 8.0] [Meta] #3127

TomasVotruba opened this issue Apr 2, 2020 · 5 comments

Comments

@TomasVotruba
Copy link
Member

TomasVotruba commented Apr 2, 2020

New Accepted Features

get_resource_id()

mixed type

constructor promotion


Generic sources


1. str_starts_with() / str_ends_with() ✔️

2. str_contains() ✔️

3. Stringable interface for classes with __toString() ✔️

4. Attributes v2 ✔️

5. static type ✔️

6. ::class on objects ✔️

7. get_debug_type ✔️

8. token_get_all to PhpToken ✔️

9. catches without $variable ✔️

10. match ✔️


New features, without no path to upgrade

@TomasVotruba TomasVotruba changed the title [PHP 8.0] Deprecations [PHP 8.0] [Meta] Apr 23, 2020
@staabm
Copy link
Contributor

staabm commented Apr 23, 2020

get_debug_type() see https://wiki.php.net/rfc/get_debug_type

Object-based token_get_all() https://wiki.php.net/rfc/token_as_object

@TomasVotruba
Copy link
Member Author

TomasVotruba commented Apr 23, 2020

@staabm Could you provide before/after diff snippet for both of them? So we can make rules of it and focus on that part only

@staabm
Copy link
Contributor

staabm commented May 11, 2020

another merged PR: php/php-src#5427

before php8

$resource = fopen(...); // example way to get a resource 
echo (int) $resource;

with php8

$resource = fopen(...); // example way to get a resource 
echo get_resource_id($resource);

@staabm
Copy link
Contributor

staabm commented May 11, 2020

Could you provide before/after diff snippet for both of them? So we can make rules of it and focus on that part only

regarding: Object-based token_get_all() wiki.php.net/rfc/token_as_object

before

$tokens = token_get_all($code);
foreach ($tokens as $token) {
    if (is_array($token)) {
       $name = token_name($token[0]);
       $text = $token[1];
    } else {
       $name = null;
       $text = $token;
    }
}

after (php8+)

$tokens = PhpToken::getAll($code);
foreach($tokens as $phpToken) {
   // it is not necessary to continuously check whether an array or string token is being used.

   $name = $phpToken->getTokenName();
   $text = $phpToken->text;
}

@TomasVotruba
Copy link
Member Author

AFAIK all cases are resolved now 👍

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

2 participants