Skip to content

Commit

Permalink
测试php版本下的使用环境,现支持php>=5.4的版本下使用
Browse files Browse the repository at this point in the history
之前使用string类型约束,必须要php7.0以上的支持,现在去除string的类型约束,更新公共打印函数的兼容性。
  • Loading branch information
all-back committed Jul 4, 2018
1 parent 8644047 commit 672ca9c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion php/Business.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function rightMenu(RCMWindows $rcm_windows_config)
}

// 主要业务逻辑
public function main(string $item_name, string $show_name, string $path, string $icon, array $extended, array $options)
public function main($item_name, $show_name, $path, $icon, array $extended, array $options)
{
$rcm_windows_config = new RCMWindows();
$rcm_windows_config->setItemName($item_name)->setShowName($show_name)->setPath($path)->setIcon($icon);
Expand Down
8 changes: 4 additions & 4 deletions php/RightClickMenu/RCMWindows.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ class RCMWindows implements RightClickMenu
protected $icon = null;
protected $extended = null;

public function setItemName(string $item_name)
public function setItemName($item_name)
{
$this->item_name = $item_name;

return $this;
}

public function setShowName(string $show_name)
public function setShowName($show_name)
{
$this->show_name = $show_name;

return $this;
}

public function setPath(string $path)
public function setPath($path)
{
$this->path = $path;

return $this;
}

public function setIcon(string $icon)
public function setIcon($icon)
{
$this->icon = $icon;

Expand Down
8 changes: 4 additions & 4 deletions php/RightClickMenu/RightClickMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

interface RightClickMenu
{
public function setItemName(string $item_name);
public function setShowName(string $show_name);
public function setPath(string $path);
public function setIcon(string $icon);
public function setItemName($item_name);
public function setShowName($show_name);
public function setPath($path);
public function setIcon($icon);

public function getItemName();
public function getShowName();
Expand Down
22 changes: 11 additions & 11 deletions php/common/funs.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?php
/**
* 变量友好化打印输出
* @param variable $param 可变参数
* @example dump($a,$b,$c,$e,[.1]) 支持多变量,使用英文逗号符号分隔,默认方式 print_r,查看数据类型传入 .1
* @version php>=5.6
* @version php4、5、7
* @return void
*/
function dump(...$param)
function dump()
{
echo '<style>.php-print{background:#eee;padding:10px;border-radius:4px;border:1px solid #ccc;line-height:1.5;white-space:pre-wrap;font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:13px;}</style>', '<pre class="php-print">';
if (end($param) === .1) {
array_splice($param, -1, 1);
foreach ($param as $k => $v) {
echo $k > 0 ? '<hr>' : '';
$args = func_get_args();
if(end($args) === .1){
array_splice($args, -1, 1);
foreach($args as $k => $v){
echo $k>0 ? '<hr>' : '';
ob_start();
var_dump($v);
echo preg_replace('/]=>\s+/', '] => ', ob_get_clean());
echo preg_replace('/]=>\s+/', '] => <label>', ob_get_clean());
}
} else {
foreach ($param as $k => $v) {
echo $k > 0 ? '<hr>' : '', print_r($v, true); // echo 逗号速度快 https://segmentfault.com/a/1190000004679782
}else{
foreach($args as $k => $v){
echo $k>0 ? '<hr>' : '', print_r($v, true);
}
}
echo '</pre>';
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

这个工具能够生成右键菜单的注册表文件(含`创建``移除`两个文件)。

> 工具更好的实现方式应该是利用`python`写一个`.exe`来实现
> 工具更好的实现方式应该是直接和windows / apple等进行交互,减少用户的操作
> 这个小工具是拿来练习PHP设计模式的实例,为了更好地理解设计模式。
## 运行环境

PHP >= 5.6
PHP >= 5.4

## 使用

Expand Down

0 comments on commit 672ca9c

Please sign in to comment.