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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing the file [...StateProvider.tpl.php] resulted in an error: Syntax error, unexpected T_NAMESPACE on line 5 #555

Closed
kochen opened this issue Nov 26, 2024 · 5 comments
Assignees

Comments

@kochen
Copy link

kochen commented Nov 26, 2024

Cross referencing from: api-platform/core#6826

{
    "name": "api-platform/issue-2805",
    "type": "project",
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "require-dev": {
        "maglnet/composer-require-checker": "^4.14"
    },
    "require": {
        "api-platform/core": "4.0.10"
    }
}
$ vendor/bin/composer-require-checker
ComposerRequireChecker 4.14.0@b6d5acd89d0de1727c1188157fa99552c39d1dfb
In LocateASTFromFiles.php line 41:
                                                                               
  Parsing the file [.../vendor/api-platform/core/src/Laravel/Console/Maker/Resources/skeleton/StateProvider.tpl.php] resulted in   
  an error: Syntax error, unexpected T_NAMESPACE on line 5                     
                                                                               
In ParserAbstract.php line 321:
                                                  
  Syntax error, unexpected T_NAMESPACE on line 5  
                                                  
check [--config-file CONFIG-FILE] [--ignore-parse-errors] [--output OUTPUT] [--] [<composer-json>]

Is there a way to resolve this from the checker side?

M.

@kochen
Copy link
Author

kochen commented Nov 26, 2024

The file in question is a simple template file:

<?php

declare(strict_types=1);

namespace {{ namespace }};

use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;

final class {{ class_name }} implements ProviderInterface
{
    public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
    {
        // Retrieve the state from somewhere
    }
}

@Ocramius
Copy link
Collaborator

That's indeed not valid PHP, and it shouldn't be part of autoloaded sources, TBH.

It will also trip tools like php -l (in upstream PHP), so I think this sort of problem should be handled downstream, in the library that declares it as .php (make it .php.tpl instead of .tpl.php? )

@Ocramius
Copy link
Collaborator

Also, hi, long time no see! 👋

@kochen
Copy link
Author

kochen commented Nov 26, 2024

That's indeed not valid PHP, and it shouldn't be part of autoloaded sources, TBH.

It will also trip tools like php -l (in upstream PHP), so I think this sort of problem should be handled downstream, in the library that declares it as .php (make it .php.tpl instead of .tpl.php? )

This was already reported downstream, just added it here for completeness.
Weird enough, the companion template in the same directory doesn't result in a Syntax error - but it could be a race condition and this one just failed first.

@kochen
Copy link
Author

kochen commented Nov 26, 2024

Also, hi, long time no see! 👋

indeed long! 👋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants