|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +StellarWP Arrays is a PHP library providing 50+ array manipulation utilities for WordPress plugins and PHP projects. It's designed as a standalone library that can be integrated into any PHP 7.4+ project. |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +### Testing |
| 12 | +```bash |
| 13 | +# Run tests with SLIC |
| 14 | +slic use arrays |
| 15 | +slic run wpunit |
| 16 | + |
| 17 | +# Run specific test |
| 18 | +slic run wpunit tests/wpunit/GetTest.php |
| 19 | +``` |
| 20 | + |
| 21 | +### Static Analysis |
| 22 | +```bash |
| 23 | +# Run PHPStan static analysis (level 5) |
| 24 | +composer test:analysis |
| 25 | +``` |
| 26 | + |
| 27 | +### Documentation |
| 28 | +```bash |
| 29 | +# Generate API documentation |
| 30 | +composer create-docs |
| 31 | +``` |
| 32 | + |
| 33 | +### Development Setup |
| 34 | +```bash |
| 35 | +# Install dependencies |
| 36 | +composer install |
| 37 | + |
| 38 | +# The arrays.php file is a WordPress plugin bootstrap for testing only |
| 39 | +# Actual library code is in src/Arrays/Arr.php |
| 40 | +``` |
| 41 | + |
| 42 | +## Architecture |
| 43 | + |
| 44 | +### Core Structure |
| 45 | +- **Main Class**: `StellarWP\Arrays\Arr` in `src/Arrays/Arr.php` - Contains all array manipulation methods |
| 46 | +- **Namespace**: `StellarWP\Arrays` (PSR-4 autoloaded) |
| 47 | +- **Methods**: 50+ static methods for array manipulation (get, set, filter, map, etc.) |
| 48 | + |
| 49 | +### Testing Architecture |
| 50 | +- **Framework**: Codeception with WP Browser for WordPress integration |
| 51 | +- **Test Suite**: `wpunit` - WordPress unit tests |
| 52 | +- **Test Location**: `tests/wpunit/` - Each method has its own test file |
| 53 | +- **Base Class**: Tests extend `ArraysTestCase` for common functionality |
| 54 | +- **CI**: Uses SLIC (StellarWP's infrastructure CLI) for automated testing |
| 55 | + |
| 56 | +### Key Design Patterns |
| 57 | +1. **Static Methods**: All array utilities are static methods on the `Arr` class |
| 58 | +2. **Dot Notation**: Many methods support dot notation for nested array access (e.g., 'user.profile.name') |
| 59 | +3. **Fluent Interface**: Methods can be chained for complex operations |
| 60 | +4. **Laravel-inspired**: Many methods ported from Laravel's array helpers |
| 61 | + |
| 62 | +### Integration Notes |
| 63 | +- Can be used standalone via Composer: `composer require stellarwp/arrays` |
| 64 | +- For production use in plugins, use Strauss for namespace prefixing to avoid conflicts |
| 65 | +- The `arrays.php` file is only for testing - not needed in production |
| 66 | + |
| 67 | +### Development Considerations |
| 68 | +- No JavaScript/frontend components - pure PHP library |
| 69 | +- WordPress coding standards should be followed |
| 70 | +- All public methods must have comprehensive PHPDoc blocks |
| 71 | +- New methods require corresponding test files in `tests/wpunit/` |
0 commit comments