Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit944d91c

Browse files
committed
made some method name changes to have a better coherence throughout the framework
When an object has a "main" many relation with related "things" (objects,parameters, ...), the method names are normalized: * get() * set() * all() * replace() * remove() * clear() * isEmpty() * add() * register() * count() * keys()The classes below follow this method naming convention: * BrowserKit\CookieJar -> Cookie * BrowserKit\History -> Request * Console\Application -> Command * Console\Application\Helper\HelperSet -> HelperInterface * DependencyInjection\Container -> services * DependencyInjection\ContainerBuilder -> services * DependencyInjection\ParameterBag\ParameterBag -> parameters * DependencyInjection\ParameterBag\FrozenParameterBag -> parameters * DomCrawler\Form -> FormField * EventDispatcher\Event -> parameters * Form\FieldGroup -> Field * HttpFoundation\HeaderBag -> headers * HttpFoundation\ParameterBag -> parameters * HttpFoundation\Session -> attributes * HttpKernel\Profiler\Profiler -> DataCollectorInterface * Routing\RouteCollection -> Route * Security\Authentication\AuthenticationProviderManager -> AuthenticationProviderInterface * Templating\Engine -> HelperInterface * Translation\MessageCatalogue -> messagesThe usage of these methods are only allowed when it is clear that there is amain relation: * a CookieJar has many Cookies; * a Container has many services and many parameters (as services is the main relation, we use the naming convention for this relation); * a Console Input has many arguments and many options. There is no "main" relation, and so the naming convention does not apply.For many relations where the convention does not apply, the following methodsmust be used instead (where XXX is the name of the related thing): * get() -> getXXX() * set() -> setXXX() * all() -> getXXXs() * replace() -> setXXXs() * remove() -> removeXXX() * clear() -> clearXXX() * isEmpty() -> isEmptyXXX() * add() -> addXXX() * register() -> registerXXX() * count() -> countXXX() * keys()
1 parent5c5e8f1 commit944d91c

File tree

56 files changed

+266
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+266
-266
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Controller/InternalController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public function indexAction($path, $controller)
3434
$request =$this->container->get('request');
3535
$attributes =$request->attributes;
3636

37-
$attributes->delete('path');
38-
$attributes->delete('controller');
37+
$attributes->remove('path');
38+
$attributes->remove('controller');
3939
if ('none' !==$path)
4040
{
4141
parse_str($path,$tmp);

‎src/Symfony/Bundle/FrameworkBundle/RequestListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public function register(EventDispatcher $dispatcher, $priority = 0)
4949

5050
publicfunctionhandle(Event$event)
5151
{
52-
$request =$event->getParameter('request');
53-
$master = HttpKernelInterface::MASTER_REQUEST ===$event->getParameter('request_type');
52+
$request =$event->get('request');
53+
$master = HttpKernelInterface::MASTER_REQUEST ===$event->get('request_type');
5454

5555
$this->initializeSession($request,$master);
5656

‎src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function register(EventDispatcher $dispatcher, $priority = 0)
4747

4848
publicfunctionhandle(Event$event,Response$response)
4949
{
50-
if (HttpKernelInterface::MASTER_REQUEST !==$event->getParameter('request_type')) {
50+
if (HttpKernelInterface::MASTER_REQUEST !==$event->get('request_type')) {
5151
return$response;
5252
}
5353

@@ -57,10 +57,10 @@ public function handle(Event $event, Response $response)
5757
$response->headers->get('location'),$response->headers->get('location'))
5858
);
5959
$response->setStatusCode(200);
60-
$response->headers->delete('Location');
60+
$response->headers->remove('Location');
6161
}
6262

63-
$request =$event->getParameter('request');
63+
$request =$event->get('request');
6464
if (!$response->headers->has('X-Debug-Token')
6565
||'3' ===substr($response->getStatusCode(),0,1)
6666
|| ($response->headers->has('Content-Type') &&false ===strpos($response->headers->get('Content-Type'),'html'))

‎src/Symfony/Component/Console/Application.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Usage:
3838
*
3939
* $app = new Application('myapp', '1.0 (stable)');
40-
* $app->addCommand(new SimpleCommand());
40+
* $app->add(new SimpleCommand());
4141
* $app->run();
4242
*
4343
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
@@ -74,8 +74,8 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
7474
newDialogHelper(),
7575
));
7676

