Erasin 3 years ago
parent
commit
287ea5dede
13 changed files with 112 additions and 50 deletions
  1. 2 1
      .gitignore
  2. 25 23
      composer.json
  3. 23 3
      src/Dy/Crypt.php
  4. 31 4
      src/Dy/Map.php
  5. 4 4
      src/Dy/Otp.php
  6. 14 5
      src/Dy/Rand.php
  7. 1 1
      src/Dy/Shell.php
  8. 5 5
      src/Dy/Time.php
  9. 6 3
      tests/RandTest.php
  10. BIN
      tests/a.png
  11. BIN
      tests/b.png
  12. BIN
      tests/c.png
  13. 1 1
      tests/shell.php

+ 2 - 1
.gitignore

@@ -1,4 +1,5 @@
 php_errors.log
 test
 .env
-vendor
+vendor
+*.png

+ 25 - 23
composer.json

@@ -1,25 +1,27 @@
 {
-    "name": "dyutils/ide-stubs",
-    "type": "library",
-    "description": "dyutils ide support",
-    "keywords": ["utils"],
-    "homepage": "https://git.dyuit.cn/dyutils/ide-stubs",
-    "license": "BSD-3-Clause",
-    "authors": [
-        {
-            "name": "Erasin",
-            "email": "erasinoo@gmail.com"
-        }
-    ],
-    "require": {
-        "php": ">=7.2.0"
-    },
-    "autoload-dev": {
-        "psr-4": {
-            "Dy\\": "src/"
-        }
-    },
-    "require-dev": {
-        "phpunit/phpunit": "^8.5"
+  "name": "dyutils/ide-stubs",
+  "type": "library",
+  "description": "dyutils ide support",
+  "keywords": [
+    "utils"
+  ],
+  "homepage": "https://git.dyuit.cn/dyutils/ide-stubs",
+  "license": "BSD-3-Clause",
+  "authors": [
+    {
+      "name": "Erasin",
+      "email": "erasinoo@gmail.com"
     }
-}
+  ],
+  "require": {
+    "php": ">=7.2.0"
+  },
+  "autoload-dev": {
+    "psr-4": {
+      "Dy\\": "src/"
+    }
+  },
+  "require-dev": {
+    "phpunit/phpunit": "^8.5"
+  }
+}

+ 23 - 3
src/Dy/Crypt.php

@@ -10,7 +10,7 @@ class Crypt
      * @param string $str
      * @return string
      */
-    public static function md5(string $str)
+    public static function md5(string $str): string
     {
     }
 
@@ -20,7 +20,7 @@ class Crypt
      * @param string $str
      * @return string
      */
-    public static function base32_encode(string $str)
+    public static function base32_encode(string $str): string
     {
     }
 
@@ -30,7 +30,27 @@ class Crypt
      * @param string $str
      * @return string
      */
-    public static function base32_decode(string $str)
+    public static function base32_decode(string $str): string
+    {
+    }
+
+    /**
+     * base64url_encode
+     *
+     * @param string $str
+     * @return string
+     */
+    public static function base64url_encode(string $str): string
+    {
+    }
+
+    /**
+     * base64url_decode
+     *
+     * @param string $str
+     * @return string
+     */
+    public static function base64url_decode(string $str): string
     {
     }
 }

+ 31 - 4
src/Dy/Map.php

@@ -2,8 +2,35 @@
 
 namespace Dy;
 
+
+/**
+ * DyMap 国内地图坐标转换
+ *
+ * WGS84坐标系 即地球坐标系,国际上通用的坐标系。 设备一般包含GPS芯片或者北斗芯
+ * 片获取的经纬度为WGS84地理坐标系。谷歌地图采用的是WGS84地理坐标系(中国范围除外,
+ * 谷歌中国地图采用的是GCJ02地理坐标系。)
+ *
+ * GCJ02坐标系 即火星坐标系,WGS84坐标系经加密后的坐标系。 出于国家安全考虑,国
+ * 内所有导航电子地图必须使用国家测绘局制定的加密坐标系统,即将一个真实的经纬度坐标  
+ * 加密成一个不正确的经纬度坐标。
+ *
+ * BD09坐标系 即百度坐标系,GCJ02坐标系经加密后的坐标系。搜狗坐标系、图吧坐标系
+ * 等,估计也是在GCJ02基础上加密而成的。
+ *
+ *  - baidu         BD09
+ *  - google        WGS84
+ *  - google china  GCJ02
+ *  - tencent       GCJ02
+ *  - ali           GCJ02
+ *  - gaode         GCJ02
+ *  - 51ditu        GCJ02
+ */
 class Map
 {
+    const BD09 = 0;
+    const WGS84 = 1;
+    const GCJ02 = 2;
+
     /**
      * 纬度
      *
@@ -44,7 +71,7 @@ class Map
      *
      * @return Map
      */
-    public function bd09()
+    public function bd09(): Map
     {
     }
 
@@ -53,7 +80,7 @@ class Map
      *
      * @return Map
      */
-    public function gcj02()
+    public function gcj02(): Map
     {
     }
 
@@ -62,7 +89,7 @@ class Map
      *
      * @return Map
      */
-    public function wgs84()
+    public function wgs84(): Map
     {
     }
 
@@ -72,7 +99,7 @@ class Map
      * @param Map $other
      * @return float
      */
-    public function distance(Map $other)
+    public function distance(Map $other): float
     {
     }
 }

+ 4 - 4
src/Dy/Otp.php

@@ -13,7 +13,7 @@ class Otp
      *
      * @return void
      */
-    public function __construct(string $secret, int $digits, int $preiod)
+    public function __construct(string $secret, int $digits, int $preiod): void
     {
     }
 
@@ -24,7 +24,7 @@ class Otp
      *
      * @return integer
      */
-    public function hotp(int $index)
+    public function hotp(int $index): int
     {
     }
 
@@ -33,7 +33,7 @@ class Otp
      *
      * @return integer
      */
-    public function totp()
+    public function totp(): int
     {
         // code...
     }
@@ -46,7 +46,7 @@ class Otp
      * @param String $issuer
      * @return String
      */
-    public function url(String $issuer)
+    public function url(String $issuer): string
     {
     }
 }

+ 14 - 5
src/Dy/Rand.php

@@ -12,7 +12,7 @@ class Rand
      *
      * @return float
      */
-    public static function float()
+    public static function float(): float
     {
     }
 
@@ -23,7 +23,7 @@ class Rand
      * @param integer $limit 字符串长度
      * @return string
      */
-    public static function alphanumeric(int $limit)
+    public static function alphanumeric(int $limit): string
     {
     }
 
@@ -33,7 +33,7 @@ class Rand
      * @param integer $limit 数字长度
      * @return integer
      */
-    public static function numeric(int $limit)
+    public static function numeric(int $limit): int
     {
     }
 
@@ -44,7 +44,7 @@ class Rand
      *
      * @return integer
      */
-    public static function snowflake($work_id = 1)
+    public static function snowflake($work_id = 1): int
     {
     }
 
@@ -53,7 +53,16 @@ class Rand
      *
      * @return integer
      */
-    public static function sonyflake()
+    public static function sonyflake(): int
+    {
+    }
+
+    /**
+     * uuid v4
+     *
+     * @return string
+     */
+    public static function uuid(): string
     {
     }
 }

+ 1 - 1
src/Dy/Shell.php

@@ -12,7 +12,7 @@ class Shell
      *
      * @return bool
      */
-    public static function exec(string $cmd, string $flags)
+    public static function exec(string $cmd, string $flags): bool
     {
     }
 }

+ 5 - 5
src/Dy/Time.php

@@ -10,7 +10,7 @@ class Time
      * @param boolean $is_local 是否为本地时间,默认 UTC时间
      * @return string 时间字符串
      */
-    public static function now_time(bool $is_local = true)
+    public static function now_time(bool $is_local = true): string
     {
     }
 
@@ -20,7 +20,7 @@ class Time
      * @param boolean $is_local 是否为本地时间,默认 UTC时间
      * @return integer 时间戳
      */
-    public static function now(bool $is_local = true)
+    public static function now(bool $is_local = true): int
     {
     }
 
@@ -30,7 +30,7 @@ class Time
      * @param boolean $is_local 是否为本地时间,默认 UTC时间
      * @return integer 时间戳
      */
-    public static function now_millis(bool $is_local = true)
+    public static function now_millis(bool $is_local = true): int
     {
     }
 
@@ -40,7 +40,7 @@ class Time
      * @param boolean $is_local 是否为本地时间,默认 UTC时间
      * @return integer 时间戳
      */
-    public static function now_micro(bool $is_local = true)
+    public static function now_micro(bool $is_local = true): int
     {
     }
 
@@ -50,7 +50,7 @@ class Time
      * @param boolean $is_local 是否为本地时间,默认 UTC时间
      * @return integer 时间戳
      */
-    public static function now_nano(bool $is_local = true)
+    public static function now_nano(bool $is_local = true): int
     {
     }
 }

+ 6 - 3
tests/RandTest.php

@@ -1,16 +1,19 @@
-<?php
+<?php declare(strict_types=1);
 
 use PHPUnit\Framework\TestCase;
 
 final class RandTest extends TestCase
 {
-    public function testFloat()
+    public function testFloat(): void
     {
         $re = Dy\Rand::float(4);
         $this->assertEquals(true, is_float($re));
     }
 
-    public function testNumeric()
+    /**
+     * @test
+     */
+    public function testNumeric(): void
     {
         $re = Dy\Rand::numeric(4);
         $this->assertEquals(true, is_numeric($re));

BIN
tests/a.png


BIN
tests/b.png


BIN
tests/c.png


+ 1 - 1
tests/shell.php

@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 // $re = DY\Shell::shell('ls', '-l');