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

karschsp’s picture

Assigned: Unassigned » karschsp
tstoeckler’s picture

I find arrays to be much more readable than writing out objects.
I don't see why we should do this.

karschsp’s picture

Anyone else want to weigh in on this? I'm about 3/4s through a patch.

sun’s picture

Status: Active » Closed (won't fix)

There'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.