phabstractic

Pure PHP Abstract Data Types, Features, and Algorithms

Documentation

For information on how the library works and how to use it please see:

Wunk.me Phabstractic Documentation

Inspiration

I've been fascinated with abstract concepts in programming ever since I started programming at age 7. To me, the idea that something can be abstracted to provide functionality apart from the data it necessarily represents is interesting. This was born first as an experiment to see what data types I could implement, but it has grown into it's own whole package.

What it does

Phabstractic provides pure PHP implementations of many different abstractions (data structure, patterns, algorithms).

For example, it provides a large list of abstract data structures (lists, queues, sets, maps, etc.)

What's next for phabstractic

Right now we're converting over the code from the old codebase located in asherwunk/primus2. I decided this was a perfectly good package on its own that I didn't need to muddy up the waters of the Artificial Intelligence System.

License

The MIT License (MIT) [OSI Approved License] The MIT License (MIT)

Copyright (c) 2015 Asher Holley

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Built With

Share this project:
×

Updates

posted an update

Phabstractic: Self-Sorting Lists Data Types

Sometimes you just need a list that'll put itself in order. You can do that by specifying a comparison method on a restricted list. Look out world, we're all alphabetical now with the LexicographicList.

You can read more about it at this blog post.

Thanks!

Log in or sign up for Devpost to join the conversation.

posted an update

Phabstractic: Restricted Lists Data Types

Lists are handy, but what happens when you only want certain data in your list, and not others? Combine a list with a restrictions predicate, and you have a restricted list.

You can read more about it at this blog post.

Thanks!

Log in or sign up for Devpost to join the conversation.

posted an update

Phabstractic: Stack Data Type

A stack is handy when you want to put things on hold, or you want to store stuff in a systemic way. They are used everywhere, but particularly useful in programming language design.

You can read more about it at this blog post.

Thanks!

Log in or sign up for Devpost to join the conversation.

posted an update

Phabstractic: Restricted Set Data Type

A set can hold any kind of information allowable in a PHP variable. What happens if we combine a restrictions predicate with a set. We only allow certain data types to be in the set.

You can read more about it at this blog post.

Log in or sign up for Devpost to join the conversation.

posted an update

Phabstracitc: Structure Data Type

Structures are a data structure supported by many different languages. The usefulness I think of this particular abstract data type is the ability to be accessed as an array, enabling TaggedUnions to act like normal variables.

You can read more about it at this blog post.

Thanks!

Log in or sign up for Devpost to join the conversation.

posted an update

Phabstractic: Tagged Union Data Type

Many programming techniques and data structures – including rope (data structure), lazy evaluation, class hierarchy (see below), arbitrary-precision arithmetic, CDR coding, the indirection bit and other kinds of tagged pointers, etc. – are usually implemented using some sort of tagged union.

You can learn more from this blog post.

Thanks!

Log in or sign up for Devpost to join the conversation.

posted an update

Phabstractic: Restrictrictions Data Type (Predicate)

Filters are important and very useful objects, allowing values or other logic to be filtered in and out of a particular set of data. Restrictions.php offers a way to use type checking in PHP, but in a very flexible and dynamic way. This can be useful for defining lists or sets that only accept certain values, which is useful for code cohesiveness and can reduce error checking.

You can see this blog post for more information.

Thanks!

Log in or sign up for Devpost to join the conversation.

posted an update

Phabstractic: Set Data Type

Sets play an important role in lots of mathematical computations and theories. A set is a bag of values that aren't necessarily in any order, they just exist in the set, or not in the set. Sets can also be set so that they only have unique values. The Set data type in Phabstractic enables easy manipulation of these simple but deviously complex entities.

You can see this blog post for more information.

Thanks!

Log in or sign up for Devpost to join the conversation.

posted an update

Phabstractic: Array Utilities

PHP's built-in array utilities/functions aren't always coherent with objects and mixed data. These methods provide some functionality that the PHP functions provide, but with more granular internal control.

You can see this blog post for more information.

Thanks!

Log in or sign up for Devpost to join the conversation.

posted an update

Phabstractic: Identity Trait

Sometimes you have to generate a unique identifier to a piece of data amidst a sea of other data in a dynamic way. There are many ways of doing this, but the most effective is to just keep counting up and never counting down. At least I think it is.

It's pretty basic, but you can see this blog post for more information.

Thanks!

Log in or sign up for Devpost to join the conversation.

posted an update

Phabstractic: Type Enumeration

PHP has type checking, to a degree, but what if we could encapsulate the checking of multiple classes and data types into one place? The first steps to this is the identification of data types that are available in PHP.

For more information see this blog post.

Thanks!

Log in or sign up for Devpost to join the conversation.

posted an update

Phabstractic: Enumeration Data Type

PHP doesn't provide a means of an Enumeration data type like languages such as C, or Java. There is an obscure SplEnum, but that doesn't seem to have been followed up on much. I have provided what I believe to be a superior Enumeration class for data types.

For more information see this blog post.

Thanks!

Log in or sign up for Devpost to join the conversation.

posted an update

Phabstractic: Configuration Trait

The thing about PHP and the mixin’s I’ve developed is that they are not necessarily a class, instead the idea is that they are a trait that offers a particular feature to another class. So you define a feature, something the class can do, such as logging, or being able to hold configurations (see below) and then you can add it to a particular class.

For more information see this blog post

Thanks!

Log in or sign up for Devpost to join the conversation.

posted an update

Phabstractic: Registry Design Pattern

A registry design pattern has been added to the project. This provides a PHP class that is instantiated once and acts like an array. It uses the Singleton Trait Design Pattern to achieve the Singleton functionality.

For more information see this blog post

Thanks!

Log in or sign up for Devpost to join the conversation.