-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[Parameter] Deprecate names starting or ending with a colon #6880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -19,6 +19,8 @@ | |||||||||||
|
||||||||||||
namespace Doctrine\ORM\Query; | ||||||||||||
|
||||||||||||
use function preg_match; | ||||||||||||
use function trigger_error; | ||||||||||||
use function trim; | ||||||||||||
|
||||||||||||
/** | ||||||||||||
|
@@ -67,6 +69,10 @@ class Parameter | |||||||||||
*/ | ||||||||||||
public function __construct($name, $value, $type = null) | ||||||||||||
{ | ||||||||||||
if (preg_match('/^:|:$/', $name)) { | ||||||||||||
@trigger_error('Starting or ending a parameter name with ":" is deprecated since 2.7 and will cause an error in 3.0', E_USER_DEPRECATED); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add the package name and use some linebreaks:
Suggested change
|
||||||||||||
} | ||||||||||||
|
||||||||||||
$this->name = trim($name, ':'); | ||||||||||||
$this->typeSpecified = $type !== null; | ||||||||||||
|
||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,29 @@ | ||||||
<?php | ||||||
declare(strict_types=1); | ||||||
|
||||||
namespace Doctrine\Tests\ORM\Query; | ||||||
|
||||||
use Doctrine\ORM\Query\Parameter; | ||||||
use Doctrine\Tests\DoctrineTestCase; | ||||||
use Doctrine\Tests\VerifyDeprecations; | ||||||
|
||||||
final class ParameterTest extends DoctrineTestCase | ||||||
{ | ||||||
use VerifyDeprecations; | ||||||
|
||||||
/** | ||||||
* @test | ||||||
* @group GH6880 | ||||||
*/ | ||||||
public function deprecationMustBeTriggeredWhenUsingColonInParameterNames() : void | ||||||
{ | ||||||
$this->expectDeprecationMessage('Starting or ending a parameter name with ":" is deprecated since 2.7 and will cause an error in 3.0'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be 2.8 too :) |
||||||
new Parameter(':user_name', 'Testing'); | ||||||
|
||||||
$this->expectDeprecationMessage('Starting or ending a parameter name with ":" is deprecated since 2.7 and will cause an error in 3.0'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
new Parameter('user_name:', 'Testing'); | ||||||
|
||||||
$this->expectDeprecationMessage('Starting or ending a parameter name with ":" is deprecated since 2.7 and will cause an error in 3.0'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
new Parameter(':user_name:', 'Testing'); | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @lcobucci wrote: