Skip to content

Bo's Code Review Style

Analysis of Bo’s code review style based on 400+ comments across 200 MRs. Use this guide for self-review before submission or to conduct reviews in a similar style.

Bo consistently identifies opportunities to simplify code by removing redundant variables, conditions, and operations.

Examples:

“变量可以省略”

“这个判断可以去掉”

“多余变量”

“直接返回array<int, App\Model\Task>就行吧”

“可以简化为 $client_display_chart = $tax_distribution_display_chart['client'] ?? $tax_distribution_display_chart;

Bo emphasizes proper type definitions and avoiding ambiguous types.

Examples:

“缺少类型定义”

“里面用 array shape 更好点”

“类型不对,应该是 list

“return type-hint”

“里面的数据类型是固定的,不应该用 mixed

“可以补上 array shape”

Bo prefers short namespaces and consistent import patterns.

Examples:

“use short namespace”

“short alias”

“使用use,尽量不要用fqcn”

“可以用Arr” (instead of full namespace)

Bo focuses on proper database patterns and performance.

Examples:

“这里最好是改成 DB 的方式更符合 database migration”

“建议使用 chunkById

“用 SQL 做聚合看起来不是很容易读, 可以考虑先查询出所有符合条件的 households 然后 groupBy”

“不能修改原来的 migration 文件,需要建新的来修改数据库结构”

Bo ensures consistent naming patterns.

Examples:

“常量名和内容尽量保持一致吧”

“加上 ‘id’ 会不会好点: new_legends_by_old_legend => new_legend_ids_by_old_legend_id

“命名不统一,有的地方叫engine_model_class,这里叫engine_object_class”

“字典序排列” (alphabetical ordering)

Bo prefers Laravel Collection methods over manual loops.

Examples:

“可以考虑用 Arr::keyBy()

“建议使用解构赋值并提供默认值”

“$tasks是Collection,可以通过 pluck(Task::COLUMN_ID)获取有效的ids”

“可以用 Collection::append 来添加元素更合适”

Bo identifies redundant or incorrect conditional checks.

Examples:

“这个条件应该不需要”

“只需要这个判断就行,外层的 if else 不需要”

“这个 if 可以不需要了”

“判断逻辑有问题”

Bo encourages using modern PHP syntax.

Examples:

“可以改用箭头函数”

“可以试试PHP8.1的新写法”

“Is it possible to use match to replace switch statements”

“str_ends_with” / “str_starts_with” (instead of manual string checks)

Before submitting for review, check these items:

  • Remove unnecessary intermediate variables
  • Remove redundant conditions
  • Inline simple expressions
  • Avoid redundant array operations (toArray, get())
  • Add type hints to all parameters and return types
  • Use array shapes instead of mixed
  • Use list for sequential arrays
  • Define @phpstan-type for complex repeated types
  • Use short namespace imports (use Arr instead of \Illuminate\Support\Arr)
  • Use FQCN in PHPDoc comments
  • Consistent import style throughout file
  • Use DB for data migrations, ORM for application code
  • Use chunkById for large datasets
  • Don’t modify existing migration files
  • Use Schema::table for DDL operations
  • Constants contain what they describe (ids in name if contains ids)
  • Alphabetical ordering for lists/constants
  • Consistent naming across related code
  • Variable names match their purpose
  • Use Arr::keyBy, Arr::first instead of manual loops
  • Use pluck to extract values
  • Use Collection methods instead of array functions
  • Destructure with defaults instead of isset checks
  • Remove obviously true conditions
  • Combine related if statements
  • Use early returns to reduce nesting
  • Check for inverted logic
  • Use arrow functions for simple callbacks
  • Use match instead of switch when appropriate
  • Use str_ends_with/str_starts_with
  • Use constructor property promotion
TraitExample
Simplification-focused”变量可以省略”
Type precision”里面用 array shape 更好点”
Short namespace preference”use short namespace”
Collection-savvy”可以考虑用 Arr::keyBy()“
Alphabetical ordering”字典序排列”
Modern PHP advocate”可以试试PHP8.1的新写法”
BilingualChinese for explanations, English for code terms
  • “变量可以省略” — Remove unnecessary variables
  • “可以简化为…” — Suggesting simplification
  • “缺少类型定义” — Missing type definitions
  • “字典序排列” — Alphabetical ordering
  • “use short namespace” — Namespace style
  • “这个判断可以去掉” — Redundant condition
  • “可以改用…” — Suggesting alternatives
  • “多余” — Redundant code/space

Based on Bo’s reviews, avoid these patterns:

  1. Unnecessary variables that are used only once
  2. Redundant conditions that are always true
  3. Full namespace when import is available
  4. Mixed types when specific types are known
  5. Manual loops when Collection methods exist
  6. Modifying old migrations instead of creating new ones
  7. Inconsistent naming across related code
  8. Unsorted constants that should be alphabetical

Bo’s review style is precision and simplification focused, emphasizing:

  1. Code reduction — Remove all unnecessary variables, conditions, and operations
  2. Type accuracy — Use specific types, array shapes, and proper type hints
  3. Namespace consistency — Short imports, consistent style
  4. Collection fluency — Use Laravel Collection methods effectively
  5. Modern PHP — Embrace arrow functions, match expressions, modern string functions
  6. Ordering discipline — Alphabetical ordering for maintainability
  7. Database correctness — Proper migration patterns and query optimization