Skip to content

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

@garak

Description

@garak

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

Activity

Ocramius

Ocramius commented on Jul 12, 2019

@Ocramius
Member

Ref:

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

added this to the v1.7.0 milestone on Jul 12, 2019
added a commit that references this issue on Jul 15, 2019
rbairwell

rbairwell commented on Jul 31, 2019

@rbairwell

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

Tobion commented on Aug 6, 2019

@Tobion
Contributor

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

modified the milestones: v1.7.0, v1.7.1 on Aug 8, 2019

12 remaining items

javiyt

javiyt commented on Oct 15, 2020

@javiyt

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

SuperlativeEntity commented on Oct 19, 2020

@SuperlativeEntity

@javiyt Did you resolve the issue?

javiyt

javiyt commented on Oct 19, 2020

@javiyt

No

SuperlativeEntity

SuperlativeEntity commented on Oct 20, 2020

@SuperlativeEntity

Might be easier to just log a separate issue.

grrenier

grrenier commented on Oct 22, 2020

@grrenier

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

SuperlativeEntity commented on Nov 10, 2020

@SuperlativeEntity

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

Ocramius

Ocramius commented on Nov 10, 2020

@Ocramius
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

wiistriker commented on Feb 16, 2021

@wiistriker

still error on php 7.4

ma-gu-16

ma-gu-16 commented on Mar 3, 2021

@ma-gu-16

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

thewasta

thewasta commented on Jun 15, 2021

@thewasta

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

Ocramius commented on Jun 15, 2021

@Ocramius
Member

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

locked as resolved and limited conversation to collaborators on Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @javiyt@Ocramius@garak@glensc@alcaeus

      Issue actions

        Trying to access array offset on value of type null · Issue #273 · doctrine/annotations