Skip to content

PHP7 return types incompatibile with generate code #6106

Closed
@mikeymike

Description

@mikeymike

Preconditions

  1. PHP 7.0.8 (any compatible PHP 7 release should be sufficient though)

Steps to reproduce

  1. Blank install
  2. Create a new block and add a method with a return type in PHP7 format e.g : string
  3. Use the block in some layout somewhere
  4. Hit the frontend to use the block

Expected result

  1. The page should load and the block code be executed correctly

Actual result

Instead you get a fatal error from PHP because the generated interceptor class doesn't have a return type at all.

PHP Fatal error:  Declaration of XX\YY\Block\CustomBlock\Interceptor::someMethod() must be compatible with XX\YY\Block\CustomBlock\::someMethod(): bool in .../var/generation/XX/YY/Block/CustomBlock/Interceptor.php on line X

This of course can be a tricky one to resolve purely based on the fact you wouldn't want to break BC with PHP 5.X.

The only resolutions I can think of at this point is...

  1. Check the version at runtime
  2. Set the PHP version (like we set the deploy mode)

Metadata

Metadata

Assignees

Labels

Issue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentbug report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions