<?php

namespace GeoIP2\Record;

abstract class AbstractPlaceRecord extends AbstractRecord
{
  private $languages;

  public function __construct($record, $languages){
    $this->languages = $languages;
    parent::__construct($record);
  }

  public function __get($attr) {
    if ($attr == 'name') {
      return $this->name();
    } else {
      return parent::__get($attr);
    }
  }


  private function name() {
    foreach($this->languages as $language) {
      if (isset($this->names[$language])) return $this->names[$language];
    }
  }
}
<?php

namespace GeoIP2\Record;

abstract class AbstractPlaceRecord extends AbstractRecord
{
  private $languages;

  public function __construct($record, $languages){
    $this->languages = $languages;
    parent::__construct($record);
  }

  public function name() {
    foreach($this->languages as $language) {
      if (isset($this->names[$language])) return $this->names[$language];
    }
  }
}
--- 
+++ 
@@ -11,7 +11,16 @@
     parent::__construct($record);
   }
 
-  public function name() {
+  public function __get($attr) {
+    if ($attr == 'name') {
+      return $this->name();
+    } else {
+      return parent::__get($attr);
+    }
+  }
+
+
+  private function name() {
     foreach($this->languages as $language) {
       if (isset($this->names[$language])) return $this->names[$language];
     }
Make 'name' a property rather than a function
