91 lines
No EOL
4 KiB
JSON
91 lines
No EOL
4 KiB
JSON
{
|
|
"uuid": [
|
|
{
|
|
"value": "ebf479a8-f93c-4972-ae90-8b59a0ca8081"
|
|
}
|
|
],
|
|
"langcode": [
|
|
{
|
|
"value": "en"
|
|
}
|
|
],
|
|
"type": [
|
|
{
|
|
"target_id": "daily_email",
|
|
"target_type": "node_type",
|
|
"target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7"
|
|
}
|
|
],
|
|
"revision_timestamp": [
|
|
{
|
|
"value": "2025-05-11T09:00:06+00:00"
|
|
}
|
|
],
|
|
"revision_uid": [
|
|
{
|
|
"target_type": "user",
|
|
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
|
}
|
|
],
|
|
"revision_log": [],
|
|
"status": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"uid": [
|
|
{
|
|
"target_type": "user",
|
|
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
|
}
|
|
],
|
|
"title": [
|
|
{
|
|
"value": "Writing custom PHPStan rules for Drupal projects"
|
|
}
|
|
],
|
|
"created": [
|
|
{
|
|
"value": "2024-09-22T00:00:00+00:00"
|
|
}
|
|
],
|
|
"changed": [
|
|
{
|
|
"value": "2025-05-11T09:00:06+00:00"
|
|
}
|
|
],
|
|
"promote": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"sticky": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"default_langcode": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"revision_translation_affected": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"path": [
|
|
{
|
|
"alias": "\/daily\/2024\/09\/22\/writing-custom-phpstan-rules-for-drupal-projects",
|
|
"langcode": "en"
|
|
}
|
|
],
|
|
"body": [
|
|
{
|
|
"value": "\n <p>Today, I watched a video recording of a session by Ond\u0159ej Mirtes - the creator of PHPStan - on writing custom rules for PHPStan.<\/p>\n\n<p>After explaining how to write them, he showed some examples of custom rules - one of which was ensuring a <code>Person<\/code> class couldn't be created outside of a <code>PersonRepository<\/code> class.<\/p>\n\n<p>This seemed straightforward\u00a0so I thought about how I could do something similar within my <a href=\"\/atdc\">Drupal automated testing email course<\/a> to check my Drupal code.<\/p>\n\n<p>Similar to Ond\u0159ej's example, I wondered if I could enforce that no post nodes should be created outside of the <code>PostBuilder<\/code> class by searching\u00a0for any code like <code>Node::create(['type' => 'post'])<\/code>.<\/p>\n\n<p>I was able to get a version working quickly and have <a href=\"https:\/\/gist.github.com\/opdavies\/a2f9d92cf3b67db6a64b9fca4e4e6697\">posted it as a gist<\/a>.<\/p>\n\n<p>I'm sure some improvements can be made, but it was a successful experiment and something I can see me using more in the future.<\/p>\n\n ",
|
|
"format": "full_html",
|
|
"processed": "\n <p>Today, I watched a video recording of a session by Ond\u0159ej Mirtes - the creator of PHPStan - on writing custom rules for PHPStan.<\/p>\n\n<p>After explaining how to write them, he showed some examples of custom rules - one of which was ensuring a <code>Person<\/code> class couldn't be created outside of a <code>PersonRepository<\/code> class.<\/p>\n\n<p>This seemed straightforward so I thought about how I could do something similar within my <a href=\"http:\/\/default\/atdc\">Drupal automated testing email course<\/a> to check my Drupal code.<\/p>\n\n<p>Similar to Ond\u0159ej's example, I wondered if I could enforce that no post nodes should be created outside of the <code>PostBuilder<\/code> class by searching for any code like <code>Node::create(['type' => 'post'])<\/code>.<\/p>\n\n<p>I was able to get a version working quickly and have <a href=\"https:\/\/gist.github.com\/opdavies\/a2f9d92cf3b67db6a64b9fca4e4e6697\">posted it as a gist<\/a>.<\/p>\n\n<p>I'm sure some improvements can be made, but it was a successful experiment and something I can see me using more in the future.<\/p>\n\n ",
|
|
"summary": null
|
|
}
|
|
]
|
|
} |