Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
PHP
/
Object-oriented programming
Why would Checkout accept a ShippingPolicy interface in its constructor?
from Object-oriented programming
PHP 8.3.33
intermediate
1 min
Why would Checkout accept a ShippingPolicy interface in its constructor?
So callers can select an implementation without Checkout depending on its concrete class.
So PHP recursively validates every value held by the implementation.
So the implementation may ignore the interface return type.
So Checkout can inherit from several shipping classes.
Check
Ask AI about this kata
Report an error
previous kata
What does constructor property promotion guarantee by itself?
Quiz
next kata
What does this program print?
Predict the output
A new version is available
Reload