<?php
function iLike($programming): string
{
return str_repeat($programming, 10);
}
@benjaminhollon Yes, you can. And not just that, you can type hint your function parameters too, and class properties and methods: https://www.phptutorial.net/php-tutorial/php-type-hints/ Type hints are extremely useful (meaning: necessary) if you use service containers, as in Laravel: https://laravel.com/docs/10.x/container
Of course you can still use PHP as a full dynamic lang and let it do automatic type casting/juggling, but a "stronger" typing using type hints may seem generally like a good idea I think. :)
@benjaminhollon BTW, another advantage of explicit types is that you can document them in your PHPDoc blocks (actually, if you use an IDE it typically will do this for you ;) ). If you write an API and need to generate documentation for it, this can be pretty convenient. :)
Another question is that this and plenty other improvements have been gradually added to PHP, and lots of people who haven't used it in a while still don't know, so they have a distorted image at times. :P
@array
"PHPDoc", you say? I *definitely* know what that is. XD
(I think when I last used PHP I was using version 5.something; PHP 7 was out but I don't think my host had it)