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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught InvalidArgumentException: $class cannot be empty #1730

Closed
iluuu1994 opened this issue Jun 3, 2019 · 6 comments
Closed

Uncaught InvalidArgumentException: $class cannot be empty #1730

iluuu1994 opened this issue Jun 3, 2019 · 6 comments

Comments

@iluuu1994
Copy link
Contributor

iluuu1994 commented Jun 3, 2019

Running psalm 3.4.0 on our beautiful legacy code base causes the following error:

$ psalm --no-cache --debug-by-line
Scanning 馃挬/vendor/phpoffice/phpexcel/Classes/PHPExcel/Chart/Axis.php
PHP Notice:  Uninitialized string offset: 0 in 馃挬/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/CommentAnalyzer.php on line 307

Notice: Uninitialized string offset: 0 in 馃挬/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/CommentAnalyzer.php on line 307
PHP Notice:  Uninitialized string offset: 0 in 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php on line 907

Notice: Uninitialized string offset: 0 in 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php on line 907
PHP Notice:  Uninitialized string offset: 0 in 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php on line 908

Notice: Uninitialized string offset: 0 in 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php on line 908
PHP Notice:  Uninitialized string offset: 0 in 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php on line 910

Notice: Uninitialized string offset: 0 in 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php on line 910
PHP Notice:  Uninitialized string offset: 0 in 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php on line 948

Notice: Uninitialized string offset: 0 in 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php on line 948
PHP Fatal error:  Uncaught InvalidArgumentException: $class cannot be empty in 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php:984
Stack trace:
#0 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php(966): Psalm\Type::getFQCLNFromString('', Object(Psalm\Aliases))
#1 馃挬/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(2367): Psalm\Type::fixUpLocalType('', Object(Psalm\Aliases), Array, Array)
#2 馃挬/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(2080): Psalm\Internal\Visitor\ReflectorVisitor->improveParamsFromDocblock(Object(Psalm\Storage\MethodStorage), Array, Object(PhpParser\Node\Stmt\ClassMethod), false)
#3 馃挬/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(256): Psalm\Internal\Visitor\ReflectorVisitor->registerFunctionLike(Object(PhpParser\Node\Stmt\ClassMethod))
#4 /Users/ilijatovilo/Developer/s in 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php on line 984

Fatal error: Uncaught InvalidArgumentException: $class cannot be empty in 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php:984
Stack trace:
#0 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php(966): Psalm\Type::getFQCLNFromString('', Object(Psalm\Aliases))
#1 馃挬/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(2367): Psalm\Type::fixUpLocalType('', Object(Psalm\Aliases), Array, Array)
#2 馃挬/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(2080): Psalm\Internal\Visitor\ReflectorVisitor->improveParamsFromDocblock(Object(Psalm\Storage\MethodStorage), Array, Object(PhpParser\Node\Stmt\ClassMethod), false)
#3 馃挬/vendor/vimeo/psalm/src/Psalm/Internal/Visitor/ReflectorVisitor.php(256): Psalm\Internal\Visitor\ReflectorVisitor->registerFunctionLike(Object(PhpParser\Node\Stmt\ClassMethod))
#4 /Users/ilijatovilo/Developer/s in 馃挬/vendor/vimeo/psalm/src/Psalm/Type.php on line 984

Not sure if phpoffice/phpexcel/Classes/PHPExcel/Chart/Axis.php just happens to be the last file or if the issue is caused by that file.

3.3.2 works fine.

@weirdan
Copy link
Collaborator

weirdan commented Jun 3, 2019

What version of phpexcel is that? 1.8.0 (that's probably older than you have) doesn't cause a crash here.

@iluuu1994
Copy link
Contributor Author

It's PHPExcel 1.8.2. Fixing it to 1.8.0 really does solve the problem.

@weirdan
Copy link
Collaborator

weirdan commented Jun 3, 2019

Looks like this:

/**
 * @param * $reference
 */

could be the culprit. Reproduced on psalm.dev: https://psalm.dev/r/989785059b

@muglug muglug closed this as completed in 20422cf Jun 3, 2019
@muglug
Copy link
Collaborator

muglug commented Jun 3, 2019

@iluuu1994 does the fix work for you?

@iluuu1994
Copy link
Contributor Author

iluuu1994 commented Jun 3, 2019

Yes! Thanks @muglug and @weirdan!

@XedinUnknown
Copy link
Contributor

Same thing, with this file

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

4 participants