Closed (won't fix)
Project:
Drupal core
Version:
8.0.x-dev
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
28 Jul 2011 at 15:12 UTC
Updated:
29 Jul 2014 at 19:49 UTC
All over the core we have short notation to assign objects from array conversion. @webchick suggesting to fix this.
+++ modules/simpletest/drupal_web_test_case.php 1 Sep 2010 10:11:48 -0000
@@ -1155,6 +1155,9 @@
+ $language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');
Let's write this out long-hand like:
$language = new stdClass;
$language->language = 'en';
$language->native = 'English';
....
Comming from #276153-41: Testing does not work at all when locale of host session is not English
Comments
Comment #1
karschsp commentedComment #2
tstoecklerI find arrays to be much more readable than writing out objects.
I don't see why we should do this.
Comment #3
karschsp commentedAnyone else want to weigh in on this? I'm about 3/4s through a patch.
Comment #4
sunThere's no way we can or should standardize this; doesn't make sense. Whenever array to object casting works and makes sense, we can use it. Primarily doesn't work when actual classes other than stdClass are involved.