| 1 | <?php |
||
| 8 | class CspServiceProvider extends ServiceProvider |
||
| 9 | { |
||
| 10 | public function boot() |
||
| 11 | { |
||
| 12 | if ($this->app->runningInConsole() && function_exists('config_path')) { |
||
| 13 | $this->publishes([ |
||
| 14 | __DIR__.'/../config/csp.php' => config_path('csp.php'), |
||
| 15 | ], 'config'); |
||
| 16 | } |
||
| 17 | |||
| 18 | $this->app->singleton(NonceGenerator::class, config('csp.nonce_generator')); |
||
| 19 | |||
| 20 | $this->app->singleton('csp-nonce', function () { |
||
| 21 | return app(NonceGenerator::class)->generate(); |
||
| 22 | }); |
||
| 23 | |||
| 24 | $this->app->view->getEngineResolver()->resolve('blade')->getCompiler()->directive('nonce', function () { |
||
|
|
|||
| 25 | return '<?php echo "nonce=\"" . csp_nonce() . "\""; ?>'; |
||
| 26 | }); |
||
| 27 | } |
||
| 28 | |||
| 29 | public function register() |
||
| 33 | } |
||
| 34 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: