PHP Classes

How to Get the Names of All Data Types Using the PHP Type Class: Get the names of each basic PHP data type

Recommend this page to a friend!
  Info   View files Documentation   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 67 All time: 10,286 This week: 200Up
Version License PHP version Categories
php-type-names 1.0.0GNU General Publi...7.3PHP 5, Data types, Language
Description 

Author

This simple class can get the names of each primary PHP data type.

It contains constants with the string values of all PHP variable types.

Applications can use it to get the names of the types to use this class together with the PHP functions SetType and GetType.

Innovation Award
PHP Programming Innovation award nominee
August 2022
Number 9
PHP is a weakly typed language. This fact means that it allows setting the type of variable values when executing the PHP code.

Although this makes the PHP language very flexible and tolerant of the developer's mistakes, sometimes it can be hard to debug subtle bugs caused by the developer's errors.

In practice, that can mean that developers may take more time to fix subtle bugs that probably would not exist if PHP was a strongly typed language.

This package provides a solution that can help to avoid those bugs. It gives the name strings of the PHP variable types.

So, if a developer wants to use the PHP GetType and SetType functions to get or set the variable type, the developer can use this class.

So, if the developer makes a mistake in the name of a constant provided by the class, PHP will trigger an error that can make it easier to find bugs caused by typing the name of a PHP type.

Manuel Lemos
Picture of Pierre-Henry Soria
  Performance   Level  
Name: Pierre-Henry Soria <contact>
Classes: 46 packages by
Country: United Kingdom
Age: 33
All time rank: 37916 in United Kingdom
Week rank: 32 Up2 in United Kingdom Up
Innovation award
Innovation award
Nominee: 17x

Winner: 3x

Documentation

PHP type names ??

Get all valid PHP type names with constants.

? Overview

Simple library containing the list of constants for the available PHP data types. Use those constant types in your project when you need to mention a data type, use those constants instead of hardcoding them.

?? Requirements

?? Installation

Install it easily with Composer

composer require ph-7/datatype

? Example

require_once __DIR__ . '/vendor/autoload.php';

use PH7\Datatype\Type;

$id = settype($_GET['id'], Type::STRING);

$name = settype($inputName, Type::STRING);

? Who cooked it?

Pierre-Henry Soria

[![@phenrysay][twitter-image]](https://twitter.com/phenrysay) [![pH-7][github-image]](https://github.com/pH-7)

Pierre-Henry Soria, a highly passionate, zen &amp; pragmatic software engineer ?

?? License

PHP type names is generously distributed under the MIT.

<!-- GitHub's Markdown reference links --> [twitter-image]: https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white [github-image]: https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white

<!-- Generated by https://github.com/pH-7/cool-readme-generator -->


  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (1 file)
Files folder imagetests (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file test.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file Type.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file TypeTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:67
This week:0
All time:10,286
This week:200Up