In my understanding, argument passed to a function/method are strictly mapped to your function call, and the arguments must be arranged in correct order to map what you pass in your function call.
e.g. function test(a,b){
return ....
}
$result = test(myValue1, myValue2);
But in magento2, when we override a class, we can inject more & more argument as we like , e.g.
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magestore\Bannerslider\Model\ResourceModel\Banner\CollectionFactory $bannerCollectionFactory,
array $data = []
) {
After override, one more argument is injected:
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magestore\Bannerslider\Model\ResourceModel\Banner\CollectionFactory $bannerCollectionFactory,
\Magestore\Bannerslider\Model\SliderFactory $sliderFactory,
SliderModel $slider,
array $data = []
) {
Why php could accept this changes? Couldn't it crash the method call as the number of arguments are not the same?