jkphl / micrometa

A meta parser for extracting micro information out of web documents, currently supporting Microformats 1+2, HTML Microdata, RDFa Lite 1.1, JSON-LD and Link Types, written in PHP
http://micrometa.jkphl.is
MIT License
115 stars 39 forks source link

Inaccessible properties with capital letters #1

Closed tschiemer closed 10 years ago

tschiemer commented 10 years ago

Hi

Not sure if this applies to all properties, as I'm just testing out the library, but I can not access a startDate property of an event microdata type.

Reproducable as:

$url = 'http://www.residentadvisor.net/events.aspx?ai=174'; // just some random event site
$parser = new \Jkphl\Micrometa($url);
$item = $parser->item('http://data-vocabulary.org/Event');
print_r($item);
var_dump($item->startDate);

Outputs:

Jkphl\Micrometa\Parser\Microdata\Item Object
(
[_url:protected] => Jkphl\Utility\Url Object
    (
        [_url:protected] => http://www.residentadvisor.net/events.aspx?ai=174
        [_parts:protected] => Array
            (
                [scheme] => http
                [host] => www.residentadvisor.net
                [path] => /events.aspx
                [query] => Array
                    (
                        [ai] => 174
                    )

            )

    )

[types] => Array
    (
        [0] => http://data-vocabulary.org/Event
    )

[id] => 
[value] => 
[_properties:protected] => stdClass Object
    (
        [startDate] => Array
            (
                [0] => 2014-05-16T00:00
            )

        [summary] => Array
            (
                [0] => 360 Degrees: Osunlade at Bird
            )

        [url] => Array
            (
                [0] => http://www.residentadvisor.net/event.aspx?569206=
            )

    )

)
NULL

In Jkphl\Micrometa\Item::__get any uppercase characters are exchanged as follows:

`startDate` -> `start-date`

If I remove the responsible line, it works just fine.

Is the property stored correctly as startDate or is it intended to be stored as start-date?

Edit: as for the versions I'm using:

    "mf2/mf2": "dev-master",
    "euskadi31/microdata": "dev-master",
    "jkphl/micrometa": "dev-master",
jkphl commented 10 years ago

Hi @tschiemer,

thanks for your report! I'm currently on holiday and will be back to my office around end of May. I'll test things then and get back to you. Thanks for your patience!

Cheers, Joschi

jkphl commented 10 years ago

Hey @tschiemer,

you were right: That line was simply wrong / obsolete, as the microformats2 processing (for which the decamelization was intended) already uses it's own implementation. Deleting the line fixes the issue, I published a new release. Thanks again for reporting!