Add PHP basic syntax (statement) for php-mode (#202)
* Add PHP basic syntax (statement) for php-mode * Add php-mode/.yas-setup.el * Replace to function (yas-php-get-class-name-by-file-name)
This commit is contained in:
parent
50557c37d8
commit
98a784a7ed
|
@ -0,0 +1,16 @@
|
|||
;;; .yas-setup.el --- Yasnippet helper functions for PHP snippets
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
(require 'yasnippet)
|
||||
|
||||
(defun yas-php-get-class-name-by-file-name ()
|
||||
"Return name of class-like construct by `file-name'.
|
||||
|
||||
\"class-like\" contains class, trait and interface."
|
||||
(file-name-nondirectory
|
||||
(file-name-sans-extension (or (buffer-file-name)
|
||||
(buffer-name (current-buffer))))))
|
||||
|
||||
;;; .yas-setup.el ends here
|
|
@ -0,0 +1,10 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: catch
|
||||
# key: catch
|
||||
# group : control structure
|
||||
# --
|
||||
catch (${1:\PDOException} ${2:$e}) {
|
||||
${3:
|
||||
throw $e;}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: class
|
||||
# key: cls
|
||||
# group: definitions
|
||||
# --
|
||||
class ${1:`(yas-php-get-class-name-by-file-name)`}
|
||||
{
|
||||
$0
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: class extends
|
||||
# key: clse
|
||||
# group: definitions
|
||||
# --
|
||||
class ${1:`(yas-php-get-class-name-by-file-name)`} extends ${2:ParentClass}
|
||||
{
|
||||
$0
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: class implements
|
||||
# key: clsi
|
||||
# group: definitions
|
||||
# --
|
||||
class ${1:`(yas-php-get-class-name-by-file-name)`} implements ${interface}
|
||||
{
|
||||
$0
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: const
|
||||
# key: const
|
||||
# group: definitions
|
||||
# --
|
||||
const ${1:NAME} = ${2:value};
|
|
@ -0,0 +1,7 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: define
|
||||
# key: define
|
||||
# group: definitions
|
||||
# --
|
||||
define('${1:NAME}', ${2:value});
|
|
@ -0,0 +1,9 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: else
|
||||
# key: else
|
||||
# group: control structure
|
||||
# --
|
||||
else {
|
||||
$0
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: elseif
|
||||
# key: elseif
|
||||
# group : control structure
|
||||
# --
|
||||
elseif (${1:condition}) {
|
||||
$0
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: function expr (closure)
|
||||
# key: fn
|
||||
# group: definitions
|
||||
# --
|
||||
function (${2:$arg, ...}) ${3:use ($var) }{
|
||||
$0
|
||||
}`(if (eq (point) (line-end-position)) ";" "")`
|
|
@ -0,0 +1,9 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: foreach
|
||||
# key: foreach
|
||||
# group : control structure
|
||||
# --
|
||||
foreach (${1:$expression} as \$${2:value}) {
|
||||
$0
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: function statement
|
||||
# key: function
|
||||
# group: definitions
|
||||
# --
|
||||
${4:public }function ${1:name}(${2:$arg, ...})
|
||||
{
|
||||
$0
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: function :type
|
||||
# key: function:
|
||||
# group : control structure
|
||||
# --
|
||||
${4:public }function ${1:name}(${2:$arg, ...}): ${3:type}
|
||||
{
|
||||
$0
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: if
|
||||
# key: if
|
||||
# group : control structure
|
||||
# --
|
||||
if (${1:condition}) {
|
||||
$0
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: interface
|
||||
# key: interface
|
||||
# group : definitions
|
||||
# --
|
||||
interface ${1:`(yas-php-get-class-name-by-file-name)`}
|
||||
{
|
||||
$0
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: switch
|
||||
# key: switch
|
||||
# group : control structure
|
||||
# --
|
||||
switch (${1:condition}) {
|
||||
case ${2:expr}:
|
||||
$0
|
||||
break;
|
||||
default:
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: trait
|
||||
# key: trait
|
||||
# group : definitions
|
||||
# --
|
||||
trait ${1:`(yas-php-get-class-name-by-file-name)`}
|
||||
{
|
||||
$0
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
# -*- mode: snippet -*-
|
||||
# contributor: USAMI Kenta <tadsan@zonu.me>
|
||||
# name: try
|
||||
# key: try
|
||||
# group : control structure
|
||||
# --
|
||||
try {
|
||||
$0
|
||||
} catch (${1:\PDOException} ${2:$e}) {
|
||||
${3:
|
||||
throw $e;}
|
||||
}
|
Loading…
Reference in New Issue