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 3w 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 35% 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

4170d 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

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k28.9M2.4k](/packages/infection-infection)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)

PHPackages © 2026

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