{"record":{"id":"1623cba53dd7b4a0","repo":"briannesbitt/Carbon","slug":"name","errorCode":null,"errorMessage":"$name","messagePattern":"\\$name","errorType":"exception","errorClass":"UnknownGetterException","httpStatus":null,"severity":"error","filePath":"src/Carbon/CarbonPeriod.php","lineNumber":895,"sourceCode":"        };\n    }\n\n    /**\n     * Get a property allowing both `DatePeriod` snakeCase and camelCase names.\n     *\n     * @param string $name\n     *\n     * @return bool|CarbonInterface|CarbonInterval|int|null\n     */\n    public function get(string $name)\n    {\n        $getter = $this->getGetter($name);\n\n        if ($getter) {\n            return $getter();\n        }\n\n        throw new UnknownGetterException($name);\n    }\n\n    /**\n     * Get a property allowing both `DatePeriod` snakeCase and camelCase names.\n     *\n     * @param string $name\n     *\n     * @return bool|CarbonInterface|CarbonInterval|int|null\n     */\n    public function __get(string $name)\n    {\n        return $this->get($name);\n    }\n\n    /**\n     * Check if an attribute exists on the object\n     *\n     * @param string $name","sourceCodeStart":877,"sourceCodeEnd":913,"githubUrl":"https://github.com/briannesbitt/Carbon/blob/b13f05955dcfd7da71d60af745fd148cbdb73505/src/Carbon/CarbonPeriod.php#L877-L913","documentation":"CarbonPeriod exposes a small fixed set of magic properties through get()/__get(), mapped in getGetter() (src/Carbon/CarbonPeriod.php:859-878): start/start_date, end/end_date, interval/date_interval, recurrences, include_start_date, include_end_date, current, locale, tzname/tz_name — camelCase is converted to snake_case. Any other name raises UnknownGetterException with the property name as the message (src/Carbon/CarbonPeriod.php:895).","triggerScenarios":"$period->get('options'); $period->filters; $period->date_class; $period->timezone (valid magic name is tzname); dynamic loops like $period->$field where $field comes from a key list containing unsupported names.","commonSituations":"Serializing/exporting periods by iterating a fixed key list; assuming DatePeriod-style property names that are not mapped (e.g. exclude_start_date); typos in camelCase access (startDate works, startdDate throws).","solutions":["Use the supported names or the real methods: getStartDate(), getEndDate(), getDateInterval(), getRecurrences(), isStartIncluded(), isEndIncluded()","Guard dynamic access with isset($period->$name) — __isset() is wired to getGetter() and returns false instead of throwing","Read non-magic data via real methods: ->getOptions(), ->getFilters(), ->getDateClass()"],"exampleFix":"// before\nforeach (['start', 'end', 'options', 'filters'] as $key) {\n    $data[$key] = $period->{$key}; // UnknownGetterException on 'options'/'filters'\n}\n\n// after\n$data = [\n    'start' => $period->getStartDate(),\n    'end' => $period->getEndDate(),\n    'options' => $period->getOptions(),\n    'filters' => $period->getFilters(),\n];","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"$known = ['start', 'start_date', 'end', 'end_date', 'interval', 'date_interval',\n    'recurrences', 'include_start_date', 'include_end_date', 'current', 'locale', 'tzname', 'tz_name'];\n\nfunction canGet(CarbonPeriod $period, string $name): bool\n{\n    return isset($period->$name); // __isset() maps to getGetter(), never throws\n}\n\n$value = canGet($period, $field) ? $period->get($field) : null;","tryCatchPattern":"try {\n    $value = $period->get($field);\n} catch (\\Carbon\\Exceptions\\UnknownGetterException $e) {\n    $value = null; // or use a real getter: match($field) { 'options' => $period->getOptions(), ... }\n}","preventionTips":["Prefer real getter methods (getStartDate(), getOptions(), getFilters()) over magic property access","Use isset($period->$name) before dynamic access — it is wired to the same getter map and returns false safely","Keep a whitelist when exporting periods; do not loop over foreign key lists"],"tags":["carbon","carbon-period","magic-properties","unknown-property"],"backgroundTag":"unknown-property-access","analyzedSha":"b13f05955dcfd7da71d60af745fd148cbdb73505","analyzedAt":"2026-08-17T04:40:56.953Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}