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

Trying to access array offset on value of type null #273

Closed
garak opened this issue Jul 12, 2019 · 19 comments
Closed

Trying to access array offset on value of type null #273

garak opened this issue Jul 12, 2019 · 19 comments
Labels
Milestone

Comments

@garak
Copy link

garak commented Jul 12, 2019

This stopped working on php 7.4, for example on DocParser class
See https://twitter.com/nikita_ppv/status/1148931277216800769 for a reference

@Ocramius
Copy link
Member

Ref:

while ($this->lexer->lookahead['position'] === ($this->lexer->token['position'] + strlen($this->lexer->token['value']))

@Ocramius Ocramius added the bug label Jul 12, 2019
@Ocramius Ocramius added this to the v1.7.0 milestone Jul 12, 2019
garak added a commit to dustin10/VichUploaderBundle that referenced this issue Jul 15, 2019
@rbairwell
Copy link

If it helps, the following seems to fix the problem:
while ($this->lexer->lookahead!==null && $this->lexer->lookahead['position'] === ($this->lexer->token['position'] + strlen($this->lexer->token['value']))

@Tobion
Copy link
Contributor

Tobion commented Aug 6, 2019

Symfony also has alot of failures in php 7.4 due to this, ref. symfony/symfony#32844

@davidbyoung
Copy link

Will the fix be merged into master in the near future? I'm testing 2.0 on PHP 7.4-beta4, and am blocked. Thanks!

@glensc
Copy link

glensc commented Sep 1, 2019

RFC that implemented the breakage: https://wiki.php.net/rfc/notice-for-non-valid-array-container

@SuperlativeEntity
Copy link

Does this still seem to be broken?

ErrorException : Trying to access array offset on value of type null
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php:995

while ($this->lexer->lookahead['position'] === ($this->lexer->token['position'] + strlen($this->lexer->token['value']))

@alcaeus
Copy link
Member

alcaeus commented Feb 25, 2020

@SuperlativeEntity what version are you running? This has been fixed in 1.7.0.

@SuperlativeEntity
Copy link

Okay, my mistake, I have the wrong version. Thanks for your time.

@javiyt
Copy link

javiyt commented Oct 15, 2020

I'm using version 1.10.2 and it's failing in other line:

[ErrorException]
 Trying to access array offset on value of type null
in /code/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php:1047

@SuperlativeEntity
Copy link

@javiyt Did you resolve the issue?

@javiyt
Copy link

javiyt commented Oct 19, 2020

No

@SuperlativeEntity
Copy link

Might be easier to just log a separate issue.

@grrenier
Copy link

Does this still seem to be broken?

ErrorException : Trying to access array offset on value of type null
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php:995

while ($this->lexer->lookahead['position'] === ($this->lexer->token['position'] + strlen($this->lexer->token['value']))

This fixed the issue in my case:

while (isset($this->lexer->lookahead['position']) && $this->lexer->lookahead['position'] === ($this->lexer->token['position'] + strlen($this->lexer->token['value']))

@SuperlativeEntity
Copy link

We can't just edit the vendor files, it needs to be fixed in the package.

@Ocramius
Copy link
Member

Hey folks: posting here won't help.

Please raise a new issue with associated failing test case, so it can be solved there.

@wiistriker
Copy link

still error on php 7.4

@ma-gu-16
Copy link

ma-gu-16 commented Mar 3, 2021

Confirm, still error on PHP 7.4 and current symfony flex doctrine/orm v 2.7.5

mhujer added a commit to mhujer/consistence-doctrine that referenced this issue Mar 5, 2021
@thewasta
Copy link

Anyone hava a solution?
I'm following this guide AKENEO DOCS and when I run php app/console cache:clear --env=prod got the error

Clearing the cache for the prod environment with debug false
PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /root/pim-community-standard/vendor/symfony/monolog-bundle/DependencyInjection/Configuration.php on line 594
PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /root/pim-community-standard/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 2635
PHP Notice:  Trying to access array offset on value of type null in /root/pim-community-standard/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php on line 967
PHP Notice:  Trying to access array offset on value of type null in /root/pim-community-standard/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php on line 967
PHP Notice:  Trying to access array offset on value of type null in /root/pim-community-standard/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php on line 967
PHP Notice:  Trying to access array offset on value of type null in /root/pim-community-standard/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php on line 967
PHP Notice:  Trying to access array offset on value of type null in /root/pim-community-standard/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php on line 967
PHP Notice:  Trying to access array offset on value of type null in /root/pim-community-standard/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php on line 967
PHP Notice:  Trying to access array offset on value of type null in /root/pim-community-standard/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php on line 967
PHP Notice:  Trying to access array offset on value of type null in /root/pim-community-standard/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php on line 967
PHP Notice:  Trying to access array offset on value of type null in /root/pim-community-standard/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php on line 967
PHP Notice:  Trying to access array offset on value of type null in /root/pim-community-standard/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php on line 967
PHP Notice:  Trying to access array offset on value of type null in /root/pim-community-standard/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php on line 967
PHP Fatal error:  Declaration of Pim\Bundle\CatalogBundle\Doctrine\ORM\Repository\LocaleRepository::findBy(array $criteria, array $orderBy = Array, $limit = NULL, $offset = NULL) must be compatible with Doctrine\ORM\EntityRepository::findBy(array $criteria, ?array $orderBy = NULL, $limit = NULL, $offset = NULL) in /root/pim-community-standard/vendor/akeneo/pim-community-dev/src/Pim/Bundle/CatalogBundle/Doctrine/ORM/Repository/LocaleRepository.php on line 23
[2021-06-15 16:00:07] php.CRITICAL: Fatal Compile Error: Declaration of Pim\Bundle\CatalogBundle\Doctrine\ORM\Repository\LocaleRepository::findBy(array $criteria, array $orderBy = Array, $limit = NULL, $offset = NULL) must be compatible with Doctrine\ORM\EntityRepository::findBy(array $criteria, ?array $orderBy = NULL, $limit = NULL, $offset = NULL) {"type":64,"file":"/root/pim-community-standard/vendor/akeneo/pim-community-dev/src/Pim/Bundle/CatalogBundle/Doctrine/ORM/Repository/LocaleRepository.php","line":23,"level":6143,"stack":[]} []


                                                                                                                                                                                                                  
  [Symfony\Component\Debug\Exception\FatalErrorException]                                                                                                                                                         
  Compile Error: Declaration of Pim\Bundle\CatalogBundle\Doctrine\ORM\Repository\LocaleRepository::findBy(array $criteria, array $orderBy = Array, $limit = NULL, $offset = NULL) must be compatible with Doctri  
  ne\ORM\EntityRepository::findBy(array $criteria, ?array $orderBy = NULL, $limit = NULL, $offset = NULL)                                                                                                         
                                                                                                                                                                                                                  


cache:clear [--no-warmup] [--no-optional-warmers]

Current PHP version is 7.4, should I downgrade to 7.3 or upgrade to 8?

@Ocramius
Copy link
Member

@thewasta please report it to akeneo/pim-community-dev - it has nothing to do with doctrine/annotations.

@doctrine doctrine locked as resolved and limited conversation to collaborators Jun 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.