Skip to content

Discussion: PHP modernization — type hints and minimum PHP version #79

@apermo

Description

@apermo

Hey Torsten,

I was looking into your plugin and considered adding some features to go along with my new https://github.com/apermo/site-bookkeeper-reporter.

Where we are

The plugin currently targets PHP 5.6. No methods have parameter types or return types. phpstan.neon exists, so there's already some interest in static analysis, but without type hints phpstan can only do so much.

The thing is

If we bump the PHP requirement and release that as, say, v2.3 or v3.0 — users on older PHP versions won't get a compatible fallback. WordPress.org always serves the latest version. So a user on PHP 7.2 would see "Update available" in their dashboard but can't actually install it. They'd be stuck on v2.2.2 forever, including missing any future security fixes.

That's the main trade-off here.

Options

  1. Keep PHP 5.6 — no type hints possible, but maximum compatibility
  2. Bump to 7.4 — typed properties, arrow functions, covariant return types

WordPress itself requires PHP 7.2.24+ since WP 6.3.

What are your thoughts on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions