Browse Source

Relax dependence on ctype

ns
J. King 5 years ago
parent
commit
f72809d621
  1. 10
      composer.json
  2. 5
      composer.lock
  3. 30
      lib/ctype.php
  4. 10
      vendor-bin/phpunit/composer.lock

10
composer.json

@ -4,10 +4,12 @@
"type": "library", "type": "library",
"require": { "require": {
"php": "^7.0", "php": "^7.0",
"ext-ctype": "*", "ext-dom": "*",
"ext-hash": "*",
"mensbeam/intl": "*" "mensbeam/intl": "*"
}, },
"suggest": {
"ext-ctype": "Improved performance"
},
"scripts": { "scripts": {
"post-install-cmd": ["@composer bin all install"], "post-install-cmd": ["@composer bin all install"],
"post-update-cmd": ["@composer bin all update"] "post-update-cmd": ["@composer bin all update"]
@ -33,10 +35,10 @@
"lib/DOM/traits" "lib/DOM/traits"
] ]
}, },
"classmap": ["lib/Token.php"] "classmap": ["lib/Token.php"],
"files": ["lib/ctype.php"]
}, },
"autoload-dev": { "autoload-dev": {
"files": ["lib/Token.php"],
"psr-4": { "psr-4": {
"dW\\HTML5\\Test\\": "tests/lib/", "dW\\HTML5\\Test\\": "tests/lib/",
"dW\\HTML5\\TestCase\\": "tests/cases/" "dW\\HTML5\\TestCase\\": "tests/cases/"

5
composer.lock

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "7f73d57a54597e507dfcbd1a6d40b779", "content-hash": "037fcc961f6e8f68b15379be21f45854",
"packages": [ "packages": [
{ {
"name": "mensbeam/intl", "name": "mensbeam/intl",
@ -100,8 +100,7 @@
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"php": "^7.0", "php": "^7.0",
"ext-ctype": "*", "ext-dom": "*"
"ext-hash": "*"
}, },
"platform-dev": [] "platform-dev": []
} }

30
lib/ctype.php

@ -0,0 +1,30 @@
<?php
namespace dW\HTML5;
// This file adds shims for matching single characters
// using the same API as the ctype extension, if the
// extension is missing. They are not a complete
// replacement, as they are designed only to evaluate
// single characters
if (!extension_loaded("ctype")) {
function ctype_alnum(string $str): bool {
return ["a"=>true,"b"=>true,"c"=>true,"d"=>true,"e"=>true,"f"=>true,"g"=>true,"h"=>true,"i"=>true,"j"=>true,"k"=>true,"l"=>true,"m"=>true,"n"=>true,"o"=>true,"p"=>true,"q"=>true,"r"=>true,"s"=>true,"t"=>true,"u"=>true,"v"=>true,"w"=>true,"x"=>true,"y"=>true,"z"=>true,"A"=>true,"B"=>true,"C"=>true,"D"=>true,"E"=>true,"F"=>true,"G"=>true,"H"=>true,"I"=>true,"J"=>true,"K"=>true,"L"=>true,"M"=>true,"N"=>true,"O"=>true,"P"=>true,"Q"=>true,"R"=>true,"S"=>true,"T"=>true,"U"=>true,"V"=>true,"W"=>true,"X"=>true,"Y"=>true,"Z"=>true,"0"=>true,"1"=>true,"2"=>true,"3"=>true,"4"=>true,"5"=>true,"6"=>true,"7"=>true,"8"=>true,"9"=>true][$str] ?? false;
}
function ctype_alpha(string $str): bool {
return ["a"=>true,"b"=>true,"c"=>true,"d"=>true,"e"=>true,"f"=>true,"g"=>true,"h"=>true,"i"=>true,"j"=>true,"k"=>true,"l"=>true,"m"=>true,"n"=>true,"o"=>true,"p"=>true,"q"=>true,"r"=>true,"s"=>true,"t"=>true,"u"=>true,"v"=>true,"w"=>true,"x"=>true,"y"=>true,"z"=>true,"A"=>true,"B"=>true,"C"=>true,"D"=>true,"E"=>true,"F"=>true,"G"=>true,"H"=>true,"I"=>true,"J"=>true,"K"=>true,"L"=>true,"M"=>true,"N"=>true,"O"=>true,"P"=>true,"Q"=>true,"R"=>true,"S"=>true,"T"=>true,"U"=>true,"V"=>true,"W"=>true,"X"=>true,"Y"=>true,"Z"=>true][$str] ?? false;
}
function ctype_upper(string $str): bool {
return ["A"=>true,"B"=>true,"C"=>true,"D"=>true,"E"=>true,"F"=>true,"G"=>true,"H"=>true,"I"=>true,"J"=>true,"K"=>true,"L"=>true,"M"=>true,"N"=>true,"O"=>true,"P"=>true,"Q"=>true,"R"=>true,"S"=>true,"T"=>true,"U"=>true,"V"=>true,"W"=>true,"X"=>true,"Y"=>true,"Z"=>true][$str] ?? false;
}
function ctype_digit(string $str): bool {
return ["0"=>true,"1"=>true,"2"=>true,"3"=>true,"4"=>true,"5"=>true,"6"=>true,"7"=>true,"8"=>true,"9"=>true][$str] ?? false;
}
function ctype_xdigit(string $str): bool {
return ["a"=>true,"b"=>true,"c"=>true,"d"=>true,"e"=>true,"f"=>true,"A"=>true,"B"=>true,"C"=>true,"D"=>true,"E"=>true,"F"=>true,"0"=>true,"1"=>true,"2"=>true,"3"=>true,"4"=>true,"5"=>true,"6"=>true,"7"=>true,"8"=>true,"9"=>true][$str] ?? false;
}
}

10
vendor-bin/phpunit/composer.lock

@ -364,16 +364,16 @@
}, },
{ {
"name": "phpspec/prophecy", "name": "phpspec/prophecy",
"version": "1.10.0", "version": "1.10.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpspec/prophecy.git", "url": "https://github.com/phpspec/prophecy.git",
"reference": "d638ebbb58daba25a6a0dc7969e1358a0e3c6682" "reference": "cbe1df668b3fe136bcc909126a0f529a78d4cbbc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/d638ebbb58daba25a6a0dc7969e1358a0e3c6682", "url": "https://api.github.com/repos/phpspec/prophecy/zipball/cbe1df668b3fe136bcc909126a0f529a78d4cbbc",
"reference": "d638ebbb58daba25a6a0dc7969e1358a0e3c6682", "reference": "cbe1df668b3fe136bcc909126a0f529a78d4cbbc",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -423,7 +423,7 @@
"spy", "spy",
"stub" "stub"
], ],
"time": "2019-12-17T16:54:23+00:00" "time": "2019-12-22T21:05:45+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",

Loading…
Cancel
Save