Skip to content

Commit

Permalink
Merge pull request #429 from cakephp/no-php
Browse files Browse the repository at this point in the history
Remove the need for <?php everywhere
  • Loading branch information
lorenzo committed Nov 21, 2012
2 parents 4ce5264 + 55608d1 commit 8340dc0
Show file tree
Hide file tree
Showing 115 changed files with 499 additions and 1,512 deletions.
8 changes: 7 additions & 1 deletion config/all.py
Expand Up @@ -71,7 +71,7 @@
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []

highlight_language = 'php'
highlight_language = 'phpinline'


# -- Options for HTML output ---------------------------------------------------
Expand Down Expand Up @@ -281,3 +281,9 @@

# Languages available.
languages = ['en', 'pt', 'es', 'ja', 'ru', 'fr']

# Hack to render the php source code without the <?php tag
from sphinx.highlighting import lexers
from pygments.lexers.web import PhpLexer

lexers['phpinline'] = PhpLexer(startinline=True)
26 changes: 0 additions & 26 deletions en/appendices/2-0-migration-guide.rst
Expand Up @@ -111,7 +111,6 @@ Internationalization / Localization

If you want to echo the result of the translation, use::

<?php
echo __('My Message');
This change includes all shortcut translation methods::
Expand All @@ -128,7 +127,6 @@ Alongside this, if you pass additional parameters, the translation will call
`sprintf <http://php.net/manual/en/function.sprintf.php>`_ with these
parameters before returning. For example::

<?php
// Will return something like "Called: MyClass:myMethod"
echo __('Called: %s:%s', $className, $methodName);

Expand Down Expand Up @@ -215,7 +213,6 @@ Components
Component is now the required base class for all components. You should update
your components and their constructors, as both have changed::

<?php
class PrgComponent extends Component {
function __construct(ComponentCollection $collection, $settings = array()) {
parent::__construct($collection, $settings);
Expand Down Expand Up @@ -245,7 +242,6 @@ All the deprecated callbacks in Component have not been transferred to
ComponentCollection. Instead you should use the `trigger()` method to interact
with callbacks. If you need to trigger a callback you could do so by calling::

<?php
$this->Components->trigger('someCallback', array(&$this));

Changes in disabling components
Expand Down Expand Up @@ -429,7 +425,6 @@ Although there has been a huge refactoring in how the classes are loaded, in ver
few occasions you will need to change your application code to respect the way you were
used to doing it. The biggest change is the introduction of a new method::

<?php
App::uses('AuthComponent', 'Controller/Component');

We decided the function name should emulate PHP 5.3's ``use`` keyword, just as a way
Expand All @@ -443,7 +438,6 @@ is used for the first time it will be located.
Some examples on using :php:meth:`App::uses()` when migrating from
:php:meth:`App::import()`::

<?php
App::import('Controller', 'Pages');
// becomes
App::uses('PagesController', 'Controller');
Expand All @@ -468,7 +462,6 @@ All classes that were loaded in the past using ``App::import('Core', $class);``
will need to be loaded using ``App::uses()`` referring to the correct package.
See the api to locate the classes in their new folders. Some examples::

<?php
App::import('Core', 'CakeRoute');
// becomes
App::uses('CakeRoute', 'Routing/Route');
Expand All @@ -494,7 +487,6 @@ App::build() and core paths

Examples::

<?php
App::build(array('controllers' => array('/full/path/to/controllers')));
//becomes
App::build(array('Controller' => array('/full/path/to/Controller')));
Expand Down Expand Up @@ -526,7 +518,6 @@ Cache

::

<?php
Cache::config('something');
Cache::write('key', $value);
Expand Down Expand Up @@ -557,14 +548,12 @@ Router
``index`` action is given a short route. If you wish to continue using short
routes, you can add a route like::

<?php
Router::connect('/users/:action', array('controller' => 'users', 'plugin' => 'users'));
To your routes file for each plugin you need short routes on.

Your app/Config/routes.php file needs to be updated adding this line at the bottom of the file::

<?php
require CAKE . 'Config' . DS . 'routes.php';

This is needed in order to generate the default routes for your application. If you do not wish to have such routes,
Expand Down Expand Up @@ -663,7 +652,6 @@ In order to accommodate View being removed from the ClassRegistry, the signature
of Helper::__construct() was changed. You should update any subclasses to use
the following::

<?php
function __construct(View $View, $settings = array())

When overriding the constructor you should always call `parent::__construct` as
Expand Down Expand Up @@ -803,13 +791,11 @@ this, just change ``$_minimizedAttributeFormat`` in your AppHelper to ``%s``.

To use with Html/Form helpers and others, you can write::

<?php
$this->Form->checkbox('field', array('checked' => true, 'value' => 'some_value'));

Other facility is that minimized attributes can be passed as item and not as
key. For example::

<?php
$this->Form->checkbox('field', array('checked', 'value' => 'some_value'));

Note that ``checked`` have a numeric key.
Expand Down Expand Up @@ -938,7 +924,6 @@ afterRender it is the view file being rendered. For beforeLayout and afterLayout
it is the layout file being rendered. Your helpers function signatures should
look like::

<?php
function beforeRender($viewFile) {

}
Expand Down Expand Up @@ -1030,20 +1015,17 @@ Models
Model relationships are now lazy loaded. You can run into a situation where
assigning a value to a nonexistent model property will throw errors::

<?php
$Post->inexistentProperty[] = 'value';

will throw the error "Notice: Indirect modification of overloaded property
$inexistentProperty has no effect". Assigning an initial value to the property
solves the issue::

<?php
$Post->nonexistentProperty = array();
$Post->nonexistentProperty[] = 'value';

Or just declare the property in the model class::

<?php
class Post {
public $nonexistentProperty = array();
}
Expand Down Expand Up @@ -1087,12 +1069,10 @@ List of Changes
* API for DboSource::execute has changed, it will now take an array of query
values as second parameter::

<?php
public function execute($sql, $params = array(), $options = array())

became::

<?php
public function execute($sql, $options = array(), $params = array())

third parameter is meant to receive options for logging, currently it only
Expand All @@ -1102,7 +1082,6 @@ List of Changes
* DboSource::fetchAll() now accepts an array as second parameter, to pass values
to be bound to the query, third parameter was dropped. Example::

<?php
$db->fetchAll('SELECT * from users where username = ? AND password = ?', array('jhon', '12345'));
$db->fetchAll('SELECT * from users where username = :username AND password = :password', array('username' => 'jhon', 'password' => '12345'));

Expand Down Expand Up @@ -1145,15 +1124,13 @@ AclBehavior and TreeBehavior

- No longer supports strings as configuration. Example::

<?php
public $actsAs = array(
'Acl' => 'Controlled',
'Tree' => 'nested'
);

became::

<?php
public $actsAs = array(
'Acl' => array('type' => 'Controlled'),
'Tree' => array('type' => 'nested')
Expand All @@ -1167,14 +1144,12 @@ Plugins no longer magically append their plugin prefix to components, helpers
and models used within them. You must be explicit with the components, models,
and helpers you wish to use. In the past::

<?php
public $components = array('Session', 'Comments');

Would look in the controller's plugin before checking app/core components. It
will now only look in the app/core components. If you wish to use objects from a
plugin you must put the plugin name::

<?php
public $components = array('Session', 'Comment.Comments');

This was done to reduce hard to debug issues caused by magic misfiring. It also
Expand Down Expand Up @@ -1272,7 +1247,6 @@ the key "driver" is not accepted anymore, only "datasource", in order to make it
more consistent. Also, as the datasources have been moved to packages you will
need to pass the package they are located in. Example::

<?php
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
Expand Down
2 changes: 0 additions & 2 deletions en/appendices/2-1-migration-guide.rst
Expand Up @@ -12,7 +12,6 @@ removed from the CakePHP core. If you do not already have these classes, you
can use the following while upgrading::

// app/View/Helper/AppHelper.php
<?php
App::uses('Helper', 'View');
class AppHelper extends Helper {
}
Expand Down Expand Up @@ -262,7 +261,6 @@ View
instead.
- ``$scripts_for_layout`` is deprecated. Use the following instead::

<?php
echo $this->fetch('meta');
echo $this->fetch('css');
echo $this->fetch('script');
Expand Down
3 changes: 0 additions & 3 deletions en/appendices/2-2-migration-guide.rst
Expand Up @@ -13,7 +13,6 @@ When upgrading to CakePHP 2.2 its important to add a few new configuration
values to ``app/Config/bootstrap.php``. Adding these will ensure consistent
behavior with 2.1.x::

<?php
// Enable the Dispatcher filters for plugin assets, and
// CacheHelper.
Configure::write('Dispatcher.filters', array(
Expand All @@ -36,7 +35,6 @@ behavior with 2.1.x::
You will also need to modify ``app/Config/core.php``. Change the value of
:php:const:`LOG_ERROR` to :php:const:`LOG_ERR`::

<?php
define('LOG_ERROR', LOG_ERR);

When using ``Model::validateAssociated()`` or ``Model::saveAssociated()`` and
Expand Down Expand Up @@ -274,7 +272,6 @@ It is now possible to tag or label cache keys under groups. This makes it
simpler to mass-delete cache entries associated to the same label. Groups are
declared at configuration time when creating the cache engine::

<?php
Cache::config(array(
'engine' => 'Redis',
...
Expand Down
2 changes: 1 addition & 1 deletion en/appendices/cakephp-development-process.rst
Expand Up @@ -53,4 +53,4 @@ on irc.freenode.net.

.. meta::
:title lang=en: CakePHP Development Process
:keywords lang=en: maintenance branch,community interaction,community feature,necessary feature,stable release,ticket system,advanced feature,power users,feature set,chat irc,leading edge,router,new features,members,attempt,development branches,branch development
:keywords lang=en: maintenance branch,community interaction,community feature,necessary feature,stable release,ticket system,advanced feature,power users,feature set,chat irc,leading edge,router,new features,members,attempt,development branches,branch development
2 changes: 0 additions & 2 deletions en/appendices/glossary.rst
Expand Up @@ -12,7 +12,6 @@ Glossary
html attributes
An array of key => values that are composed into html attributes. For example::
<?php
// Given
array('class' => 'my-class', '_target' => 'blank')

Expand All @@ -22,7 +21,6 @@ Glossary
If an option can be minimized or accepts it's name as the value, then ``true``
can be used::
<?php
// Given
array('checked' => true)
Expand Down
31 changes: 5 additions & 26 deletions en/appendices/migrating-from-cakephp-1-2-to-1-3.rst
Expand Up @@ -46,7 +46,6 @@ There is a new way to add those paths. As of 1.3 RC1 the

::

<?php
App::build(array(
'plugins' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'),
'models' => array('/full/path/to/models/', '/next/full/path/to/models/'),
Expand Down Expand Up @@ -74,11 +73,8 @@ configs are created **before** bootstrap.php is loaded.
``inflections.php`` has been removed, it was an unnecessary file
hit, and the related features have been refactored into a method to
increase their flexibility. You now use ``Inflector::rules()`` to
load custom inflections.
load custom inflections::

::

<?php
Inflector::rules('singular', array(
'rules' => array('/^(bil)er$/i' => '\1', '/^(inflec|contribu)tors$/i' => '\1ta'),
'uninflected' => array('singulars'),
Expand Down Expand Up @@ -223,11 +219,8 @@ automatically included without you asking for them. SessionHelper
and SessionComponent now act like every other component and must be
declared like any other helper/component. You should update
``AppController::$components`` and ``AppController::$helpers`` to
include these classes to retain existing behavior.

::
include these classes to retain existing behavior::

<?php
var $components = array('Session', 'Auth', ...);
var $helpers = array('Session', 'Html', 'Form' ...);

Expand Down Expand Up @@ -281,11 +274,8 @@ behavior with other prefix style routes in that it was treated
differently. Instead you should use ``Routing.prefixes``. Prefix
routes in 1.3 do not require additional routes to be declared
manually. All prefix routes will be generated automatically. To
update simply change your core.php.

::
update simply change your core.php::

<?php
//from:
Configure::write('Routing.admin', 'admin');
Expand All @@ -295,11 +285,8 @@ update simply change your core.php.
See the New features guide for more information on using prefix
routes. A small change has also been done to routing params. Routed
params should now only consist of alphanumeric chars, - and \_ or
``/[A-Z0-9-_+]+/``.
``/[A-Z0-9-_+]+/``::

::

<?php
Router::connect('/:$%@#param/:action/*', array(...)); // BAD
Router::connect('/:can/:anybody/:see/:m-3/*', array(...)); //Acceptable

Expand All @@ -308,11 +295,8 @@ increase performance and reduce code clutter. The side effect of
this is two seldom used features were removed, as they were
problematic and buggy even with the existing code base. First path
segments using full regular expressions was removed. You can no
longer create routes like

::
longer create routes like::

<?php
Router::connect('/([0-9]+)-p-(.*)/', array('controller' => 'products', 'action' => 'show'));

These routes complicated route compilation and impossible to
Expand All @@ -321,9 +305,6 @@ you use route parameters with capture patterns. Next mid-route
greedy star support has been removed. It was previously possible to
use a greedy star in the middle of a route.

::

<?php
Router::connect(
'/pages/*/:event',
array('controller' => 'pages', 'action' => 'display'),
Expand All @@ -343,7 +324,6 @@ $this->redirect() calls to reflect this change.

::

<?php
// old format:
$url = array('controller' => 'posts', 'action' => 'view', 'id' => $id);
// use cases:
Expand Down Expand Up @@ -500,7 +480,6 @@ automatically outputs SQL logs. If you want to output SQL logs in

::

<?php
echo $this->element('sql_dump');

You can place this element anywhere in your layout or view. The
Expand Down

0 comments on commit 8340dc0

Please sign in to comment.