This commit is contained in:
2024-04-30 07:08:23 +02:00
commit a711247971
2043 changed files with 16874 additions and 0 deletions

View File

@@ -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

10
snippets/php-mode/__call Normal file
View File

@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: __call()
# key: __call
# group: Magic Methods
# --
public function __call($name, $args)
{
$0
}

View File

@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: __callStatic()
# key: __callStatic
# group: Magic Methods
# --
public function __callStatic($name, $args)
{
$0
}

10
snippets/php-mode/catch Normal file
View File

@@ -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;}
}

10
snippets/php-mode/cls Normal file
View File

@@ -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
}

10
snippets/php-mode/clse Normal file
View File

@@ -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
}

10
snippets/php-mode/clsi Normal file
View File

@@ -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
}

7
snippets/php-mode/const Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: const
# key: const
# group: definitions
# --
const ${1:NAME} = ${2:value};

7
snippets/php-mode/define Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: define
# key: define
# group: definitions
# --
define('${1:NAME}', ${2:value});

View File

@@ -0,0 +1,11 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: PHPDoc (multi-line)
# key: /**
# group: annotation
# --
/**
* ${1:Summary}
*
*$0
*/

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: Doc comment (one-line)
# key: *
# group: annotation
# --
/** ${1:Summary} */

9
snippets/php-mode/else Normal file
View File

@@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: else
# key: else
# group: control structure
# --
else {
$0
}

9
snippets/php-mode/elseif Normal file
View File

@@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: elseif
# key: elseif
# group : control structure
# --
elseif (${1:condition}) {
$0
}

11
snippets/php-mode/enum Normal file
View File

@@ -0,0 +1,11 @@
# -*- mode: snippet -*-
# contributor: takeo obara<bararararatty@gmail.com>
# name: enum
# key: enum
# group : definitions
# --
enum ${1:Name}${2:: type} {
case: ${3:One};
case: ${4:Two};
$0
}

9
snippets/php-mode/fn Normal file
View File

@@ -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)) ";" "")`

View File

@@ -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
}

View File

@@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: foreach (array as $key => $value)
# key: foreach=>
# group : control structure
# --
foreach (${1:$expression} as \$${2:key} => \$${3:value}) {
$0
}

View File

@@ -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
}

View File

@@ -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
}

10
snippets/php-mode/get Normal file
View File

@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# contributor: Robin de Rooij <rderooij685@gmail.com>
# name: get
# key: get
# group: definitions
# --
public function get${1:$(upcase-initials yas-text)}()
{
return \$this->$1;
}

9
snippets/php-mode/if Normal file
View File

@@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: if
# key: if
# group : control structure
# --
if (${1:condition}) {
$0
}

View File

@@ -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
}

View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: PHPDoc @license
# key: *license
# group: annotation
# --
* @license ${1:https://www.gnu.org/licenses/gpl-3.0.html} ${2:GPL-3.0}${0:
*}

View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: PHPDoc @license Apache License
# key: *license-apache
# group: annotation
# --
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache-2.0${0:
*}

View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: PHPDoc @license GPLv2
# key: *license-gplv2
# group: annotation
# --
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GPL-2.0${0:
*}

View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: PHPDoc @license MIT
# key: *license-mit
# group: annotation
# --
* @license https://opensource.org/licenses/MIT MIT${0:
*}

View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: PHPDoc @license MPL
# key: *license-mpl
# group: annotation
# --
* @license https://www.mozilla.org/en-US/MPL/2.0/ MPL-2.0${0:
*}

10
snippets/php-mode/match Normal file
View File

@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# contributor: takeo obara<bararararatty@gmail.com>
# name: match
# key: match
# group : control structure
# --
match (${1:$var}) {
${2:$cond} => ${3:$return},
$0
};

View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: PHPDoc @param
# key: *param
# group: annotation
# --
* @param ${1:type} ${2:$variable} ${3:description}${0:
*}

View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: PHPDoc @property
# key: *property
# group: annotation
# --
* @property ${1:type} ${2:$variable} ${3:description}${0:
*}

7
snippets/php-mode/psysh Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: psysh
# key: psysh
# group: generic
# --
eval(\Psy\sh());

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: PHPDoc @return
# key: *return
# group: annotation
# --
* @return ${1:type} ${2:description}

10
snippets/php-mode/set Normal file
View File

@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# contributor: Robin de Rooij <rderooij685@gmail.com>
# name: set
# key: set
# group: definitions
# --
public function set${1:$(upcase-initials yas-text)}(\$$1)
{
\$this->$1 = \$$1;
}

7
snippets/php-mode/stdout Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: fwrite(STDOUT)
# key: stdout
# group: generic
# --
fwrite(STDOUT, ${1:$var}${2: . PHP_EOL});

12
snippets/php-mode/switch Normal file
View File

@@ -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:
}

7
snippets/php-mode/ticks Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: declare(ticks=)
# key: ticks
# group: definitions
# --
declare(ticks=${1:1});

10
snippets/php-mode/trait Normal file
View File

@@ -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
}

12
snippets/php-mode/try Normal file
View File

@@ -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;}
}

View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: PHPDoc: var
# key: *var
# group: definitions
# --
* @var ${type}${0:
*}

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: PHPDoc: @var (one-line)
# key: @var
# group: definitions
# --
/** @var ${type} */

7
snippets/php-mode/vd Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: var_dump()
# key: vd
# group: generic
# --
var_dump(${1:$var});

7
snippets/php-mode/vde Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: var_dump() exit
# key: vde
# group: generic
# --
var_dump(${1:$var});exit(1);

7
snippets/php-mode/ve Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# contributor: USAMI Kenta <tadsan@zonu.me>
# name: var_export()
# key: ve
# group: generic
# --
var_export(${1:$var}${2:, true});