Merge pull request #720 from codeinabox/php-namespace-from-relpath

Use relative path when determining `namespace` for PHP snippet
This commit is contained in:
Honza Pokorny 2016-04-29 14:55:45 -03:00
commit 042aec6f06

View File

@ -268,8 +268,8 @@ endsnippet
snippet ns "namespace declaration" b snippet ns "namespace declaration" b
namespace ${1:`!p namespace ${1:`!p
abspath = os.path.abspath(path) relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', abspath) m = re.search(r'[A-Z].+(?=/)', relpath)
if m: if m:
snip.rv = m.group().replace('/', '\\') snip.rv = m.group().replace('/', '\\')
`}; `};
@ -279,8 +279,8 @@ snippet class "Class declaration template" b
<?php <?php
namespace ${1:`!p namespace ${1:`!p
abspath = os.path.abspath(path) relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', abspath) m = re.search(r'[A-Z].+(?=/)', relpath)
if m: if m:
snip.rv = m.group().replace('/', '\\') snip.rv = m.group().replace('/', '\\')
`}; `};
@ -298,8 +298,8 @@ snippet interface "Interface declaration template" b
<?php <?php
namespace ${1:`!p namespace ${1:`!p
abspath = os.path.abspath(path) relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', abspath) m = re.search(r'[A-Z].+(?=/)', relpath)
if m: if m:
snip.rv = m.group().replace('/', '\\') snip.rv = m.group().replace('/', '\\')
`}; `};