zend-code icon indicating copy to clipboard operation
zend-code copied to clipboard

v3 only: Unknown Notices from ClassScanner

Open aight8 opened this issue 9 years ago • 2 comments

Notice: Undefined offset: 585 in /var/www/.../current/vendor/zendframework/zend-code/src/Scanner/ClassScanner.php on line 939

Notice: Uninitialized string offset: 1 in /var/www/.../current/vendor/zendframework/zend-code/src/Scanner/ClassScanner.php on line 971

Notice: Uninitialized string offset: 1 in /var/www/.../current/vendor/zendframework/zend-code/src/Scanner/ClassScanner.php on line 971

Notice: Uninitialized string offset: 1 in /var/www/.../current/vendor/zendframework/zend-code/src/Scanner/ClassScanner.php on line 971

Notice: Undefined offset: 267 in /var/www/.../current/vendor/zendframework/zend-code/src/Scanner/ClassScanner.php on line 939

BTW: I just added a new directory to scan via the great zend annotation module but it fails with a fatal exception in the ClassScanner. Is it possible to add more accurate error messages which make it simple to locate the file?

edit:

  • Error when folder contains empty file.
  • Notice:
Notice: Uninitialized string offset: 1 in /var/www/.../current/vendor/zendframework/zend-code/src/Scanner/TokenArrayScanner.php on line 582 Notice: Uninitialized string offset: 1 in /var/www/.../current/vendor/zendframework/zend-code/src/Scanner/TokenArrayScanner.php on line 582

when you have a php config file with ::class syntax:

<?php

return [
    'xxxx' => [
        'zzzz' => [
            'source_class' => \Test\Bla::class
        ]
    ]
];

aight8 avatar Jun 22 '16 12:06 aight8

@aight8, @weierophinney, this issue is when the scanner scans plain php file with "::class" token. for example:

<?php

use App\Controller\ErrorController;

return [
    'controllers' => [
        'invokables' => [
            ErrorController::class => ErrorController::class,
        ],
        'aliases' => [
            'ErrorController' => ErrorController::class
        ]
    ],
    'zf_annotation' => [
        'scan_modules' => ['App'],
    ],
];

will fail as it recognizes "::class" as "class Name". as a temporary solution, do not use that and change your code to, eg.:

<?php

return [
    'controllers' => [
        'invokables' => [
            'App\Controller\ErrorController' => 'App\Controller\ErrorController',
        ],
        'aliases' => [
            'ErrorController' => 'App\Controller\ErrorController'
        ]
    ],
    'zf_annotation' => [
        'scan_modules' => ['App'],
    ],
];

image

image

alex-oleshkevich avatar Aug 15 '16 10:08 alex-oleshkevich

This repository has been closed and moved to laminas/laminas-code; a new issue has been opened at https://github.com/laminas/laminas-code/issues/26.

weierophinney avatar Dec 31 '19 21:12 weierophinney