Why toURL and not toUrl - or is it?

The documentation of toURL is quite clear: “toURL” and not “toUrl”.

Weird thing is:

  1. The actual field method is, and from what I can tell has been called “toUrl” ever since its introduction in commit f21a9c9b0f095cf8db3183812966a6c7e3a6d8af
  2. The dynamic invocation code in the FieldAbstract class checks the method to be called with isset(static::$methods[$method]) which - to the best of my PHP knowledge - is case SENSITIVE.
  3. Consequently, in my setup with PHP 7.1 and Kirby 2.4.1 calling toURL just returns the field itself which isn’t quite what is advertised in the documentation :wink:

For me, toUrl does the trick, but I found myself being very confused by all that.

So… my question is: Does toURL work for anybody and what environment are you using if it does?

1 Like

Yes, it only works with toUrl(), not toURL(), need to fix the docs.

Hmmm… did it ever work with toURL()? I had a really hard time believing that I’d be the first one to run into this since the docs are everybody’s go-to place and I’ve been relying on the (amazing) docs ever since I started Kirbying.

I don’t think so, I just tested it with a 2.1.1 (the version after the commit), and toURL() doesn’t work with that version either.

You can also just use url() btw.

Interesting :slight_smile:

I saw the url() alias for that method when I checkt out the code, but since that one isn’t documented, I didn’t know about it until I started investigating the toURL() issue.

=> https://github.com/getkirby/getkirby.com/issues/333