74
loading...
This website collects cookies to deliver better user experience
$ratings
and offered me a line of code that does just that. Then I just have to hit Tab
to accept the snippet. Neat.computeAverage()
and see what Copilot offers:Tab
repeatedly as suggestions showed up to come up with a complete function that computes the average.$ composer create-project drupal/recommended-project drupal 9.2
$ code drupal
web/modules/custom/mymodule/src/Form/MyForm.php
, insert a comment at the top describing what kind of Drupal form we want to build and see if any suggestion shows up:namespace
, Copilot suggests a properly formatted PSR-4 Drupal namespace. That is a good sign. class
:Tab
as suggestions show up and insert a few PHP comments here and there. Copilot ends up writing the entire class:getFormId()
, buildForm()
, validateForm()
, submitForm()
) albeit with deprecated signaturest()
function, which again demonstrates some Drupal-specific knowledgeemail
instead of textfield
drupal_set_message()
was introduced even though it was deprecated a few years ago. Again, Copilot may not be aware that I am writing code specifically for Drupal 9. The drupal-check extension would likely catch this.buildForm()
even though the comment I typed suggested that I wanted only the Name field to be required.$form_state
is supposed to be a FormStateInterface
object, not an array). The change happened several years ago.web/modules/custom/mymodule/mymodule.module
and prompt Copilot to offer code that displays user-entered content:arg()
which was deprecated in Drupal 8.t()
function and a safe @
placeholder, which brings protection against XSS attacks. The code looks secure.db_select()
. Let's give Copilot a hint:\Drupal::entityQuery()
.74