Skip to content

3.20.0

Choose a tag to compare

@kamshory kamshory released this 09 Dec 15:33
· 41 commits to main since this release
01679fc

MagicObject Version 3.20.0

Change: Removal of Math-Related Classes

In this release, several math-related classes have been removed from MagicObject to keep the core library lightweight and focused.

Removed Modules

  1. Complex Numbers
  2. Matrix Operations
  3. Geometry Utilities

Migration

These classes are not discontinued, but have been moved into a new dedicated repository:

👉 Planetbiru/MagicMath

Developers who rely on these math utilities should install the new package separately:

composer require planetbiru/magic-math

New Feature: PDO Connection Verification Method

A new method isPdoConnected() has been introduced to allow developers to verify not only the TCP-level connection, but also the ability of PHP to execute SQL statements on the database.

New Method: PicoPageData::getResultAsArray()

The new getResultAsArray() method allows users to return a list of data directly as an array, which can be immediately sent as JSON. This eliminates the need to first collect the data as an array of objects and then manually construct an array.

Bug Fix: Handle Exception in method getDatabaseCredentialsFromPdo($pdo, $driver, $dbType)

If an error occurs when executing:

$dsn = $pdo->getAttribute(PDO::ATTR_CONNECTION_STATUS);

getDatabaseCredentialsFromPdo($pdo, $driver, $dbType) will return an empty instance of SecretObject.

Enhancement: Improved getDatabaseCredentialsFromPdo Handling

The method getDatabaseCredentialsFromPdo has been updated to better handle
PDO drivers that do not support certain attributes (e.g., PDO::ATTR_CONNECTION_STATUS).

Key Improvements

  • Warning Suppression
    Suppresses warnings when PDO::getAttribute(PDO::ATTR_CONNECTION_STATUS)
    is not supported by the active PDO driver (e.g., SQLite).

  • Graceful Fallback
    Introduced an optional $databaseCredentials parameter, which is used as a
    fallback source for host, port, and database name if they cannot be extracted
    from the PDO connection.

  • Driver-Agnostic Behavior
    Ensures compatibility across multiple database drivers (MySQL, PostgreSQL, SQLite, etc.)
    without causing runtime warnings.

  • Consistent Output
    Always returns a populated SecretObject with connection details.
    If extraction fails, either the provided $databaseCredentials is returned,
    or a new empty SecretObject is created.

Why It Matters?

  • Prevents noisy PHP warnings in environments where PDO drivers expose limited attributes.
  • Provides a more reliable and consistent mechanism for retrieving database credentials.
  • Ensures backward compatibility while making the method more robust in multi-database environments.

What's Changed

Full Changelog: 3.19.0...3.20.0