Re: Versioned Packagers (Iteration IV)

From: Date: Fri, 05 Jul 2024 18:22:58 +0000
Subject: Re: Versioned Packagers (Iteration IV)
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Jul 3, 2024, at 17:16, Michael Morris <[email protected]> wrote:
> Can PHP support multiple packages without rewriting the whole engine?  I think so, but it
> isn't trivial, and the side effects need to be cordoned off so that those who need this
> complexity can have it while the beginning and intermediate coders can ignore it just like they
> ignore strict comparison operators and strict typing unless a library they are trying to use foists
> it on them.

I think that focusing on the syntax and tooling for executing these imports is starting at the wrong
end of this problem. The bulk of the work for this feature is going to be whatever engine changes
are required to support versioning, not the tooling around it.

To that end - consider the following. Let's say that two different files in your project import
different versions of package Foo. Foo contains a definition of the FooBar class, and contains
functions which return that object.

1) If $foobar is one of those FooBar objects, what does $foobar::class return? Is it the same as the
fully qualified name of FooBar (e.g. "Foo\FooBar")? Does the result differ depending on
what file contains that code?

2) What happens if you try to pass that string back to something like new $class() or construct a
ReflectionClass for it? Does that depend on the location of the call? What if the call is through
something like PDO::FETCH_CLASS which occurs within the runtime?

3) Within Foo, would it be true that if $x = new FooBar(), then $x::class === FooBar::class? Does
this differ outside Foo (with an appropriately qualified name for FooBar)?

4) If those two files both create FooBar objects of their respective versions, what happens if you
try to pass one of those objects to a function in the file using the "wrong" version of
Foo? Does it pass type checks, and what happens if it does? If not, how does the check fail?

5) What shows up in the output of functions like get_declared_classes()? Are there multiple
instances of FooBar in there for each version? How are they distinguished from one another?


Thread (128 messages)

« previous php.internals (#124233) next »