This is me being picky… but currently I have to use \ in front of all my classes…
//credit card expiration years and months
$expirationYears = array();
$expirationMonths = array();
$datePeriod = new \DatePeriod(new \DateTime(), new \DateInterval("P1Y"), 5);
foreach ($datePeriod as $year) {
$expirationYears[] = $year->format('Y');
}
$datePeriod = new \DatePeriod(new \DateTime('January 1st'), new \DateInterval("P1M"), 11);
foreach ($datePeriod as $month) {
$class = new \stdClass();
$class->value = $month->format('m');
$class->label = $month->format('M');
$expirationMonths[] = $class;
}
Is there a way around this or is that just something that’s required in a namespaced environment?
I consider it unreasonable to specify a use for each class… that’s too tedius to maintain
The
usekeyword is the exact right way to go. It’s not that much overhead.We use it big time in a project, and it’s not a big deal.
Using backslashes all the way through now that is tedious.
Also, it’s great to keep track of all classes you use in some files which may be a couple of thousands lines long. So you can go to the top and see what classes are in use (without using in-text search).