Closed thinkjson closed 10 years ago
Could you post the offending annotation?
The following code:
<?php
require('../vendor/autoload.php');
use Swagger\Swagger;
use Swagger\Annotations as SWG;
/**
* @SWG\Resource(resourcePath="/")
*/
/**
* This is a test
*
* @SWG\Api(
* path="/docstest.php",
* description="Send a test response",
* @SWG\Operations(
* @SWG\Operation(
* method="GET", summary="Gets a test response"
* )
* )
* )
*
*/
class DocsTest {
public function test() {
$cls = Swagger::class;
$swagger = new Swagger(dirname(__FILE__), []);
$apiJson = $swagger->getResourceList();
print json_encode($apiJson);
}
}
error_reporting(E_ALL);
$test = new DocsTest();
$test->test();
produces the following notice:
"PHP message: PHP Notice: Uninitialized string offset: 1 in /.../vendor/zircote/swagger-php/library/Swagger/Parser.php on line 260
PHP message: PHP Stack trace:
PHP message: PHP 1. {main}() /.../public/docstest.php:0
PHP message: PHP 2. DocsTest->test() /.../public/docstest.php:37
PHP message: PHP 3. Swagger\Swagger->__construct() /.../public/docstest.php:29
PHP message: PHP 4. Swagger\Swagger->scan() /.../vendor/zircote/swagger-php/library/Swagger/Swagger.php:65
PHP message: PHP 5. Swagger\Parser->__construct() /.../vendor/zircote/swagger-php/library/Swagger/Swagger.php:209
PHP message: PHP 6. Swagger\Parser->parseFile() /.../vendor/zircote/swagger-php/library/Swagger/Parser.php:97
PHP message: PHP 7. Swagger\Parser->parseTokens() /.../vendor/zircote/swagger-php/library/Swagger/Parser.php:207
Removing the class resolver removes the notice.
Fixed in 0.9.2 by @alkev
Looks good. Thanks!
Using SomeClass::class to get the fully resolved class name causes a parse error when constructing a Swagger instance:
Hard-coding the fully namespaced class name causes the error to go away.