ziyadsk / dk
另一种编写PHP的方式
dev-master
2020-01-13 03:32 UTC
Requires
- php: ^7.2
This package is auto-updated.
Last update: 2024-09-13 13:38:59 UTC
README
另一种编写PHP的方式
安装
通过Composer
composer global require ziyadsk/dk:dev-master
将composer的bin目录添加到您的路径中
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
用法
dk [file] [destination]
- 如果没有指定目标,当前目录将作为目标。
特性
DK 将更易于阅读的代码转换为PHP
删除分号、美元符号和开放标签
name = "John Doe" echo("Hello")
到
<?php $name = "John Doe" ; echo($name); ?>
函数和循环的更简短语法
fn print_100_times(variable){ for(i in {1..100}){ print(variable) } }
到
<?php function print_100_times($variable){ for($i=0 ;$i<=100; $i++){ print($variable); } } ?>
更易于阅读的foreach循环
for(element in my_arr){ print(element) } }
到
<?php foreach($my_arr as $element){ print($element); } ?>
类、类属性和接口
class Car : Vehicule [SomeInterface,AnotherInterFace] { static pub name = "Honda" serial_number = "9819020Z0DJLOZEOLD" pub fn start_engine(){} } myCar = new Car() myCar->start_engine()
到
<?php class Car extends Vehicule implements SomeInterface, AnotherInterFace { static $name = "Honda"; private $serial_number = "9819020Z0DJLOZEOLD"; public function start_engine() {} } $myCar = new Car() ; $myCar->start_engine() ; ?>
编辑器支持
- VScode扩展 -> DK