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: protobuf 3.19.1 causes several Deprecation notices #9293

Closed
caugner opened this issue Dec 9, 2021 · 7 comments
Closed

PHP: protobuf 3.19.1 causes several Deprecation notices #9293

caugner opened this issue Dec 9, 2021 · 7 comments

Comments

@caugner
Copy link

caugner commented Dec 9, 2021

What version of protobuf and what language are you using?
Version: 3.19.1
Language: PHP

What operating system (Linux, Windows, ...) and version?

Docker 4.3.0 inside Ubuntu 20.04 LTS inside WSL2 on Windows 10

What runtime / compiler are you using (e.g., python version or gcc version)

# Dockerfile
FROM php:8.1-cli-alpine

RUN apk add --no-cache git && \
    curl -sSL -o /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
    chmod uga+x /usr/local/bin/install-php-extensions && \
    sync && \
    install-php-extensions protobuf && \
    rm /usr/local/bin/install-php-extensions

What did you do?
Steps to reproduce the behavior:

  1. Build the Dockerfile (docker build -t php-with-protobuf .)
  2. Run the built Docker image (docker run --rm -it php-with-protobuf)

What did you expect to see

$ docker build -t php-with-protobuf .
$ docker run --rm -it php-with-protobuf
Interactive shell

php >

What did you see instead?

$ docker build -t php-with-protobuf .
$ docker run --rm -it php-with-protobuf
Deprecated: Return type of Google\Protobuf\Internal\RepeatedField::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                 
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\RepeatedField::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                      
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\RepeatedField::offsetSet($index, $newval) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\RepeatedField::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                   
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\RepeatedField::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                         
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\RepeatedField::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                                                     
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\RepeatedFieldIter::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                                            
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\RepeatedFieldIter::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                                                   
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\RepeatedFieldIter::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                                                    
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\RepeatedFieldIter::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                                                 
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\RepeatedFieldIter::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                                               
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\MapField::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                      
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\MapField::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                           
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\MapField::offsetSet($index, $newval) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0     
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\MapField::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                        
                                                                                                                                                                                                                                                                                                          
Deprecated: Return type of Google\Protobuf\Internal\MapField::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                              
                                                                                                                                                                                                                                                                            
Deprecated: Return type of Google\Protobuf\Internal\MapField::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                            
                                                                                                                                                                                                                                                                            
Deprecated: Return type of Google\Protobuf\Internal\MapFieldIter::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                   
                                                                                                                                                                                                                                                                            
Deprecated: Return type of Google\Protobuf\Internal\MapFieldIter::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                          
                                                                                                                                                                                                                                                                            
Deprecated: Return type of Google\Protobuf\Internal\MapFieldIter::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0                           

Deprecated: Return type of Google\Protobuf\Internal\MapFieldIter::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0

Deprecated: Return type of Google\Protobuf\Internal\MapFieldIter::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0
Interactive shell

php >

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

(No.)

@elharo
Copy link
Contributor

elharo commented Dec 9, 2021

3.9.1 is from a couple of years ago. Do you see this with the latest 3.19.1?

@elharo elharo added the php label Dec 9, 2021
@caugner caugner changed the title PHP: protobuf 3.9.1 causes several Deprecation notices PHP: protobuf 3.19.1 causes several Deprecation notices Dec 9, 2021
@caugner
Copy link
Author

caugner commented Dec 9, 2021

@elharo Sorry, my bad, this happens indeed with 3.19.1:

$ docker run --rm -it php-protobuf php -i | grep -A 2 ^protobuf$
protobuf

Version => 3.19.1

@elharo elharo added the cleanup label Dec 9, 2021
oleg1540 added a commit to oleg1540/protobuf that referenced this issue Dec 13, 2021
oleg1540 added a commit to oleg1540/protobuf that referenced this issue Dec 15, 2021
@mlocati
Copy link
Contributor

mlocati commented Jan 11, 2022

This is still an issue with protobuf 3.19.2

@caugner
Copy link
Author

caugner commented Jan 11, 2022

FWIW There are two workarounds:

  1. In your php.ini, set error_reporting = E_ALL & ~E_DEPRECATED
  2. Prepend your CLI script with php -d 'error_reporting=24575'

I'm applying workaround 2 now, because the output of vendor/bin/php-cs-fixer fix --dry-run --format=gitlab > codeclimate.json cannot be parsed by GitLab due to the Deprecation notices (and redirecting stderr with 2> /dev/null did not help, because the deprecation notices are emitted via stdout).

@lanlin
Copy link

lanlin commented Jan 13, 2022

same issue on 3.19.3

@caugner
Copy link
Author

caugner commented Jan 14, 2022

I have linked some related PRs, of which #9359 seems to be the most promising PR with passing tests.

@haberman
Copy link
Member

haberman commented Feb 4, 2022

This should be fixed by #9370

@haberman haberman closed this as completed Feb 4, 2022
acozzette added a commit that referenced this issue Feb 11, 2022
* #9293 - fix Missing function's return type declaration (incompatible return type php 8.1)

* #9293 - remove return type void for compatible with php 7.0

* #9293 - add todo for mixed return type

Co-authored-by: Adam Cozzette <acozzette@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants