09.
AbstractShipStorage
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
10 Comments
Reminder :
Pay attention to the order of "require" in bootstrap.php.
AbstractShipStorage must be included before PdoShipStorage and JsonFileShipStorage.
You're 100% right :). And isn't that annoying? You'll love episode 4 where we show how this is solved with "autoload" ;) https://symfonycasts.com/sc...
Cheers!
Hi,
After the AbstractShipStorage i get the following error
"Argument 1 in de __constuct() must be an instance of AbstractShopStorage, array given, called in index.php on line 6"
In my index.php it's the following line:
"$container = new Container($configuration);"
So i don't quite get why i have this error.
Kind regards,
Emin
UPDATE
I accedently put in mu __construct AbstractShipStorage instead array so once i replaced those it works :)
Hey Emin,
Glad you had got it working before we replied to you! That's why typehinting is great, it helps to discover the problem earlier. :)
Cheers!
Hey,
Since we're creating an AbstractShipStorage class, shouldn't the title of this video be: AbstractShipStorage?
Kind regards,
Ben
Hey Ben,
Yes, you're totally right! I fixed it in https://github.com/knpunive... - thanks for letting us know!
Cheers!
Why can't I make the concrete function getRadius() in AbstractPlanet like:
SolidPlanet uses it just happily as-is.
GasPlanet stores radius as the property (rather than uselessly storing diameter - which seemed just to be different):
But the exercise tells me that getRadius() must be declared abstract in AbstractPlanet. I thought that it was perfectly fine to have some concrete methods in an abstract class??
That would happen when there is a method body that applies appropriately to all (or most) subclasses that extend the abstract class.
Hey Phil,
Yeah, good question! Actually, you totally can do it on practice. The error you see is not a PHP internal one, just a user error triggered by our validation system - we just do not cover all possible cases. In this challenge we suppose do not change the current implementation much. Let's say, for simplicity, we need to store diameter for GasPlanet and radius for SolidPlaned, i.e. we want to keep current implementation, just make common methods abstract and extend the AbstractPlanet class. Anyway, you just overthought this challenge a bit, our tasks were much easier. But it's good you think about it, great job!
Cheers!
Thanks - good to know it is what I thought, not an actual PHP error but just a bit of a course code sanity check.
"Houston: no signs of life"
Start the conversation!