Inconsistent syntax of calling methods in configuration

m.brecher
Generous Backer | 717
+
+3
-

Hi,

may be this comment would be helpful for improving the syntax rules in .neon configuration:

I tested the correct syntax of calling methods of objects in configuration and compare the result (nette/neon v3.3.3):

local.neon – syntax samples:

params:
                # case 1 - reads method, expected behaviour
	param: @Nette\Http\Request::getUrl()

                # case 2 - attempt to read property - Nette\MemberAccessException, expected behaviour
    param: @Nette\Http\Request::getUrl

                # case 3 - cals method, expected behaviour
    param: @Nette\Http\Request::getUrl()::getBasePath()

               # case 4 -  cals not property but method getBasePath(), unexpected behaviour
    param: @Nette\Http\Request::getUrl()::getBasePath

The standard syntax calling methods with brackets getXxx() works, so there is no problem for people using standard syntax.

But in some cases works also the nonstandard syntax – see syntax sample number 4 so some people may think this in neon works as standard and will start use it, later they come to the point that this syntax works only in special cases. This brakes the intuitiveness of the syntax.

I have no much experiences with Nette at all, but I dont see any added value of having nonstandard syntax for calling methods (object::method) in the neon configuration files.

So I propose the internal Nette developers to think about removing the nonstandard one away and use only object::method() syntax.

Last edited by m.brecher (2023-01-07 17:39)