PHPackages                             mfn/cakephp2-magic-properties - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mfn/cakephp2-magic-properties

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

mfn/cakephp2-magic-properties
=============================

Automatically add class documentation for CakePHP2 magic properties

v0.1.4(11y ago)268MITPHPPHP &gt;=5.4.0

Since Oct 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/mfn/cakephp2-magic-properties)[ Packagist](https://packagist.org/packages/mfn/cakephp2-magic-properties)[ Docs](http://github.com/mfn/cakephp2-magic-properties)[ RSS](/packages/mfn-cakephp2-magic-properties/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (5)Dependencies (6)Versions (8)Used By (0)

Abandoned
=========

[](#abandoned)

This repository is archived, it served its purpose.

---

Automatically add class documentation for CakePHP2 magic properties [ ![Travis Build Status](https://camo.githubusercontent.com/fb0e1dc246250bafa37c15b97cedfed4579738b6df55de7da877561054cf519e/68747470733a2f2f7472617669732d63692e6f72672f6d666e2f63616b65706870322d6d616769632d70726f706572746965732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mfn/cakephp2-magic-properties)
==================================================================================================================================================================================================================================================================================================================================================================================================

[](#automatically-add-class-documentation-for-cakephp2-magic-properties--)

Homepage:

Blurb
=====

[](#blurb)

When working with [CakePHP2](http://cakephp.org/), dependency injection happens via magic properties like `uses`, `helpers`, etc.

Unfortunately not many editors/IDEs are capable of understanding this special syntax and thus almost none provide autocompletion for the resulting magic properties.

By running this script against your CakePHP2 sources, PHPDOC `@property` is addded to the class definitions which aids into autocompletion the propert types.

Just pass any files/directories to the script and they will be parsed and PHPDOC properties added. Note that every class will be resolved via it's parents to figure out if it's a Controller or Helper, thus the script must be able to find all relevant parent classes to properly resolve them. Usually, just passing your Controller/ and/or Helper/ direcotries should do fine.

This code uses the excellent [PhpParser library](https://github.com/nikic/PHP-Parser) by Nikita Popov.

What injected properties are supported?
=======================================

[](#what-injected-properties-are-supported)

- `Controller`
    - `components`
    - `uses`
- `Component`
    - `components`
- `Helper`
    - `components`
    - `helpers`
    - `uses`
- `Model`
    - `belingsTo`
    - `hasAndBelongsToMany`
    - `hasOne`
    - `hasMany`
- `Shell`
    - `uses`

The `className` setting is also supported.

For details please see `res/configuration.php`.

Usage
=====

[](#usage)

`cakephp2_magic_properties magic app/Controller/`

or

`cakephp2_magic_properties magic app/View/Helper/`

or just your whole app (note that it will recursively parse all \*.php files):

`cakephp2_magic_properties magic ../path/to/your/app/`

It will convert:

```
AppController extends Controller {
  $uses = ['Foo'];
  $component = ['Bar'];
}
```

into

```
/**
 * @property BarComponent $Bar
 * @property Foo $Foo
 */
AppController extends Controller {
  $uses = ['Foo'];
  $component = ['Bar'];
}
```

By default, existing properties will not be touched but care is taken to not create duplicates. If however you want to remove all existing `@property` documentation, use the `--remove` flag `cakephp2_magic_properties magic --remove ../path/to/your/app/`:

```
/**
 * @property BarComponent $Bar
 * @property Foo $Foo
 */
AppController extends Controller {
  $component = ['Bar'];
}
```

into

```
/**
 * @property BarComponent $Bar
 */
AppController extends Controller {
  $component = ['Bar'];
}
```

Note: it may also cause to re-order your existing properties if none have really changed (because interally first all properties are always removed).

See the `--help` flag for other options. The library is designed to act idempotent.

Integration with phing
----------------------

[](#integration-with-phing)

A phing task is also provided for better phing integration. Use `taskdef` to define a new custom task.

```

```

The following attributes are supported:

- `configFile`
    Path to configuration file, see next chapter
- `dryRun`
    Whether to actually write changes to files; defaults to `false` which means *overwrite* the files. This is useful in combination with `haltOnSourcesChanged`
- `haltOnSourcesChanged`
    Whether to abort the build if any source files have been changed.
- `removeUnknownProperties`
    Whether to remove unknown `@property` declarations

Note: due the use of namespaces this will only work properly if phing is used via composer too.

Configuration file
==================

[](#configuration-file)

In `res/configuration.php` the projects default configuration is provided which all runners allow to override.

This file contains the mapping:

1. from "top level class" to properties
2. and those properties map to a closure which transform the name of a injected virtual property

The closure approach is required because e.g. `helpers` and `components` have different rules how the actual class names have to be called.

Requirements
============

[](#requirements)

- PHP 5.4 (tested with at least 5.4.24)

Installation
============

[](#installation)

```
composer.phar require mfn/cakephp2-magic-properties 0.1.1

```

TODOs / Ideas
=============

[](#todos--ideas)

- Support for Tests?

© Markus Fischer

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Recently: every ~24 days

Total

7

Last Release

4123d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4f0d4e7638e419a48dde77f4c481fb1eb2dbe8f5fe913e68e26269ee7e051ade?d=identicon)[mfn](/maintainers/mfn)

---

Top Contributors

[![mfn](https://avatars.githubusercontent.com/u/87493?v=4)](https://github.com/mfn "mfn (39 commits)")

---

Tags

utilitycakephp2

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mfn-cakephp2-magic-properties/health.svg)

```
[![Health](https://phpackages.com/badges/mfn-cakephp2-magic-properties/health.svg)](https://phpackages.com/packages/mfn-cakephp2-magic-properties)
```

###  Alternatives

[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M568](/packages/symfony-maker-bundle)[phpro/soap-client

A general purpose SoapClient library

8885.6M46](/packages/phpro-soap-client)[roave/backward-compatibility-check

Tool to compare two revisions of a public API to check for BC breaks

5953.3M56](/packages/roave-backward-compatibility-check)[coenjacobs/mozart

Composes all dependencies as a package inside a WordPress plugin

4723.6M20](/packages/coenjacobs-mozart)[vaimo/composer-patches

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and patch command for testing/troubleshooting added patches.

2994.3M16](/packages/vaimo-composer-patches)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)

PHPackages © 2026

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