PHPackages                             ocolin/global-type - 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. ocolin/global-type

ActiveLibrary

ocolin/global-type
==================

Simple library for making sure global variables are of a specific type

v2.0.0(2mo ago)0409MITPHPPHP ^8.0

Since Nov 22Pushed 1mo agoCompare

[ Source](https://github.com/ocolin/GlobalType)[ Packagist](https://packagist.org/packages/ocolin/global-type)[ RSS](/packages/ocolin-global-type/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (8)Used By (9)

GlobalType
==========

[](#globaltype)

Description
-----------

[](#description)

GlobalType is a simple library that allows type checks on global arrays. Because by default the array elements are mixed, one has to check the element type before using. This library makes it easier to tell PHP what type you are expecting from a global array.

Requirements
------------

[](#requirements)

The only requirement is PHP version 8.0 or higher.

Installation
------------

[](#installation)

composer require ocolin/global-type

Usage
-----

[](#usage)

### Available Classes

[](#available-classes)

GlobalType has a class for each of the PHP Globals:

ClassGlobalCOOKIE::class$\_COOKIEENV::class$\_ENVFILES::class$\_FILESGET::class$\_GETGLOBALS::class$GLOBALSPOST::class$\_POSTREQUEST::class$\_REQUESTSERVER::class$\_SERVERSESSION::class$\_SESSION### Available Methods

[](#available-methods)

Every class shares the same functions which are used on the classes corresponding PHP Global

MethodDescriptiongetStringReturn a string or '' if not found.getStringNullReturn a string or null if not found.getIntReturn an int or 0 if not found.getIntNullReturn an int or null if not found.getFloatReturn a float or 0.0 if not found.getFloatNullReturn a float of null if not found.getBoolReturn a bool or false if not found.getBoolNullReturn a bool or null if not found.getArrayReturn an array or \[\] if not found.getArrayNullReturn an array or null if not found.getObjectReturn same object or null if not found.### Arguments

[](#arguments)

Both the Null and non-Null methods take a name parameter, while the Null methods only take a name argument.

- name - The name of the array key in the targeted PHP global.
- default - If the element is not found or the type does not match, you can return a default value of your choice.

### Basic Usage

[](#basic-usage)

```
use Ocolin\GlobalType\GET;
$_GET['parameter'] = 'value';

$value = GET::getString( name: 'parameter' );
// string(5) "value"

$value = GET::getInt( name: 'parameter' );
// int(0)

$value = GET::getIntNull( name: 'parameter' );
// NULL

$value = GET::getInt( name: 'parameter', default: 777 );
//int(777)
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance88

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity45

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 ~23 days

Recently: every ~29 days

Total

6

Last Release

61d ago

Major Versions

1.6 → v2.0.02026-03-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/e97ac0aa452b872ddc3f7f4c56c83852574a27bb74622f8c054d11ca20008fc9?d=identicon)[Ocolin](/maintainers/Ocolin)

---

Top Contributors

[![ocolin](https://avatars.githubusercontent.com/u/8870196?v=4)](https://github.com/ocolin "ocolin (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ocolin-global-type/health.svg)

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

PHPackages © 2026

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