PHPackages                             yarco/type-detector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yarco/type-detector

AbandonedLibrary[Utility &amp; Helpers](/categories/utility)

yarco/type-detector
===================

TypeDetector is php library to detect variable types by the name and value

v0.0.2(9y ago)015MITPHPPHP ^7.0

Since Nov 12Pushed 9y ago1 watchersCompare

[ Source](https://github.com/yarcowang/type-detector.php)[ Packagist](https://packagist.org/packages/yarco/type-detector)[ RSS](/packages/yarco-type-detector/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Type Detector
=============

[](#type-detector)

[![Latest Version](https://camo.githubusercontent.com/1c585a36b565dc2395a8fc07f4687f9935995718bac2874017387a5fb46b7d59/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f796172636f77616e672f747970652d6465746563746f722e7068702e7376673f7374796c653d666c61742d737175617265)](https://github.com/yarcowang/type-detector.php/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/c8f863226580fb4c84ab4f5f2d23e2dc02091638eefd5eedbca7ae44fa40a3fd/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f796172636f77616e672f747970652d6465746563746f722e7068702f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/yarcowang/type-detector.php)[![Total Downloads](https://camo.githubusercontent.com/29af155585e1cbf0423e3424ff4ef9ad6f0a997a84dfc6f6fe9f3bb596e3a2ac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796172636f2f747970652d6465746563746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yarco/type-detector)

TypeDetector is php library to detect variable types by the key name and the value. The thinkings inherit from [superunit](https://github.com/yarcowang/superunit) and [php-schema](https://github.com/yarcowang/php-schema) ( *both are my experimental projects* ).

Usage
-----

[](#usage)

Use [composer](https://getcomposer.org/) to install this library.

`composer require yarco/type-detector`

Use the class's static method `array TypeDetector::detect(array $array)` to get key-value pair of the types.

Example:

```
use Yarco\TypeDetector;

$result = TypeDetector::detect(['name' => 'yarco', 'age' => 36]);
print_r($result);

/*
it should return

Array
(
    [name] => string
    [age] => smallint
)

*/
```

Types
-----

[](#types)

Below fields are referenced from [w3schools.com](http://www.w3schools.com/sql/sql_datatypes.asp).

### Number

[](#number)

MySQL Data TypesSQL Server Data TypesHTML Input TypesDoctrine Types*Type Detector Supported*TINYINT(size)tinyintSMALLINT(size)smallintsmallint*smallint*MEDIUMINT(size)INT(size)intrange, numberinteger*int*BIGINT(size)bigintbigint*bigint*FLOAT(size,d)realDOUBLE(size,d)float(n)float*float*DECIMAL(size,d)decimal(p,s)decimal*decimal*numeric(p,s)smallmoneymoneybitboolean### Text

[](#text)

MySQL Data TypesSQL Server Data TypesHTML Input TypesDoctrine Types*Type Detector Supported*CHAR(size)char(n), nchar(n)VARCHAR(size)varchar(n), nvarchar(n)textstring*string*TINYTEXTTEXTtext, ntexttextareatext*text*BLOBbinary, varbinarybinaryMEDIUMTEXTMEDIUMBLOBLONGTEXTLONGBLOBimageblobENUM(x,y,z,etc.)selectSETpassword*password*color*color*email*email*searchtelurl*url*### Datetime

[](#datetime)

MySQL Data TypesSQL Server Data TypesHTML Input TypesDoctrine Types*Type Detector Supported*DATEdatedatedate*date*DATETIMEdatetime, datetime2, smalldatetimedatetime, datetime-localdatetime*datetime*TIMESTAMPtimestampTIMEtimetimetime*time*YEARmonth,weekdatetimeoffsetdatetimetz### Other

[](#other)

MySQL Data TypesSQL Server Data TypesHTML Input TypesDoctrine Types*Type Detector Supported*```
| uniqueidentifier | | guid

```

JSON | | checkbox |

Valid Type Definitions
----------------------

[](#valid-type-definitions)

Type Detector Supported Types | Definition | Priority (large first) ----|----|----|---- *smallint* | type is integer and value less than 100 | 120 *bigint* | type is integer and value large than 10000 | 120 *int* | type is integer | 115 *decimal* | type is float and number of the fraction is either 2 or 3 | 112 *float* | type is float | 110 *password* | type is string and value is \*\*\* | 100 *color* | type is string and value match ^#\[0-9a-fA-F\]{6}$ | 90 *email* | type is string and value is email | 80 *url* | type is string and value is url | 70 *date* | type is string and value match ^\\d{2}/\\d{2}/\\d{4}$ or ^\\d{4}-\\d{2}-\\d{2}$ | 60 *time* | type is string and value match ^\\d{2}:\\d{2}:\\d{2}$ or ^\\d{2}:\\d{2}$ | 60 *datetime* | type is tring and value match ^\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}(?::\\d{2})?$ or can be convert to datetime | 55 *string* | type is string and length less than 27 | 20 *text* | type is tring | 0

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

3516d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1576504?v=4)[Yarco](/maintainers/yarcowang)[@yarcowang](https://github.com/yarcowang)

---

Top Contributors

[![yarcowang](https://avatars.githubusercontent.com/u/1576504?v=4)](https://github.com/yarcowang "yarcowang (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yarco-type-detector/health.svg)

```
[![Health](https://phpackages.com/badges/yarco-type-detector/health.svg)](https://phpackages.com/packages/yarco-type-detector)
```

###  Alternatives

[misterion/pinba-phpdoc

@phpdoc extension php pinba for IDE autocomplete

1054.2k2](/packages/misterion-pinba-phpdoc)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
