container icon indicating copy to clipboard operation
container copied to clipboard

Handle preceeding slash in class name handling

Open M1ke opened this issue 3 years ago • 0 comments

Resolves https://github.com/thephpleague/container/issues/237

To summarise that issue:

  • PHP class names may be valid in both the format Foo\Bar and also as \Foo\Bar when used as a string
  • Using Foo::class returns Foo\Bar but legitimate user code may handle as \Foo\Bar and this would work for class_exists or new $var cases
  • Because of this, a concrete class may be set with one form of slash, and got with the other. This means the set definition is not used.
  • This fix adds test for both ways round that this issue could occur, and implements the class name normalizing in each appropriate place

This aims to be backwards compatible and causes no test failures.

M1ke avatar Feb 01 '22 11:02 M1ke