yiisoft / yii2-apidoc

Yii 2 apidoc extension.
https://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
258 stars 121 forks source link

Error: Syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM on line 220 #205

Closed neoacevedo closed 2 years ago

neoacevedo commented 3 years ago

What steps will reproduce the problem?

Run the command vendor/bin/apidoc api /the/source/path /the/target/path --page-title="API Documentation"

What's expected?

Non syntax error

What do you get instead?

Error: Syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM on line 220 The API Doc is generated although not all the files are being scanned.

Additional info

Q A
Yii vesion 2.0.38
Yii APIDoc version
PHP version 7.4.12
Operating system openSUSE Tumbleweed

And, I dnon't know if it comes inside this issue or if it should be posted in a new one, but yii2-apidoc isn't rendering all the files inside the input directory, and also, in the errors.txt file, I find a lot of Method tableName|attributeLabels|behaviors has no parent to inherit from in namespace\models\ModelFile. when I use inheritdoc.

samdark commented 3 years ago

Would you please post some files that generate the error?

neoacevedo commented 3 years ago

For the error T_PAAMAYIM_NEKUDOTAYIMI, I can't get which files are issuing it. It's showed just after start processing files. The source files are inside vendor directory from my project. I can't put the source code because it's a private project.

samdark commented 3 years ago

You can divide by 2, I guess. Put vendor elsewhere, delete half of the files, try it. If there's an error, delete another half etc. This way you may be able to find which file causes it. Then it will become fixable.

neoacevedo commented 3 years ago

I have found one of the lines, but I'm cuorious because the parsing error. Processing files... 77% (17/22) ETA: n/a Parse Error: Syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM on line 411

...
if (($model = $this->modelClass::findOne(['id' => $id, 'auth_key' => $authKey])) !== null) {
...

Additional to it, I get (for the same file):

[0] => Unable to process "/path/to/Controller.php": The given file could not be interpreted as it contains errors: Errors parsing /path/to/Controller.php

But I don't have a clue which error is referred to.

bizley commented 3 years ago

This is about ::. You cannot use $this->modelClass as a static call. Assign it to variable first.

neoacevedo commented 3 years ago

I replaced $this->modelClass:: with User:: and the error on line 411 has dissapeared, but the proccess error for the files is still preesent.

UPDATE: I have finally solved the parse error, loggin apidoc in php cli log, a duplicated use statement was the blame. Now, Method tableName|attributeLabels|behaviors has no parent to inherit from in namespace\models\ModelFile. is still present. I think this last one can go inside the issue https://github.com/yiisoft/yii2-apidoc/issues/194

arogachev commented 2 years ago

As for uniform variable syntax, it looks like a duplicate of #148, it's already fixed in #220. As for issue #194, hopefully I'll take a look at it too. Closing this, feel free to reopen with a snippet for reproducing the problem (if it differs from #194).