77-
$this->addCommand(newHelpCommand());
78-
$this->addCommand(newListCommand());
77+
$this->add(newHelpCommand());
78+
$this->add(newListCommand());
7979

8080
$this->definition =newInputDefinition(array(
8181
newInputArgument('command', InputArgument::REQUIRED,'The command to execute'),
@@ -181,7 +181,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
181181
}
182182

183183
// the command name MUST be the first element of the input
184-
$command =$this->findCommand($name);
184+
$command =$this->find($name);
185185

186186
$this->runningCommand =$command;
187187
$statusCode =$command->run($input,$output);
@@ -329,7 +329,7 @@ public function getLongVersion()
329329
*/
330330
publicfunctionregister($name)
331331
{
332-
return$this->addCommand(newCommand($name));
332+
return$this->add(newCommand($name));
333333
}
334334

335335
/**
@@ -340,7 +340,7 @@ public function register($name)
340340
publicfunctionaddCommands(array$commands)
341341
{
342342
foreach ($commandsas$command) {
343-
$this->addCommand($command);
343+
$this->add($command);
344344
}
345345
}
346346

@@ -353,7 +353,7 @@ public function addCommands(array $commands)
353353
*
354354
* @return Command The registered command
355355
*/
356-
publicfunctionaddCommand(Command$command)
356+
publicfunctionadd(Command$command)
357357
{
358358
$command->setApplication($this);
359359

@@ -375,7 +375,7 @@ public function addCommand(Command $command)
375375
*
376376
* @throws \InvalidArgumentException When command name given does not exist
377377
*/
378-
publicfunctiongetCommand($name)
378+
publicfunctionget($name)
379379
{
380380
if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
381381
thrownew \InvalidArgumentException(sprintf('The command "%s" does not exist.',$name));
@@ -386,7 +386,7 @@ public function getCommand($name)
386386
if ($this->wantHelps) {
387387
$this->wantHelps =false;
388388

389-
$helpCommand =$this->getCommand('help');
389+
$helpCommand =$this->get('help');
390390
$helpCommand->setCommand($command);
391391

392392
return$helpCommand;
@@ -402,7 +402,7 @@ public function getCommand($name)
402402
*
403403
* @return Boolean true if the command exists, false otherwise
404404
*/
405-
publicfunctionhasCommand($name)
405+
publicfunctionhas($name)
406406
{
407407
returnisset($this->commands[$name]) ||isset($this->aliases[$name]);
408408
}
@@ -451,7 +451,7 @@ public function findNamespace($namespace)
451451
/**
452452
* Finds a command by name or alias.
453453
*
454-
* Contrary togetCommand, this command tries to find the best
454+
* Contrary toget, this command tries to find the best
455455
* match if you give it an abbreviation of a name or alias.
456456
*
457457
* @param string $name A command name or a command alias
@@ -460,7 +460,7 @@ public function findNamespace($namespace)
460460
*
461461
* @throws \InvalidArgumentException When command name is incorrect or ambiguous
462462
*/
463-
publicfunctionfindCommand($name)
463+
publicfunctionfind($name)
464464
{
465465
// namespace
466466
$namespace ='';
@@ -481,7 +481,7 @@ public function findCommand($name)
481481

482482
$abbrevs =static::getAbbreviations($commands);
483483
if (isset($abbrevs[$name]) &&1 ==count($abbrevs[$name])) {
484-
return$this->getCommand($namespace ?$namespace.':'.$abbrevs[$name][0] :$abbrevs[$name][0]);
484+
return$this->get($namespace ?$namespace.':'.$abbrevs[$name][0] :$abbrevs[$name][0]);
485485
}
486486

487487
if (isset($abbrevs[$name]) &&count($abbrevs[$name]) >1) {
@@ -500,7 +500,7 @@ public function findCommand($name)
500500
thrownew \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).',$fullName,$this->getAbbreviationSuggestions($abbrevs[$fullName])));
501501
}
502502

503-
return$this->getCommand($abbrevs[$fullName][0]);
503+
return$this->get($abbrevs[$fullName][0]);
504504
}
505505

506506
/**
@@ -512,7 +512,7 @@ public function findCommand($name)
512512
*
513513
* @return array An array of Command instances
514514
*/
515-
publicfunctiongetCommands($namespace =null)
515+
publicfunctionall($namespace =null)
516516
{
517517
if (null ===$namespace) {
518518
return$this->commands;
@@ -566,7 +566,7 @@ static public function getAbbreviations($names)
566566
*/
567567
publicfunctionasText($namespace =null)
568568
{
569-
$commands =$namespace ?$this->getCommands($this->findNamespace($namespace)) :$this->commands;
569+
$commands =$namespace ?$this->all($this->findNamespace($namespace)) :$this->commands;
570570

571571
$messages =array($this->getHelp(),'');
572572
if ($namespace) {
@@ -607,7 +607,7 @@ public function asText($namespace = null)
607607
*/
608608
publicfunctionasXml($namespace =null,$asDom =false)
609609
{
610-
$commands =$namespace ?$this->getCommands($this->findNamespace($namespace)) :$this->commands;
610+
$commands =$namespace ?$this->all($this->findNamespace($namespace)) :$this->commands;
611611

612612
$dom =new \DOMDocument('1.0','UTF-8');
613613
$dom->formatOutput =true;

‎src/Symfony/Component/Console/Command/HelpCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function setCommand(Command $command)
6565
protectedfunctionexecute(InputInterface$input,OutputInterface$output)
6666
{
6767
if (null ===$this->command) {
68-
$this->command =$this->application->getCommand($input->getArgument('command_name'));
68+
$this->command =$this->application->get($input->getArgument('command_name'));
6969
}
7070

7171
if ($input->getOption('xml')) {

‎src/Symfony/Component/Console/Shell.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ protected function autocompleter($text, $position)
9797

9898
// task name?
9999
if (false ===strpos($text,'') || !$text) {
100-
returnarray_keys($this->application->getCommands());
100+
returnarray_keys($this->application->all());
101101
}
102102

103103
// options and arguments?

‎src/Symfony/Component/DomCrawler/Form.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function getMethod()
215215
*
216216
* @return Boolean true if the field exists, false otherwise
217217
*/
218-
publicfunctionhasField($name)
218+
publicfunctionhas($name)
219219
{
220220
returnisset($this->fields[$name]);
221221
}
@@ -229,9 +229,9 @@ public function hasField($name)
229229
*
230230
* @throws \InvalidArgumentException When field is not present in this form
231231
*/
232-
publicfunctiongetField($name)
232+
publicfunctionget($name)
233233
{
234-
if (!$this->hasField($name)) {
234+
if (!$this->has($name)) {
235235
thrownew \InvalidArgumentException(sprintf('The form has no "%s" field',$name));
236236
}
237237

@@ -245,7 +245,7 @@ public function getField($name)
245245
*
246246
* @return FormField The field instance
247247
*/
248-
publicfunctionsetField(Field\FormField$field)
248+
publicfunctionset(Field\FormField$field)
249249
{
250250
$this->fields[$field->getName()] =$field;
251251
}
@@ -255,7 +255,7 @@ public function setField(Field\FormField $field)
255255
*
256256
* @return array An array of fields
257257
*/
258-
publicfunctiongetFields()
258+
publicfunctionall()
259259
{
260260
return$this->fields;
261261
}
@@ -280,21 +280,21 @@ protected function initialize()
280280
$nodeName =$node->nodeName;
281281

282282
if ($node ===$button) {
283-
$this->setField(newField\InputFormField($node));
283+
$this->set(newField\InputFormField($node));
284284
}elseif ('select' ==$nodeName ||'input' ==$nodeName &&'checkbox' ==$node->getAttribute('type')) {
285-
$this->setField(newField\ChoiceFormField($node));
285+
$this->set(newField\ChoiceFormField($node));
286286
}elseif ('input' ==$nodeName &&'radio' ==$node->getAttribute('type')) {
287-
if ($this->hasField($node->getAttribute('name'))) {
288-
$this->getField($node->getAttribute('name'))->addChoice($node);
287+
if ($this->has($node->getAttribute('name'))) {
288+
$this->get($node->getAttribute('name'))->addChoice($node);
289289
}else {
290-
$this->setField(newField\ChoiceFormField($node));
290+
$this->set(newField\ChoiceFormField($node));
291291
}
292292
}elseif ('input' ==$nodeName &&'file' ==$node->getAttribute('type')) {
293-
$this->setField(newField\FileFormField($node));
293+
$this->set(newField\FileFormField($node));
294294
}elseif ('input' ==$nodeName && !in_array($node->getAttribute('type'),array('submit','button','image'))) {
295-
$this->setField(newField\InputFormField($node));
295+
$this->set(newField\InputFormField($node));
296296
}elseif ('textarea' ==$nodeName) {
297-
$this->setField(newField\TextareaFormField($node));
297+
$this->set(newField\TextareaFormField($node));
298298
}
299299
}
300300
}
@@ -308,7 +308,7 @@ protected function initialize()
308308
*/
309309
publicfunctionoffsetExists($name)
310310
{
311-
return$this->hasField($name);
311+
return$this->has($name);
312312
}
313313

314314
/**
@@ -322,7 +322,7 @@ public function offsetExists($name)
322322
*/
323323
publicfunctionoffsetGet($name)
324324
{
325-
if (!$this->hasField($name)) {
325+
if (!$this->has($name)) {
326326
thrownew \InvalidArgumentException(sprintf('The form field "%s" does not exist',$name));
327327
}
328328

@@ -339,7 +339,7 @@ public function offsetGet($name)
339339
*/
340340
publicfunctionoffsetSet($name,$value)
341341
{
342-
if (!$this->hasField($name)) {
342+
if (!$this->has($name)) {
343343
thrownew \InvalidArgumentException(sprintf('The form field "%s" does not exist',$name));
344344
}
345345

‎src/Symfony/Component/EventDispatcher/Event.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function isProcessed()
102102
*
103103
* @return array The event parameters
104104
*/
105-
publicfunctiongetParameters()
105+
publicfunctionall()
106106
{
107107
return$this->parameters;
108108
}
@@ -114,7 +114,7 @@ public function getParameters()
114114
*
115115
* @return Boolean true if the parameter exists, false otherwise
116116
*/
117-
publicfunctionhasParameter($name)
117+
publicfunctionhas($name)
118118
{
119119
returnarray_key_exists($name,$this->parameters);
120120
}
@@ -128,7 +128,7 @@ public function hasParameter($name)
128128
*
129129
* @throws \InvalidArgumentException When parameter doesn't exists for this event
130130
*/
131-
publicfunctiongetParameter($name)
131+
publicfunctionget($name)
132132
{
133133
if (!array_key_exists($name,$this->parameters)) {
134134
thrownew \InvalidArgumentException(sprintf('The event "%s" has no "%s" parameter.',$this->name,$name));
@@ -143,7 +143,7 @@ public function getParameter($name)
143143
* @param string $name The parameter name
144144
* @param mixed $value The parameter value
145145
*/
146-
publicfunctionsetParameter($name,$value)
146+
publicfunctionset($name,$value)
147147
{
148148
$this->parameters[$name] =$value;
149149
}

‎src/Symfony/Component/HttpFoundation/HeaderBag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ public function contains($key, $value)
145145
}
146146

147147
/**
148-
*Deletes a header.
148+
*Removes a header.
149149
*
150150
* @param string $key The HTTP header name
151151
*/
152-
publicfunctiondelete($key)
152+
publicfunctionremove($key)
153153
{
154154
$key =strtr(strtolower($key),'_','-');
155155

‎src/Symfony/Component/HttpFoundation/ParameterBag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ public function has($key)
105105
}
106106

107107
/**
108-
*Deletes a parameter.
108+
*Removes a parameter.
109109
*
110110
* @param string $key The key
111111
*/
112-
publicfunctiondelete($key)
112+
publicfunctionremove($key)
113113
{
114114
unset($this->parameters[$key]);
115115
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp