[PSR-13] Type updates

62 views
Skip to first unread message

Larry Garfield

unread,
Dec 14, 2020, 11:57:34 AM12/14/20
to PHP-FIG
We previously attempted to upgrade a few PSRs to PHP 7, in stages per bylaw. However, we discovered through experimentation with PSR-13 and others that the upgrades would be a lot easier if we jumped straight to PHP 8, thanks to its more robust type support. (Specifically, string|\Stringable and return static.)

PHP 8 is now here, so let's get back to it.

Here are the re-upped PSR-13 PRs to add modern typing. This requires a 2/3 CC vote, I believe. Today begins the 2 week discussion period, although since that puts the vote starting smack in the middle of everyone's Christmas holiday I will likely not call the vote to start until early January. There is still the bikeshedding around whether these are 1.1/2.0 or 2.0/3.0, for which I do not have enough energy to really give a damn either way.

The vote would be to accept all 3 PRs and tag accordingly.

Step 1: https://github.com/php-fig/link/pull/6
Step 2: https://github.com/php-fig/link/pull/7
Spec: https://github.com/php-fig/fig-standards/pull/1199

--
Larry Garfield
la...@garfieldtech.com

Larry Garfield

unread,
Dec 14, 2020, 1:09:49 PM12/14/20
to PHP-FIG
I'm on a roll, so let's update PSR-6's types while we're at it. Same routine as for PSR-13, in 2 steps.

Of note, I am making this a 2.0/3.0 release rather than a 1.1/2.0 release due to the addition of a type hint for DateTimeInterface. That was the subject of a previous errata, and the type check gives a slightly different thrown error, so I consider that a large enough change to warrant a 2.0 tag for that one.

Otherwise these should also be uncontroversial.

Spec: https://github.com/php-fig/fig-standards/pull/1220
Step 1: https://github.com/php-fig/cache/pull/23
Step 2: https://github.com/php-fig/cache/pull/24

--
Larry Garfield
la...@garfieldtech.com

Jan Schneider

unread,
Dec 15, 2020, 11:45:45 AM12/15/20
to php...@googlegroups.com

Zitat von Larry Garfield <la...@garfieldtech.com>:

> We previously attempted to upgrade a few PSRs to PHP 7, in stages
> per bylaw. However, we discovered through experimentation with
> PSR-13 and others that the upgrades would be a lot easier if we
> jumped straight to PHP 8, thanks to its more robust type support.
> (Specifically, string|\Stringable and return static.)
>
> PHP 8 is now here, so let's get back to it.
>
> Here are the re-upped PSR-13 PRs to add modern typing. This
> requires a 2/3 CC vote, I believe. Today begins the 2 week
> discussion period, although since that puts the vote starting smack
> in the middle of everyone's Christmas holiday I will likely not call
> the vote to start until early January. There is still the
> bikeshedding around whether these are 1.1/2.0 or 2.0/3.0, for which
> I do not have enough energy to really give a damn either way.
>
> The vote would be to accept all 3 PRs and tag accordingly.
>
> Step 1: https://github.com/php-fig/link/pull/6

Why does only withHref() accept Stringable, and not the other methods
with string parameters?
--
Jan Schneider
The Horde Project
https://www.horde.org/

Larry Garfield

unread,
Dec 15, 2020, 12:10:50 PM12/15/20
to PHP-FIG
On Tue, Dec 15, 2020, at 10:45 AM, Jan Schneider wrote:
>
> Zitat von Larry Garfield <la...@garfieldtech.com>:
>
> > We previously attempted to upgrade a few PSRs to PHP 7, in stages
> > per bylaw. However, we discovered through experimentation with
> > PSR-13 and others that the upgrades would be a lot easier if we
> > jumped straight to PHP 8, thanks to its more robust type support.
> > (Specifically, string|\Stringable and return static.)
> >
> > PHP 8 is now here, so let's get back to it.
> >
> > Here are the re-upped PSR-13 PRs to add modern typing. This
> > requires a 2/3 CC vote, I believe. Today begins the 2 week
> > discussion period, although since that puts the vote starting smack
> > in the middle of everyone's Christmas holiday I will likely not call
> > the vote to start until early January. There is still the
> > bikeshedding around whether these are 1.1/2.0 or 2.0/3.0, for which
> > I do not have enough energy to really give a damn either way.
> >
> > The vote would be to accept all 3 PRs and tag accordingly.
> >
> > Step 1: https://github.com/php-fig/link/pull/6
>
> Why does only withHref() accept Stringable, and not the other methods
> with string parameters?

The docblock for that one specifically calls out that it allows an object, so disallowing Stringable would be an API change.

For the others (mainly relationships), they're not complex strings. They're by design trivial little labels, so there's no good reason anyone would be using a Stringable object there.

Cases like this are going to be a judgement call in each spec, which is what we concluded last year when we previously tried to add types. The above is my judgement call for this spec.

--Larry Garfield
Reply all
Reply to author
Forward
0 new messages