`__` to `.` Convention
taufik-nurrohman opened this issue Β· comments
I must be crazy! Just another breaking changes idea that still floating around my head.
- The
p2f()
function converts__
prefix into.
character but that applies only if__
character exists in the first property name. Looks tricky and too strict for me because the rest of__
are not converted into dots. - This breaks a lot because most of namespaced functions are started with
_\lot\x
where in this case_\lot\x
is better to be compatible with./lot/x
return value. So, it is likely I will rename them into__\lot\x
.
What I want to do:
RENAME ALL EXTENSION FUNCTION NAMESPACES FROM_\lot\x\*
TO__\lot\x\*
π±- DO NOT CONVERT
\
INTO.
BUT INTO/
π₯
What will happen if these changes applied:
-
No more repeated replacement like this.
-
As
\
will be changed into/
, so namespaced functions will be easier to be converted into file path. This would change the way class auto-loader works. To load namespaced classes, you will need to put them under certain directory name, which is, in my opinion, looks pretty neat:// Before .\ βββ engine\ βββ kernel\ βββ pager.php βββ pager.page.php βββ pager.pages.php // After .\ βββ engine\ βββ kernel\ βββ pager\ β βββ page.php β βββ pages.php βββ pager.php
Seems to have more benefits. Nice issue number by the way.
To simplify the namespace specification, and to prevent me from experimenting with new ideas to create namespace according to the exact folder position, I decided to simply give namespace x
for extension-related functions and layout
for layout-related functions.
namespace layout\autumn;
function recent_comment_hooks() {}
function recent_page_hooks() {}
namespace x\panel;
function type() {}
function route() {}
You donβt have to provide namespace if your functions are unique enough and may be used as a feature enhancer for layouts and extensions, globally.
There may be various possible namespace specifications for special features as well, based on the existence of certain folders under .\lot
. For example, users may add custom route using functions instead of files:
namespace route\ajax;
function image_upload() {} // `http://127.0.0.1/route/ajax/image-upload`
Fixed on the main
branch.