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

AuthenticationController::$container must not be defined #178

Closed
4 tasks done
mkilmanas opened this issue Dec 20, 2023 · 1 comment
Closed
4 tasks done

AuthenticationController::$container must not be defined #178

mkilmanas opened this issue Dec 20, 2023 · 1 comment

Comments

@mkilmanas
Copy link
Contributor

Checklist

  • I have looked into the Readme and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

When updating to 5.2.2 composer throws this error during Symfony cache:clear step:

 [KO]
Script cache:clear returned with error code 255
!!
!!  Fatal error: Type of Auth0\Symfony\Controllers\AuthenticationController::$container must not be defined (as in class Symfony\Bundle\FrameworkBundle\Controller\AbstractController) in /xyz/vendor/auth0/symfony/src/Controllers/AuthenticationController.php on line 20
!!  PHP Fatal error:  Type of Auth0\Symfony\Controllers\AuthenticationController::$container must not be defined (as in class Symfony\Bundle\FrameworkBundle\Controller\AbstractController) in /xyz/vendor/auth0/symfony/src/Controllers/AuthenticationController.php on line 20
!!  Symfony\Component\ErrorHandler\Error\FatalError {#3008
!!    #message: "Compile Error: Type of Auth0\Symfony\Controllers\AuthenticationController::$container must not be defined (as in class Symfony\Bundle\FrameworkBundle\Controller\AbstractController)"
!!    #code: 0
!!    #file: "./vendor/auth0/symfony/src/Controllers/AuthenticationController.php"
!!    #line: 20
!!    -error: array:4 [
!!      "type" => 64
!!      "message" => "Type of Auth0\Symfony\Controllers\AuthenticationController::$container must not be defined (as in class Symfony\Bundle\FrameworkBundle\Controller\AbstractController)"
!!      "file" => "/xyz/vendor/auth0/symfony/src/Controllers/AuthenticationController.php"
!!      "line" => 20
!!    ]
!!  }
!!
Script @auto-scripts was called via post-update-cmd

I presume it refers to this declaration of the property here vs [the property already declared by the parent class without the type restriction].(https://github.com/symfony/symfony/blob/6.4/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php#L58-L61)
Type restriction was actually introduced in Symfony 7.0, so I suspect this was an attempt at upgrading/making-compatible.

I would suggest removing the protected keyword and using the setter method provided - that way it will be compatible both with 6.x and 7.x.

E.g.

    public function __construct(
        private Authenticator $authenticator,
        private RouterInterface $router,
       ContainerInterface $container,
    ) {
        $this->setContainer($container);
    }

Reproduction

  1. Install this bundle into a symfony project
  2. use composer update to upgrade this bundle to v5.2.2

Additional context

No response

jwt-auth-bundle version

5.2.2

Symfony version

6.4.1

PHP version

8.2

evansims pushed a commit that referenced this issue Dec 20, 2023
…atibility issues (#179)

### Changes

Please describe both what is changing and why this is important.
Include:

- Removing scope keyword from constructor parameter to avoid property
re-declaration
- In turn that allows compatibility with both symfony version 6.x and
7.x
- Using given setter to achieve the same desired result

### References

[#178]

### Testing

Previously Symfony (6.4) app container building (cache:clear) was
throwing a fatal error, now it's not.

- [ ] This change adds test coverage

- [x] This change has been tested on the latest version of Symfony

### Checklist

- [x] I have read the [Auth0 general contribution
guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)

- [x] I have read the [Auth0 Code of
Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)

- [ ] All existing and new tests complete without errors
@evansims
Copy link
Member

Resolved by #179

evansims pushed a commit that referenced this issue Jan 4, 2024
### Changes

Fix syntax typo in the previous code change in
`AuthenticationController::__construct()`

### References

#178
#179
https://github.com/auth0/symfony/actions/runs/7279226624/job/19835136156
https://github.com/auth0/symfony/actions/runs/7279226624/job/19835137264

### Testing

[ ] This change adds test coverage

[ ] This change has been tested on the latest version of Symfony

### Checklist

[x] I have read the [Auth0 general contribution
guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)

[x] I have read the [Auth0 Code of
Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)

[ ] All existing and new tests complete without errors
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

2 participants